:root {
    --primary: #6366f1; /* Indigo */
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #ec4899; /* Pink */
    --secondary-dark: #be185d;
    --accent: #06b6d4; /* Cyan */
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.6); /* Glassy Slate */
    --bg-card-hover: rgba(30, 41, 59, 0.8);
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --success: #10b981;
    --warning: #fbbf24;
    --danger: #ef4444;
    --glass-border: rgba(255, 255, 255, 0.1);
    --radius: 20px;
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.3) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(236, 72, 153, 0.3) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.3) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(16, 185, 129, 0.3) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    line-height: 1.6;
    padding: 60px 20px;
}

.container {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
    margin: 0 auto;
}

/* Glassmorphism Classes */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.glass:hover {
    background: var(--bg-card-hover);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.6);
}

/* Login Page Styling */
.login-box {
    max-width: 480px;
    width: 90%;
    padding: 60px 45px;
    text-align: center;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    animation: fadeInScale 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.login-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 6px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    z-index: 2;
}

/* Background Blobs for Atmosphere */
.blob {
    position: fixed;
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    filter: blur(80px);
    border-radius: 50%;
    z-index: -1;
    opacity: 0.15;
    animation: floating 20s infinite alternate ease-in-out;
}

.blob-1 { top: -100px; left: -100px; background: var(--primary); }
.blob-2 { bottom: -100px; right: -100px; background: var(--secondary); animation-delay: -5s; }
.blob-3 { top: 40%; left: 60%; width: 300px; height: 300px; background: var(--accent); animation-delay: -10s; }

@keyframes floating {
    0% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, 50px) rotate(10deg); }
    66% { transform: translate(-20px, 20px) rotate(-10deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

.login-logo {
    width: 160px;
    height: auto;
    margin-bottom: 25px;
    filter: drop-shadow(0 15px 25px rgba(236, 72, 153, 0.4));
    transition: transform 0.5s ease;
}

.login-logo:hover {
    transform: rotate(5deg) scale(1.05);
}

.mr-2 {
    margin-right: 12px;
}

.school-name {
    margin-bottom: 5px;
}

.login-box h1 {
    font-size: 2.2rem;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #fff 40%, #cbd5e1);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.2;
}

.login-box p {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 35px;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.form-group {
    margin-bottom: 30px;
    text-align: left;
}

.form-group label {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.form-group input {
    width: 100%;
    padding: 18px 24px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    color: white;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-group input:focus {
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.7);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25), inset 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
}

.login-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 16px;
    color: white;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    margin-top: 10px;
    box-shadow: 0 15px 30px rgba(236, 72, 153, 0.3);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.login-btn:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 20px 40px rgba(236, 72, 153, 0.45);
    filter: brightness(1.1);
}

.login-btn:active {
    transform: translateY(-2px) scale(0.98);
}

.login-footer {
    margin-top: 45px;
    padding-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.login-footer p {
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.login-footer span {
    color: #fff;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Dashboard Styling */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 25px 30px;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 25px;
}

.school-logo {
    height: 60px;
    width: auto;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.school-title {
    font-size: 1.1rem;
    margin: 0;
    color: var(--primary-light);
    font-weight: 700;
}

.student-name {
    font-size: 1.35rem;
    margin: 4px 0;
    font-weight: 700;
}

.student-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
    display: flex;
    align-items: center;
}

.meta-divider {
    margin: 0 10px;
    opacity: 0.3;
}

.logout-btn {
    padding: 12px 24px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.avatar {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 900;
    font-size: 1.5rem;
    box-shadow: 0 8px 16px rgba(6, 182, 212, 0.3);
    border: 2px solid rgba(255,255,255,0.2);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.stat-card {
    padding: 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.05), transparent);
    transform: translateX(-100%);
    transition: 0.5s;
}

.stat-card:hover::before {
    transform: translateX(100%);
}

.gpa-card {
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    border: none;
}
.gpa-card .stat-val, .gpa-card .stat-label {
    color: white;
    background: none;
    -webkit-text-fill-color: white;
    text-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.stat-val {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #fff, var(--primary-light));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.grades-table th {
    background: rgba(15, 23, 42, 0.6);
    padding: 20px;
    text-align: left;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.grades-table th:first-child { border-top-left-radius: 12px; }
.grades-table th:last-child { border-top-right-radius: 12px; }

.grades-table td {
    padding: 22px 20px;
    border-bottom: 1px solid var(--glass-border);
    transition: background 0.3s ease;
}

.grades-table tr:hover td {
    background: rgba(255, 255, 255, 0.05);
}

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

.grade-badge {
    padding: 8px 16px;
    border-radius: 30px;
    font-weight: 800;
    font-size: 1rem;
    display: inline-block;
    min-width: 60px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.grade-4 { background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.4)); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.grade-3 { background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(6, 182, 212, 0.4)); color: #67e8f9; border: 1px solid rgba(6, 182, 212, 0.3); }
.grade-2 { background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(251, 191, 36, 0.4)); color: #fde047; border: 1px solid rgba(251, 191, 36, 0.3); }
.grade-1 { background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.4)); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }

.logout-btn:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
    transform: translateY(-2px);
}

.data-section {
    padding: 30px;
    margin-bottom: 30px;
    overflow: hidden;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.activity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.error-message {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 25px;
    font-size: 0.95rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
    text-align: center;
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.dashboard-section-title {
    margin-bottom: 25px;
    border-left: 5px solid var(--primary);
    padding-left: 20px;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dashboard-section-title-activities {
    border-left-color: var(--success);
}

.activity-card {
    padding: 20px;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255,255,255,0.05);
    transition: all 0.3s ease;
}

.activity-card:hover {
    background: rgba(15, 23, 42, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.activity-name {
    font-size: 1.05rem;
    font-weight: 600;
}

.activity-status-pass {
    color: #10b981;
    background: rgba(16, 185, 129, 0.15);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.9rem;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.activity-status-fail {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.9rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

@media (max-width: 992px) {
    .container {
        padding: 15px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 20px 15px !important;
        justify-content: flex-start;
    }
    .dashboard-header {
        flex-direction: column;
        text-align: center;
        padding: 30px 20px;
        gap: 20px;
    }
    .dashboard-header > div {
        flex-direction: column;
        gap: 15px;
    }
    .user-info {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    .logout-btn {
        width: 100%;
        margin-left: 0 !important;
        text-align: center;
        justify-content: center;
        display: flex;
    }
    .stat-val {
        font-size: 2.8rem;
    }
    .login-box {
        padding: 40px 25px;
    }
    .login-box h1 {
        font-size: 1.8rem;
    }
    .grades-table th, .grades-table td {
        padding: 15px 12px;
        font-size: 0.85rem;
    }
    .grades-table th:nth-child(2), 
    .grades-table td:nth-child(2) {
        display: none; /* Hide credits on mobile to save space */
    }
    .dashboard-section-title {
        font-size: 1.25rem;
        padding-left: 15px;
    }
    .stat-card {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .stat-val {
        font-size: 2.5rem;
    }
    .grade-badge {
        padding: 6px 12px;
        font-size: 0.9rem;
        min-width: 50px;
    }
    .dashboard-header img {
        height: 50px !important;
    }
    .avatar {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    .activity-card {
        padding: 15px;
    }
    .activity-name {
        font-size: 0.95rem;
    }
    /* Login Page Mobile Optimization */
    .login-logo {
        width: 80px;
        margin-bottom: 10px;
    }
    .login-box {
        padding: 20px 15px;
        width: 95%;
    }
    .login-box h1 {
        font-size: 1.25rem;
        margin-bottom: 5px;
    }
    .login-box p {
        font-size: 0.75rem;
        margin-bottom: 15px;
        letter-spacing: 0;
    }
    .form-group {
        margin-bottom: 15px;
    }
    .form-group label {
        font-size: 0.65rem;
        letter-spacing: 1px;
        margin-bottom: 5px;
    }
    .form-group input {
        padding: 12px 15px;
        font-size: 0.9rem;
        border-radius: 12px;
    }
    .login-btn {
        padding: 12px;
        font-size: 0.95rem;
        border-radius: 12px;
    }
    .login-footer {
        margin-top: 20px;
        padding-top: 15px;
        font-size: 0.65rem;
    }
    .login-footer p {
        margin-bottom: 2px;
    }
}
