/* ===================================================
   AUTH MODAL — Login / Signup / Recovery
   All selectors scoped under .auth-modal-overlay
   =================================================== */

/* Overlay */
.auth-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: authModalFadeIn 0.2s ease;
}

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

/* Container */
.auth-modal-container {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 480px;
    max-height: 92vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    animation: authModalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: max-width 0.35s ease;
}

.auth-modal-container.auth-modal-wide {
    max-width: 680px;
}

@keyframes authModalSlideIn {
    from { opacity: 0; transform: scale(0.93) translateY(-12px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* Scrollbar */
.auth-modal-container::-webkit-scrollbar { width: 5px; }
.auth-modal-container::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.auth-modal-container::-webkit-scrollbar-thumb { background: #c5c5c5; border-radius: 10px; }

/* Close button */
.auth-modal-close {
    position: absolute;
    top: 13px;
    right: 13px;
    width: 30px;
    height: 30px;
    border: none;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    z-index: 10;
    transition: background 0.2s, transform 0.2s;
    line-height: 1;
}
.auth-modal-close:hover {
    background: rgba(255, 255, 255, 0.45);
    transform: rotate(90deg);
}

/* ── Header ─────────────────────────────────── */
.auth-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 30px 24px 22px;
    text-align: center;
    border-radius: 20px 20px 0 0;
    position: relative;
    overflow: hidden;
}

.auth-modal-header::before {
    content: '\f02d';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: -10px; right: 20px;
    font-size: 80px;
    opacity: 0.1;
    transform: rotate(15deg);
    color: #fff;
    pointer-events: none;
}

.auth-modal-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.auth-modal-logo img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.6);
    object-fit: cover;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.auth-modal-header h2 {
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}

.auth-modal-header p {
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.88rem;
    position: relative;
    z-index: 1;
    margin: 0;
}

/* ── Body ────────────────────────────────────── */
.auth-modal-body {
    padding: 22px 24px 24px;
}

/* Register / Login toggle bar */
.auth-modal-register-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-bottom: 14px;
    font-size: 0.84rem;
    color: #6b7280;
}

.auth-modal-text-btn {
    background: none;
    border: none;
    color: #667eea;
    font-weight: 600;
    font-size: 0.84rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}
.auth-modal-text-btn:hover { background: #ede9fe; color: #764ba2; }

/* ── Messages ────────────────────────────────── */
.auth-modal-error,
.auth-modal-success {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.86rem;
    margin-bottom: 14px;
}

.auth-modal-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.auth-modal-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

/* Loading */
.auth-modal-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f8faff;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 0.86rem;
    color: #374151;
    border: 1px solid #e0e7ff;
}

.auth-modal-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: authSpin 0.65s linear infinite;
    flex-shrink: 0;
}

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

/* ── Forms ───────────────────────────────────── */
.auth-modal-form { display: block; }

.auth-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.auth-form-group {
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
}

.auth-form-group label {
    font-size: 0.83rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.auth-form-group label i {
    color: #667eea;
    font-size: 0.78rem;
}

.auth-form-control {
    padding: 10px 13px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #111827;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    outline: none;
    font-family: inherit;
}

.auth-form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.auth-form-control::placeholder { color: #9ca3af; }

/* Password field */
.auth-password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-password-field .auth-form-control {
    padding-right: 42px;
}

.auth-password-toggle {
    position: absolute;
    right: 12px;
    color: #9ca3af;
    cursor: pointer;
    font-size: 0.85rem;
    transition: color 0.2s;
    user-select: none;
    display: flex;
    align-items: center;
    padding: 4px;
}
.auth-password-toggle:hover { color: #374151; }

/* ── Buttons ─────────────────────────────────── */
.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px 14px;
    border: none;
    border-radius: 8px;
    font-size: 0.93rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-decoration: none;
    margin-bottom: 8px;
    line-height: 1.4;
}

.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-btn:last-child { margin-bottom: 0; }

.auth-btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}
.auth-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #5568d3, #6a3f8f);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.38);
}

.auth-btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}
.auth-btn-secondary:hover:not(:disabled) {
    background: #e5e7eb;
}

/* Forgot password link */
.auth-forgot-link {
    text-align: center;
    margin: 2px 0 10px;
}

.auth-forgot-link a {
    color: #667eea;
    text-decoration: none;
    font-size: 0.83rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.auth-forgot-link a:hover { text-decoration: underline; }

/* Signup prompt in login form */
.auth-signup-prompt {
    text-align: center;
    font-size: 0.83rem;
    color: #6b7280;
    margin-top: 2px;
    padding-top: 10px;
    border-top: 1px solid #f3f4f6;
}

.auth-inline-btn {
    background: none;
    border: none;
    color: #667eea;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.83rem;
    padding: 0;
    text-decoration: underline;
}
.auth-inline-btn:hover { color: #764ba2; }

/* Notice box (signup info) */
.auth-notice {
    background: #dbeafe;
    border: 1px solid #93c5fd;
    border-radius: 8px;
    padding: 9px 13px;
    font-size: 0.81rem;
    color: #1e40af;
    margin-bottom: 14px;
    line-height: 1.5;
}

/* Checkbox */
.auth-checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 14px;
    font-size: 0.84rem;
    color: #374151;
    line-height: 1.5;
}

.auth-checkbox-group input[type="checkbox"] {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    margin-top: 2px;
    accent-color: #667eea;
    cursor: pointer;
}

.auth-checkbox-group a {
    color: #667eea;
    text-decoration: underline;
}

/* reCAPTCHA */
.auth-recaptcha-wrap {
    margin-bottom: 14px;
    display: flex;
    justify-content: center;
    min-height: 78px;
}

/* ── Instruction Screen ──────────────────────── */
.auth-instruction-screen { display: none; }

.auth-instruction-content {
    text-align: center;
    padding: 4px 0 8px;
}

.auth-instruction-icon {
    font-size: 2.8rem;
    margin-bottom: 10px;
    line-height: 1;
}

.auth-instruction-content h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #16a34a;
    margin-bottom: 14px;
}

.auth-instruction-box {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 18px;
    border: 1px solid #e9ecef;
    text-align: left;
}

.auth-instruction-box p {
    font-size: 0.875rem;
    color: #374151;
    margin-bottom: 6px;
    line-height: 1.5;
}
.auth-instruction-box p:last-child { margin-bottom: 0; }

.auth-instruction-email {
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    color: #667eea !important;
    word-break: break-all;
}

.auth-instruction-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.auth-instruction-actions .auth-btn {
    flex: 1;
    min-width: 120px;
}

.auth-instruction-note {
    font-size: 0.77rem;
    color: #9ca3af;
    margin: 0;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 600px) {
    .auth-form-row { grid-template-columns: 1fr; }
    .auth-modal-container.auth-modal-wide { max-width: 100%; }
    .auth-modal-body { padding: 18px 16px 20px; }
    .auth-modal-header { padding: 24px 16px 18px; }
}

@media (max-height: 600px) {
    .auth-modal-container { max-height: 98vh; }
    .auth-modal-header { padding: 18px 20px 14px; }
    .auth-modal-logo img { width: 36px; height: 36px; }
    .auth-modal-header h2 { font-size: 1.2rem; }
}
