/* style.css - Updated for Admin/Public separation */
:root {
    /* Dark Theme Colors */
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --primary-light: #a78bfa;
    --secondary: #10b981;
    --secondary-dark: #059669;
    --accent: #f59e0b;
    --accent-dark: #d97706;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    
    /* Background Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --bg-modal: rgba(15, 23, 42, 0.95);
    
    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Border & Shadows */
    --border-color: #334155;
    --border-radius: 12px;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.4);
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--primary), var(--primary-dark));
    --gradient-secondary: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
    --gradient-danger: linear-gradient(135deg, var(--danger), var(--danger-dark));
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
    transition: var(--transition);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
.header {
    background: var(--gradient-primary);
    border-radius: var(--border-radius);
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    animation: slideDown 0.8s ease-out;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header-left {
    flex: 1;
    min-width: 300px;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-primary);
    opacity: 0.9;
    font-size: 1.1rem;
}

.admin-badge {
    background: var(--gradient-danger);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 10px;
    animation: pulse 2s infinite;
}

.header-actions {
    display: flex;
    gap: 15px;
}

/* Loading State */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    border-radius: var(--border-radius);
    padding: 20px;
    margin: 20px 0;
    text-align: center;
    color: var(--danger);
}

.error-message i {
    font-size: 2rem;
    margin-bottom: 10px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 25px;
    margin-bottom: 40px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.card-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 25px;
}

/* Summary Card */
.summary-card {
    grid-column: span 4;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.stat {
    text-align: center;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 500;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 5px;
}

.stat-change {
    font-size: 0.9rem;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-block;
}

.stat-change.positive {
    background: rgba(16, 185, 129, 0.2);
    color: var(--secondary);
}

.stat-change.negative {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.stat-subtext {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Chart Cards */
.chart-card {
    grid-column: span 8;
}

.chart-container {
    height: 300px;
    position: relative;
}

/* Table Card */
.table-card {
    grid-column: span 8;
}

.table-container {
    overflow-x: auto;
}

.grades-table {
    width: 100%;
    border-collapse: collapse;
}

.grades-table thead {
    background: var(--bg-secondary);
}

.grades-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

.grades-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.grades-table tbody tr {
    transition: var(--transition);
}

.grades-table tbody tr:hover {
    background: var(--bg-hover);
}

/* Grade Badges */
.grade-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
    min-width: 40px;
}

.grade-1 {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.grade-2 {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
}

.grade-3 {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.grade-4 {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.grade-5 {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    color: white;
}

.grade-6 {
    background: linear-gradient(135deg, #000000, #1f2937);
    color: white;
}

/* Distribution Card */
.distribution-card {
    grid-column: span 4;
}

.distribution-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    flex: 1;
    min-width: 150px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* Performance Card */
.performance-card {
    grid-column: span 4;
}

.performance-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.performance-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.performance-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.performance-icon.excellent {
    background: rgba(16, 185, 129, 0.2);
    color: var(--secondary);
}

.performance-icon.good {
    background: rgba(139, 92, 246, 0.2);
    color: var(--primary);
}

.performance-icon.average {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent);
}

.performance-icon.poor {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.performance-info h4 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.performance-info p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-icon, .btn-danger {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 92, 246, 0.4);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(239, 68, 68, 0.4);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 50%;
}

.btn-icon:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Time Selector */
.time-selector {
    display: flex;
    gap: 5px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 8px;
}

.time-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.time-btn.active {
    background: var(--gradient-primary);
    color: white;
}

.time-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

select, input, textarea {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 15px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    width: 100%;
    transition: var(--transition);
}

select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-modal);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-modal:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 25px;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.form-actions .btn-primary,
.form-actions .btn-secondary {
    flex: 1;
}

/* Admin Form Specific */
.grade-inputs {
    display: grid;
    grid-template-columns: 1fr 100px;
    gap: 15px;
    align-items: end;
}

.grade-inputs .form-group:last-child {
    margin-bottom: 0;
}

/* Filter Controls */
.filter-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

.footer-note {
    font-size: 0.8rem;
    margin-top: 5px;
    opacity: 0.7;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .summary-card,
    .table-card,
    .chart-card,
    .distribution-card,
    .performance-card {
        grid-column: span 6;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .header-left {
        min-width: auto;
    }
    
    .header h1 {
        font-size: 2rem;
        justify-content: center;
    }
    
    .header-actions {
        justify-content: center;
    }
    
    .summary-stats {
        grid-template-columns: 1fr;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .time-selector {
        align-self: stretch;
    }
    
    .time-btn {
        flex: 1;
        text-align: center;
    }
    
    .grade-inputs {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .header {
        padding: 20px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    .grades-table th,
    .grades-table td {
        padding: 10px 8px;
        font-size: 0.9rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1001;
    animation: slideInRight 0.3s ease-out;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.notification-success {
    background: var(--gradient-secondary);
    color: white;
}

.notification-error {
    background: var(--gradient-danger);
    color: white;
}

.notification-info {
    background: var(--gradient-primary);
    color: white;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}
