/* Authorization Modal & Components */

/* Profile Button (Fixed UI) */
#btn-user-profile {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: var(--bg-surface-solid);
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-glass);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-glass);
    position: relative;
    /* For badges if needed */
}

#btn-user-profile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-main);
    background: var(--bg-item-hover);
    border-color: var(--primary);
}

#btn-user-profile.logged-in {
    border-color: var(--primary);
    background: var(--bg-surface-solid);
}

.avatar-circle {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    /* Fallback purple */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Auth Modal Overlay */
.auth-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: var(--z-auth);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Scroll on short/touch viewports */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;   /* iOS momentum scroll */
    padding: 16px;
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    touch-action: pan-y;                 /* allow vertical pan on touch */
}

[data-theme="dark"] .auth-modal-overlay {
    background: rgba(0, 0, 0, 0.8);
}

.auth-modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* Auth Modal Card */
.auth-modal {
    background: var(--bg-surface-solid);
    width: 100%;
    max-width: 420px;
    border-radius: 24px;
    padding: 28px 28px 24px;   /* compact: smaller padding all round */
    box-shadow: 0 32px 80px -16px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-glass);
    transform: translateY(16px) scale(0.96);
    transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    /* Scroll if taller than viewport — scrollbar hidden */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;   /* iOS momentum scroll */
    scrollbar-width: none;
    -ms-overflow-style: none;
    align-self: flex-start;
    margin: auto;
    touch-action: pan-y;
}

.auth-modal::-webkit-scrollbar { display: none; }

[data-theme="dark"] .auth-modal {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.auth-modal-overlay.show .auth-modal {
    transform: translateY(0) scale(1);
}

.auth-close {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    z-index: 10;
}

.auth-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    transform: rotate(90deg) scale(1.1);
    border-color: rgba(239, 68, 68, 0.2);
}

/* Header */
.auth-header {
    text-align: center;
    margin-bottom: 16px;
}

.auth-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;          /* was 2.2rem */
    font-weight: 800;
    margin: 0 0 4px 0;
    letter-spacing: -0.03em;
    color: #0f172a;
}

[data-theme="dark"] .auth-header h2 {
    color: #ffffff;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

/* Toggle Tabs */
.auth-tabs {
    display: flex;
    background: var(--bg-item);
    padding: 3px;
    border-radius: 11px;
    margin-bottom: 16px;
}

.auth-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 10px;           /* was 10px */
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.25s ease;
    min-height: 40px;            /* touch target */
    touch-action: manipulation;
}

.auth-tab:hover:not(.active) {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.auth-tab.active {
    background: #2e7dd1;
    color: #ffffff;
    box-shadow: 0 6px 16px -4px rgba(46, 125, 209, 0.35);
}

/* Form */
.auth-form-group {
    margin-bottom: 11px;
}

.auth-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.auth-input {
    width: 100%;
    padding: 11px 14px;          /* was 16px 20px */
    border-radius: 12px;         /* was 16px */
    border: 1.5px solid var(--border-strong);
    background: var(--bg-item);
    color: var(--text-main);
    font-size: 16px;             /* ≥16px prevents iOS auto-zoom */
    font-family: inherit;
    transition: all 0.2s;
    touch-action: manipulation;
    -webkit-appearance: none;    /* remove iOS inner shadow */
    appearance: none;
    box-sizing: border-box;
}

[data-theme="dark"] .auth-input {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.auth-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    background: rgba(0, 0, 0, 0.3);
}

/* Placeholder Color */
/* Placeholder Color */
.auth-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* Autofill Fix for Global Auth Modal */
.auth-input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px var(--bg-item) inset !important;
    -webkit-text-fill-color: var(--text-main) !important;
    caret-color: var(--text-main);
}

[data-theme="dark"] .auth-input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px #1e293b inset !important;
    /* Match modal dark bg */
    -webkit-text-fill-color: #ffffff !important;
    caret-color: #ffffff;
}

/* Submit Button */
.auth-submit {
    width: 100%;
    padding: 13px;               /* was 18px */
    border-radius: 13px;
    border: none;
    background: #2e7dd1;
    color: white;
    font-weight: 700;
    font-size: 1rem;             /* was 1.1rem */
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.23, 1, 0.32, 1);
    margin-top: 14px;            /* was 24px */
    box-shadow: 0 8px 24px -8px rgba(46, 125, 209, 0.45);
    position: relative;
    overflow: hidden;
    min-height: 46px;            /* solid touch target */
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-submit:hover {
    transform: translateY(-2px);
    background: #2563eb;
    box-shadow: 0 12px 32px -8px rgba(46, 125, 209, 0.55);
}

.auth-submit:active {
    transform: translateY(1px);
    box-shadow: none;
}

.auth-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

/* Feedback */
.auth-feedback {
    margin-top: 10px;
    font-size: 0.82rem;
    text-align: center;
    color: var(--text-muted);
}

.auth-feedback.error {
    color: var(--danger);
}

/* Decorative Blobs - DISABLED */
.auth-blob {
    display: none;
}


/* Teacher Checkbox Styles */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 30px;
    cursor: pointer;
    font-size: 0.95rem;
    user-select: none;
    color: var(--text-main);
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    height: 20px;
    width: 20px;
    background-color: var(--bg-item);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    transition: all 0.2s;
}

.checkbox-container:hover input~.checkmark {
    background-color: var(--bg-item-hover);
    border-color: var(--primary);
}

.checkbox-container input:checked~.checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked~.checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.label-text {
    font-weight: 500;
}

/* ─── Auth modal responsive → responsive-scale.css §9 ─── */

/* Role Selection Cards */
.role-selection-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.role-card {
    background: var(--bg-item);
    border: 1.5px solid transparent;
    border-radius: 14px;
    padding: 14px 10px;          /* was 20px 16px */
    text-align: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;                    /* was 12px */
    position: relative;
    overflow: hidden;
    min-height: 44px;            /* touch target */
    touch-action: manipulation;
}

.role-card:hover {
    background: var(--bg-item-hover);
    transform: translateY(-3px);
}

.role-card.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    box-shadow: 0 6px 18px -4px rgba(99, 102, 241, 0.22);
}

.role-card i {
    font-size: 1.4rem;           /* was 1.8rem */
    color: var(--text-muted);
    transition: all 0.25s ease;
}

.role-card.active i {
    color: var(--primary);
}

.role-card span {
    font-size: 0.82rem;          /* was 0.95rem */
    font-weight: 700;
    color: var(--text-main);
}

.role-card .check-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transform: scale(0);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.role-card.active .check-badge {
    transform: scale(1);
}

/* Remember Me Checkbox on Student Panel */
.student-remember-me {
    margin-top: 15px;
    justify-content: center;
}

/* ============================================================
   EMAIL CONFIRMATION PANEL
   Appears inside .auth-modal after a successful sign-up
   ============================================================ */

.email-confirm-panel {
    animation: confirmPanelIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    text-align: center;
}

@keyframes confirmPanelIn {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Envelope Illustration ── */
.email-confirm-icon-wrap {
    margin: 0 auto 20px;
    position: relative;
    width: 110px;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.email-confirm-envelope {
    position: relative;
    width: 88px;
    height: 66px;
    animation: envelopeBob 3s ease-in-out infinite;
}

@keyframes envelopeBob {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50%       { transform: translateY(-8px) rotate(2deg); }
}

.envelope-body {
    width: 88px;
    height: 66px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 32px -8px rgba(99,102,241,0.55);
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 44px solid transparent;
    border-right: 44px solid transparent;
    border-top: 36px solid rgba(139,92,246,0.9);
}

.envelope-letter {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    background: white;
    border-radius: 4px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: letterPeek 3s ease-in-out infinite;
}

@keyframes letterPeek {
    0%, 100% { bottom: 8px; }
    50%       { bottom: 14px; }
}

.letter-line {
    height: 3px;
    background: linear-gradient(90deg, #e2e8f0, #cbd5e1);
    border-radius: 2px;
    width: 100%;
}
.letter-line.short { width: 65%; }

/* Sparkles */
.envelope-sparkle {
    position: absolute;
    color: #fbbf24;
    animation: sparkleAnim 2s ease-in-out infinite;
    font-size: 0.5rem;
    opacity: 0;
}

.envelope-sparkle.s1 { top: 2px;  right: -4px;  animation-delay: 0s;    font-size: 0.65rem; }
.envelope-sparkle.s2 { top: -6px; left: 4px;   animation-delay: 0.6s;  font-size: 0.5rem;  }
.envelope-sparkle.s3 { bottom: 0; right: 2px;  animation-delay: 1.1s;  font-size: 0.4rem; color: #a78bfa; }

@keyframes sparkleAnim {
    0%   { opacity: 0; transform: scale(0.5) translateY(0); }
    30%  { opacity: 1; transform: scale(1.2) translateY(-4px); }
    70%  { opacity: 0.8; transform: scale(1) translateY(-8px); }
    100% { opacity: 0; transform: scale(0.3) translateY(-14px); }
}

/* ── Role Badge ── */
.email-confirm-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(99,102,241,0.12);
    border: 1px solid rgba(99,102,241,0.25);
    color: #818cf8;
    border-radius: 100px;
    padding: 6px 16px;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 16px;
    letter-spacing: 0.03em;
}

.email-confirm-role-badge.student-role {
    background: rgba(16,185,129,0.1);
    border-color: rgba(16,185,129,0.25);
    color: #34d399;
}

/* ── Heading & Subtitle ── */
.email-confirm-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.55rem;
    font-weight: 800;
    margin: 0 0 10px;
    color: var(--text-main, #0f172a);
    letter-spacing: -0.02em;
}

[data-theme="dark"] .email-confirm-title { color: #ffffff; }

.email-confirm-subtitle {
    color: var(--text-muted, #64748b);
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0 0 20px;
}

.email-confirm-address {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.95rem;
    color: #6366f1;
    background: rgba(99,102,241,0.08);
    padding: 4px 14px;
    border-radius: 8px;
    word-break: break-all;
}

/* ── Steps ── */
.email-confirm-steps {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 18px;
}

.confirm-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--bg-item, rgba(241,245,249,0.7));
    border: 1px solid var(--border-glass, rgba(0,0,0,0.06));
    border-radius: 14px;
    padding: 12px 16px;
    animation: stepSlideIn 0.4s ease both;
}

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

.confirm-step:nth-child(1) { animation-delay: 0.1s; }
.confirm-step:nth-child(2) { animation-delay: 0.22s; }
.confirm-step:nth-child(3) { animation-delay: 0.34s; }

[data-theme="dark"] .confirm-step {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.08);
}

.confirm-step-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(99,102,241,0.3);
}

.confirm-step-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.confirm-step-text strong {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main, #0f172a);
    line-height: 1.3;
}

[data-theme="dark"] .confirm-step-text strong { color: #e2e8f0; }

.confirm-step-text span {
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    line-height: 1.4;
}

/* ── Tip Box ── */
.email-confirm-tip {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(251,191,36,0.08);
    border: 1px solid rgba(251,191,36,0.2);
    border-radius: 12px;
    padding: 11px 14px;
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    text-align: left;
    margin-bottom: 20px;
    line-height: 1.5;
}

.email-confirm-tip i {
    color: #fbbf24;
    margin-top: 1px;
    flex-shrink: 0;
}

.email-confirm-tip strong {
    color: var(--text-main, #374151);
}

[data-theme="dark"] .email-confirm-tip strong { color: #e2e8f0; }

/* ── Resend ── */
.email-confirm-resend {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
}

.auth-resend-btn {
    background: transparent;
    border: 1.5px solid var(--border-glass, rgba(0,0,0,0.12));
    color: var(--text-muted, #64748b);
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    touch-action: manipulation;
}

.auth-resend-btn:hover:not(:disabled) {
    border-color: var(--primary, #6366f1);
    color: var(--primary, #6366f1);
    background: rgba(99,102,241,0.06);
}

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

.auth-resend-btn i {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.auth-resend-btn:not(:disabled) i {
    animation: none;
}

.auth-resend-btn.sending i {
    animation: spin 1s linear infinite;
}

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

.auth-resend-timer {
    font-size: 0.75rem;
    color: var(--text-muted, #94a3b8);
    font-weight: 500;
}

.auth-resend-feedback {
    font-size: 0.78rem;
    font-weight: 600;
    min-height: 1.2em;
}

.auth-resend-feedback.success {
    color: #10b981;
}

.auth-resend-feedback.error {
    color: var(--danger, #ef4444);
}

.auth-resend-feedback.maxed {
    color: var(--text-muted, #94a3b8);
}

/* ── Actions ── */
.email-confirm-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}