/* ========================================
   RTU Grades Portal - Modern Dark Theme
   ======================================== */

:root {
    /* Core palette - Deep navy with teal accents */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a1f2e;
    --bg-card-hover: #1f2937;
    --bg-input: #0d1117;
    
    /* Accent colors */
    --accent-primary: #14b8a6;
    --accent-primary-dim: rgba(20, 184, 166, 0.15);
    --accent-secondary: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #14b8a6 0%, #06b6d4 100%);
    
    /* Text colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Status colors */
    --success: #22c55e;
    --success-dim: rgba(34, 197, 94, 0.15);
    --warning: #f59e0b;
    --warning-dim: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-dim: rgba(239, 68, 68, 0.15);
    --info: #3b82f6;
    --info-dim: rgba(59, 130, 246, 0.15);
    
    /* Borders & shadows */
    --border-color: rgba(148, 163, 184, 0.1);
    --border-focus: rgba(20, 184, 166, 0.5);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(20, 184, 166, 0.15);
    
    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Typography */
    --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Background Pattern */
.bg-pattern {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(20, 184, 166, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(6, 182, 212, 0.08) 0%, transparent 50%),
        linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: calc(100vh - 60px);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.center {
    text-align: center;
}

/* ========================================
   Splash Screen
   ======================================== */

.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 23, 0.95);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.3s ease-out;
}

.splash-screen.hidden {
    display: none;
}

.splash-content {
    max-width: 480px;
    width: 100%;
    padding: 2.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    text-align: center;
    animation: slideInUp 0.4s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.splash-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    background: var(--warning-dim);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--warning);
}

.splash-icon svg {
    width: 32px;
    height: 32px;
    color: var(--warning);
}

.splash-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.splash-content p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.btn-splash {
    padding: 0.875rem 2rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-splash:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 0 30px rgba(20, 184, 166, 0.4);
}

.btn-splash:active {
    transform: translateY(0);
}

@media (max-width: 640px) {
    .splash-content {
        padding: 2rem 1.5rem;
    }
    
    .splash-icon {
        width: 56px;
        height: 56px;
    }
    
    .splash-icon svg {
        width: 28px;
        height: 28px;
    }
    
    .splash-content h2 {
        font-size: 1.25rem;
    }
    
    .splash-content p {
        font-size: 0.875rem;
    }
}

/* ========================================
   Login Card
   ======================================== */

.login-card {
    max-width: 420px;
    margin: 8vh auto 0;
    padding: 3rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md), 0 0 30px rgba(20, 184, 166, 0.3);
}

.logo-icon svg {
    width: 36px;
    height: 36px;
    color: white;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.tagline {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Form Elements */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-group input {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
}

.input-group input::placeholder {
    color: var(--text-muted);
    font-family: var(--font-main);
    letter-spacing: normal;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px var(--accent-primary-dim);
}

.input-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 1rem 1.5rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-main);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 0 30px rgba(20, 184, 166, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-primary.loading .btn-text {
    visibility: hidden;
}

.btn-primary.loading .btn-loader {
    display: block;
}

.btn-loader {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Error Message */
.error-message {
    margin-top: 1rem;
    padding: 0.875rem 1rem;
    background: var(--danger-dim);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: #fca5a5;
    font-size: 0.875rem;
    display: none;
}

.error-message.show {
    display: block;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ========================================
   Dashboard
   ======================================== */

.dashboard {
    animation: fadeIn 0.4s ease-out;
}

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

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-back svg {
    width: 18px;
    height: 18px;
}

.semester-select-wrapper {
    position: relative;
}

.semester-select {
    appearance: none;
    padding: 0.625rem 2.5rem 0.625rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-main);
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    min-width: 280px;
    transition: all 0.2s ease;
}

.semester-select:hover {
    border-color: var(--accent-primary);
}

.semester-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-dim);
}

/* Student Card */
.student-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    animation: slideInRight 0.5s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.student-avatar {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    background: var(--accent-primary-dim);
    border: 2px solid var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.student-avatar svg {
    width: 36px;
    height: 36px;
    color: var(--accent-primary);
}

.student-info h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: -0.01em;
}

.student-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.student-id-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: 9999px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    transition: all 0.3s ease;
    animation: fadeInUp 0.5s ease-out backwards;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.15s; }
.stat-card:nth-child(3) { animation-delay: 0.2s; }
.stat-card:nth-child(4) { animation-delay: 0.25s; }
.stat-card:nth-child(5) { animation-delay: 0.3s; }

.stat-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }
.stat-value.info { color: var(--info); }
.stat-value.accent { color: var(--accent-primary); }

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Grades Card */
.grades-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.5rem;
    animation: fadeInUp 0.5s ease-out 0.2s backwards;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-header h3 {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1rem;
    font-weight: 700;
}

.card-header h3 svg {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.semester-badge {
    padding: 0.375rem 0.875rem;
    background: var(--accent-primary-dim);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-primary);
}

/* Grades Table */
.grades-table-wrapper {
    overflow-x: auto;
}

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

.grades-table th,
.grades-table td {
    padding: 1rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.grades-table th {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.15);
}

.grades-table tbody tr {
    transition: background 0.15s ease;
}

.grades-table tbody tr:hover {
    background: rgba(20, 184, 166, 0.05);
}

.grades-table tbody tr:last-child td {
    border-bottom: none;
}

.subject-name {
    font-weight: 500;
}

.subject-code {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.grade-cell {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.9rem;
}

.grade-cell.excellent { color: var(--success); }
.grade-cell.good { color: #4ade80; }
.grade-cell.average { color: var(--warning); }
.grade-cell.poor { color: #fb923c; }
.grade-cell.fail { color: var(--danger); }
.grade-cell.special { color: var(--text-muted); font-style: italic; }

/* Table Footer */
.grades-table tfoot td {
    padding: 1rem 1.25rem;
    font-weight: 700;
    background: rgba(20, 184, 166, 0.08);
    border-top: 2px solid var(--accent-primary);
}

.grades-table tfoot .gwa-label {
    color: var(--text-secondary);
}

.grades-table tfoot .gwa-value {
    font-family: var(--font-mono);
    font-size: 1.125rem;
    color: var(--accent-primary);
}

/* Legends Card */
.legends-card {
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    animation: fadeInUp 0.5s ease-out 0.3s backwards;
}

.legends-card h4 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.legends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
}

.legend-code.warning {
    background: var(--warning-dim);
    color: var(--warning);
}

.legend-code.danger {
    background: var(--danger-dim);
    color: var(--danger);
}

.legend-code.info {
    background: var(--info-dim);
    color: var(--info);
}

.legend-code.muted {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }
    
    .login-card {
        margin-top: 4vh;
        padding: 2rem 1.5rem;
    }
    
    .logo-icon {
        width: 60px;
        height: 60px;
    }
    
    .logo-icon svg {
        width: 30px;
        height: 30px;
    }
    
    .logo h1 {
        font-size: 1.5rem;
    }
    
    .student-card {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem;
    }
    
    .student-avatar {
        width: 64px;
        height: 64px;
    }
    
    .student-avatar svg {
        width: 32px;
        height: 32px;
    }
    
    .semester-select {
        min-width: 100%;
        width: 100%;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-back {
        align-self: flex-start;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .grades-table th,
    .grades-table td {
        padding: 0.75rem;
        font-size: 0.85rem;
    }
    
    .card-header {
        padding: 1rem;
    }
    
    .legends-grid {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Selection */
::selection {
    background: var(--accent-primary);
    color: white;
}



