/* Reset */
* {
    box-sizing: border-box;
}

/* Base */
body {
    margin: 0;
    min-height: 100vh;
    font-size: 16px;
    line-height: 1.5;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #eef7f9 0%, #f8fafc 100%);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Header */
.page-header {
    width: 100%;
    padding: 22px 28px;
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.header-inner {
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logo {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--blue);
    text-decoration: none;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.main-nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 7px 10px;
    border-radius: 999px;
}

.main-nav .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 999px;
    border: none;
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    font-weight: 700;
    box-shadow: 0 12px 24px rgba(14, 154, 167, 0.16);
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease, color 0.25s ease;
}

.main-nav .button-outline {
    background: rgba(255,255,255,0.9);
    color: var(--primary);
    border: 1px solid rgba(14, 154, 167, 0.2);
    box-shadow: none;
}

.main-nav .button:hover,
.main-nav .button:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(14, 154, 167, 0.2);
}

/* Page */
.auth-page {
    min-height: calc(100vh - 84px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 22px 36px;
}

/* Card */
.auth-card {
    width: min(560px, 100%);
    background: rgba(255,255,255,0.98);
    border-radius: 28px;
    padding: 28px 30px 32px;
    box-shadow: 0 30px 80px rgba(14, 154, 167, 0.14);
    border: 1px solid rgba(14, 154, 167, 0.14);
}

.auth-card h1 {
    margin: 0 0 8px;
    font-size: 2.25rem;
    line-height: 1.08;
    letter-spacing: -0.03em;
}

.auth-subtitle {
    margin: 12px 0 30px;
    color: #475569;
    font-size: 1.05rem;
    line-height: 1.7;
}

/* Labels */
label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: #334155;
}

/* Form layout */
.auth-card form {
    display: grid;
    gap: 18px;
}

.form-row {
    display: grid;
    gap: 18px;
}

.form-row .input-group {
    width: 100%;
}

.form-group {
    display: grid;
    gap: 12px;
}

.role-group {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-radius: 20px;
    background: rgba(14,154,167,0.06);
    border: 1px solid rgba(14,154,167,0.14);
}

.role-group label {
    margin-bottom: 0;
    color: #0f172a;
    font-weight: 700;
}

.role-group input[type="radio"] {
    accent-color: var(--primary);
    margin-right: 10px;
}

.radio-list {
    display: grid;
    justify-content: start;
    gap: 10px;
    padding: 0 4px;
}

.radio-list > div {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 220px));
    gap: 10px;
    justify-content: start;
    min-width: 0;
}

.radio-list > div label {
    width: auto;
}

.radio-list label {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(255,255,255,0.95);
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    min-height: 44px;
    white-space: nowrap;
}

.radio-list input[type="radio"] {
    margin: 0;
}

.radio-list input[type="radio"]:checked + span,
.radio-list input[type="radio"]:checked + strong,
.radio-list input[type="radio"]:checked + label {
    color: #0f172a;
}

.student-fields,
.teacher-fields {
    display: grid;
    gap: 14px;
    padding: 18px 16px;
    border-radius: 22px;
    background: rgba(238,247,249,0.85);
    border: 1px solid rgba(14,154,167,0.12);
}

.student-fields::before,
.teacher-fields::before {
    content: attr(data-section);
    display: block;
    margin-bottom: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
}

.terms-group {
    display: grid;
    gap: 10px;
    padding: 16px 18px;
    border-radius: 20px;
    background: rgba(248,250,252,0.95);
    border: 1px solid rgba(148,163,184,0.18);
}

.terms-group .checkbox-label {
    display: inline-flex;
    align-items: flex-start;
    gap: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
    color: #475569;
}

.terms-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 3px;
    accent-color: var(--primary);
}

.floating-label-group,
.input-group {
    display: grid;
    gap: 8px;
    width: 100%;
    margin-bottom: 0;
}

.floating-label-group label,
.input-group label {
    position: static;
    transform: none;
    opacity: 1;
    font-size: 0.95rem;
    color: #334155;
    pointer-events: auto;
}

.input-group:hover label,
.input-group input:focus + label,
.input-group input:valid + label,
.input-group:focus-within label,
.input-group.focused label,
.input-group.has-value label {
    top: auto;
    left: auto;
    transform: none;
    color: #0f172a;
}

.floating-label-group input,
.input-group input {
    position: relative;
    z-index: 1;
    margin-bottom: 0;
}

.floating-label-group input::placeholder,
.input-group input::placeholder {
    color: #94a3b8;
    opacity: 1;
    transition: color 0.25s ease;
}

.input-group:hover input::placeholder,
.input-group:focus-within input::placeholder {
    color: transparent;
}

/* Inputs */
input,
select {
    width: 100%;
    padding: 17px 18px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(255,255,255,0.96);
    font-size: 1rem;
    color: var(--text);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.2s ease;
}

input {
    margin-bottom: 0;
}

input:focus,
select:focus {
    outline: none;
    border-color: rgba(79, 70, 229, 0.55);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

/* Buttons */
button {
    width: 100%;
    padding: 15px 18px;
    border: none;
    border-radius: 16px;
    background: var(--blue);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(14, 154, 167, 0.12);
}

form button.button,
form button[type="submit"] {
    width: 100%;
    padding: 15px 20px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    box-shadow: 0 12px 24px rgba(14, 154, 167, 0.16);
}

form button.button:hover,
form button[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(14, 154, 167, 0.16);
}

.toggle-password {
    width: auto;
    padding: 0.5rem;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    box-shadow: none;
}

.toggle-password:hover {
    background: rgba(14, 154, 167, 0.08);
    color: var(--primary);
    transform: none;
    box-shadow: none;
}

/* OAuth */
.oauth-button {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.36);
    background: white;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    margin-bottom: 20px;
}

/* Google CTA specific */
.google-cta {
    padding: 12px 18px;
    gap: 14px;
    border-radius: 14px;
    font-size: 1rem;
}

.oauth-text {
    display: inline-block;
    font-weight: 700;
    color: #0f172a;
}

.social-note {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #64748b;
    text-align: center;
}

.google-cta:focus-visible {
    outline: 3px solid rgba(14,154,167,0.18);
    outline-offset: 3px;
}

.oauth-button img {
    width: 20px;
    height: 20px;
}

.oauth-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(31, 42, 71, 0.12);
    border-color: rgba(79, 70, 229, 0.32);
}

/* Divider */
.oauth-divider {
    margin: 18px 0;
    display: flex;
    align-items: center;
    gap: 14px;
    color: rgba(100, 116, 139, 0.9);
    font-size: 0.95rem;
}

.oauth-divider::before,
.oauth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(148, 163, 184, 0.28);
}

/* Footer */
.auth-footer {
    margin-top: 24px;
    font-size: 0.96rem;
    color: var(--muted);
    text-align: center;
}

.auth-footer a {
    color: var(--blue);
    text-decoration: none;
    font-weight: 600;
}

.separator {
    margin: 0 8px;
    color: rgba(100, 116, 139, 0.9);
}

/* Policy Update Section */
.policy-update-info {
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.6;
}

.policy-update-info p {
    margin: 0;
}

.policy-update-info strong {
    color: var(--blue);
    font-weight: 600;
}

.policy-links {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.policy-links .button {
    flex: 1;
    min-width: 200px;
    background: transparent;
    border: 2px solid var(--blue);
    color: var(--blue);
    font-weight: 600;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.policy-links .button:hover {
    background: var(--blue);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(79, 70, 229, 0.15);
}

/* Responsive */
@media (max-width: 640px) {
    .page-header {
        padding: 14px 16px;
    }

    .header-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .main-nav {
        gap: 8px;
        justify-content: flex-start;
    }

    .main-nav .button,
    .main-nav .button-outline {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .auth-page {
        padding: 18px 10px 30px;
    }

    .auth-card {
        padding: 24px 20px;
        border-radius: 22px;
    }

    .auth-card h1 {
        font-size: 1.75rem;
    }

    .auth-subtitle {
        font-size: 0.98rem;
    }

    .auth-card form {
        gap: 14px;
    }

    .policy-links {
        flex-direction: column;
    }

    .policy-links .button {
        min-width: 100%;
    }
}

@media (min-width: 720px) {
    /* Keep form single-column even on medium screens */
    .auth-card {
        width: min(520px, 100%);
    }

    .form-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .header-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .auth-card {
        padding: 28px 22px;
    }

    .policy-links {
        flex-direction: column;
    }

    .policy-links .button {
        min-width: 100%;
    }
}

@media (max-width: 540px) {
    .main-nav {
        width:100%;
        display:flex;
        justify-content:flex-start;
        gap:8px;
        flex-wrap:wrap;
    }

    .auth-card {
        width: 100%;
        margin: 0 auto;
        padding: 22px 18px;
        border-radius: 20px;
    }

    .auth-page {
        padding: 12px 8px 24px;
    }

    .button,
    .oauth-button,
    form button.button,
    form button[type="submit"] {
        width: 100%;
    }

    .oauth-divider::before, .oauth-divider::after { display:none; }
    input,
    select {
        padding: 12px 12px;
        border-radius: 14px;
    }

    .radio-list {
        grid-template-columns: 1fr;
    }

    .radio-list > div {
        grid-template-columns: 1fr;
    }

    .radio-list label,
    .terms-group,
    .student-fields,
    .teacher-fields {
        padding: 12px;
    }

    .auth-card h1 {
        font-size: 1.45rem;
    }

    .auth-footer {
        font-size: 0.9rem;
    }
}

/* Terms */
.terms-group .checkbox-label {
    display: inline-flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.4;
    font-size: 0.95rem;
    color: var(--muted);
    cursor: pointer;
}
.terms-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 3px 0 0 0;
    align-self: flex-start;
}
.terms-text { display: inline-block; }
.policy-link { color: var(--primary); text-decoration: underline; margin: 0 4px; }
.policy-link:hover { color: var(--primary-dark); }

/* Password toggle */
.password-input-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 0;
}

.password-input-wrapper input {
    width: 100%;
    padding-right: 56px;
    position: relative;
    z-index: 1;
}


.toggle-password {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    background: rgba(14,154,167,0.08);
    border: none;
    padding: 0.65rem;
    border-radius: 999px;
    cursor: pointer;
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.16s ease, color 0.16s ease; /* no transform transition */
    width: 38px;
    height: 38px;
    z-index: 2;
}

/* Ensure hover/active keep the same vertical transform so the button doesn't shift */
.toggle-password:hover,
.toggle-password:active,
.toggle-password:focus-visible {
    top: 50%;
    transform: translateY(-50%);
    background: rgba(14,154,167,0.16);
    color: #075985;
}

.toggle-password:focus-visible {
    outline: 2px solid rgba(79, 70, 229, 0.5);
    outline-offset: 2px;
}

.password-strength-wrapper {
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.password-strength-bar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    overflow: hidden;
}

.strength-meter {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #ef4444, #f87171);
    transition: width 0.25s ease, background 0.25s ease;
}

.strength-meter.very-weak {
    width: 20%;
    background: linear-gradient(90deg, #dc2626, #f87171);
}

.strength-meter.weak {
    width: 40%;
    background: linear-gradient(90deg, #f97316, #fb923c);
}

.strength-meter.medium {
    width: 70%;
    background: linear-gradient(90deg, #eab308, #facc15);
}

.strength-meter.strong {
    width: 100%;
    background: linear-gradient(90deg, #22c55e, #10b981);
}

.password-strength-info {
    display: grid;
    gap: 4px;
    color: #475569;
    font-size: 0.92rem;
}

.password-strength-info .strength-label strong {
    color: #0f172a;
}

.toggle-password svg {
    width: 20px;
    height: 20px;
}

/* Stack icons and fade between them to avoid layout shifts */
.toggle-password {
    position: absolute; /* already absolute; ensure stacking context */
}
.toggle-password .eye-icon,
.toggle-password .eye-off-icon {
    position: absolute;
    inset: 0; /* fill the button */
    width: 20px;
    height: 20px;
    margin: auto;
    transition: opacity 160ms ease;
    opacity: 1;
    pointer-events: none;
    display: block;
}
.toggle-password .eye-off-icon { opacity: 0; }
.password-input-wrapper.password-visible .toggle-password .eye-icon { opacity: 0; }
.password-input-wrapper.password-visible .toggle-password .eye-off-icon { opacity: 1; }

.errorlist,
.messages {
    margin: 0;
    padding: 0;
    list-style: none;
}

.errorlist {
    border: 1px solid rgba(239, 68, 68, 0.18);
    background: rgba(254, 226, 226, 0.5);
    color: #991b1b;
    padding: 12px 14px;
    border-radius: 16px;
    font-size: 0.95rem;
}

.errorlist li {
    margin-bottom: 6px;
}

.messages li {
    margin-bottom: 10px;
}

.messages li:last-child,
.errorlist li:last-child {
    margin-bottom: 0;
}

.message {
    font-weight: 600;
}

/* Input Validation */
.input-error input,
.input-error textarea {
    border-color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.04);
}

.input-error input:focus,
.input-error textarea:focus {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12) !important;
}

.input-valid input,
.input-valid textarea {
    border-color: #10b981 !important;
    background-color: rgba(16, 185, 129, 0.04);
}

.input-valid input:focus,
.input-valid textarea:focus {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12) !important;
}

.validation-error {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: #ef4444;
    font-weight: 500;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================= */
/* DARK MODE STYLES - login.css */
/* ============================================= */

html.dark body,
html[data-theme="dark"] body {
    background: linear-gradient(135deg, rgba(11, 18, 32, 0.98), rgba(8, 13, 24, 0.98)) !important;
    color: var(--text) !important;
}

html.dark .page-header,
html[data-theme="dark"] .page-header {
    background: rgba(10, 15, 28, 0.92) !important;
    border-bottom-color: rgba(148, 163, 184, 0.14) !important;
}

html.dark .logo,
html[data-theme="dark"] .logo {
    color: var(--primary) !important;
}

html.dark .main-nav a,
html[data-theme="dark"] .main-nav a {
    color: var(--text) !important;
}

html.dark .main-nav a:hover,
html[data-theme="dark"] .main-nav a:hover {
    color: var(--primary) !important;
}

html.dark .form-card,
html.dark .auth-card,
html.dark .card,
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .card {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(10, 15, 28, 0.98)) !important;
    border-color: rgba(148, 163, 184, 0.14) !important;
    box-shadow: 0 16px 40px rgba(2, 6, 23, 0.3) !important;
}

html.dark input,
html.dark textarea,
html.dark select,
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    background: rgba(15, 23, 42, 0.95) !important;
    border-color: rgba(148, 163, 184, 0.22) !important;
    color: var(--text) !important;
}

html.dark input::placeholder,
html.dark textarea::placeholder,
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: rgba(148, 163, 184, 0.6) !important;
}

html.dark input:focus,
html.dark textarea:focus,
html.dark select:focus,
html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] select:focus {
    background: rgba(15, 23, 42, 0.98) !important;
    border-color: rgba(14, 154, 167, 0.24) !important;
    box-shadow: 0 0 0 3px rgba(14, 154, 167, 0.1) !important;
}

html.dark button,
html.dark .button,
html.dark .btn,
html[data-theme="dark"] button,
html[data-theme="dark"] .button,
html[data-theme="dark"] .btn {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(11, 18, 30, 0.98)) !important;
    border-color: rgba(148, 163, 184, 0.18) !important;
    color: var(--text) !important;
}

html.dark button:hover,
html.dark .button:hover,
html.dark .btn:hover,
html[data-theme="dark"] button:hover,
html[data-theme="dark"] .button:hover,
html[data-theme="dark"] .btn:hover {
    background: linear-gradient(180deg, rgba(20, 29, 48, 0.98), rgba(14, 22, 40, 0.98)) !important;
    border-color: rgba(14, 154, 167, 0.24) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 20px rgba(14, 154, 167, 0.12) !important;
}

html.dark .errorlist,
html[data-theme="dark"] .errorlist {
    background: rgba(239, 68, 68, 0.08) !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
    color: #fca5a5 !important;
}

html.dark .input-error input,
html.dark .input-error textarea,
html[data-theme="dark"] .input-error input,
html[data-theme="dark"] .input-error textarea {
    border-color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.08) !important;
}

html.dark .input-valid input,
html.dark .input-valid textarea,
html[data-theme="dark"] .input-valid input,
html[data-theme="dark"] .input-valid textarea {
    border-color: #10b981 !important;
    background-color: rgba(16, 185, 129, 0.08) !important;
}

html.dark .validation-error,
html[data-theme="dark"] .validation-error {
    color: #fca5a5 !important;
}

