/* ============================================================
   WeCatchAI - Auth Modal Styles (login-modal.js + signup-modal.js)
   Self-contained: no dependency on styles.css
   ============================================================ */

/* ── Base reset for modal elements ─────────────────────────── */
.auth-modal,
.auth-modal * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Overlay ────────────────────────────────────────────────── */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    padding-top: max(1rem, env(safe-area-inset-top, 0px));
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ── Backdrop (click to close) ──────────────────────────────── */
.auth-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    cursor: pointer;
}

/* ── Modal card ─────────────────────────────────────────────── */
.auth-modal-content {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 420px;
    max-height: 95vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    animation: authModalSlide 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes authModalSlide {
    from {
        opacity: 0;
        transform: translateY(-40px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Header ─────────────────────────────────────────────────── */
.auth-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem 0;
    background: #ffffff;
    border-radius: 16px 16px 0 0;
    border-bottom: 1px solid #e2e8f0;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.auth-logo-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.auth-logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #00d4ff, #8b5cf6);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
}

.auth-close-btn {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 0.75rem;
    cursor: pointer;
    color: #64748b;
    border-radius: 10px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-close-btn:hover {
    background: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
    transform: scale(1.05);
}

/* ── Body ───────────────────────────────────────────────────── */
.auth-modal-body {
    padding: 1rem 2rem 1.5rem;
    background: #ffffff;
    border-radius: 0 0 16px 16px;
}

/* ── Intro block ────────────────────────────────────────────── */
.auth-header {
    text-align: center;
    margin-bottom: 1rem;
}

.auth-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.75rem 0;
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.auth-subtitle {
    font-size: 1rem;
    color: #64748b;
    margin: 0;
    line-height: 1.5;
    font-weight: 400;
}

.auth-security-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    padding: 8px 16px;
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 6px;
    font-size: 0.875rem;
    color: #10b981;
    font-weight: 500;
}

.auth-security-badge span {
    color: #10b981;
}

.auth-security-badge svg {
    flex-shrink: 0;
}

/* ── Form container ─────────────────────────────────────────── */
.auth-form-container {
    margin-bottom: 1rem;
}

/* ── Google button ──────────────────────────────────────────── */
.auth-google-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.875rem;
    padding: 1rem 1.25rem;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    background: #ffffff;
    color: #374151;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-height: 50px;
}

.auth-google-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.auth-google-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ── Or divider ─────────────────────────────────────────────── */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    position: relative;
}

.auth-divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.3), transparent);
}

.auth-divider-text {
    padding: 0 1.5rem;
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 500;
    background: #ffffff;
    position: relative;
}

/* ── Form ───────────────────────────────────────────────────── */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-field {
    display: flex;
    flex-direction: column;
}

.auth-field-row {
    display: flex;
    gap: 1rem;
}

.auth-field-row .auth-field {
    flex: 1;
}

.auth-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.375rem;
    display: block;
}

.auth-input {
    width: 100%;
    padding: 1rem 1.125rem;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #ffffff;
    color: #1f2937;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
    min-height: 50px;
}

.auth-input:focus {
    outline: none;
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow:
        0 0 0 3px rgba(59, 130, 246, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.1);
}

.auth-input::placeholder {
    color: #6b7280;
}

.auth-password-hint {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.25rem;
}

/* ── Field error ────────────────────────────────────────────── */
.auth-field-error {
    display: none;
    color: #ef4444;
    font-size: 13px;
    margin-top: 6px;
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
}

/* ── Login options row (show password / remember me / forgot) ─ */
.login-options-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    gap: 8px;
    flex-wrap: wrap;
}

.login-options-left {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-shrink: 1;
    min-width: 0;
}

.login-option-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.login-option-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #3b82f6;
    cursor: pointer;
    flex-shrink: 0;
}

.login-option-item label {
    color: #1f2937;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.login-option-separator {
    color: #d1d5db;
    font-size: 13px;
}

.login-forgot-link {
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: auto;
}

/* ── Checkbox field (terms) ─────────────────────────────────── */
.auth-checkbox-field {
    margin: 0.5rem 0;
}

/* ── Submit button ──────────────────────────────────────────── */
.auth-submit-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    margin-top: 1rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 4px 12px rgba(59, 130, 246, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    letter-spacing: 0.025em;
    min-height: 52px;
}

.auth-submit-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    box-shadow:
        0 8px 20px rgba(59, 130, 246, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.auth-submit-btn:disabled {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ── Terms notice (small text below Google / below form) ────── */
.auth-terms-notice {
    text-align: center;
    font-size: 11px;
    color: #6b7280;
    margin-top: 8px;
    line-height: 1.4;
}

.auth-terms-notice a {
    color: #3b82f6;
    text-decoration: underline;
}

/* ── Footer (sign in / sign up switch) ──────────────────────── */
.auth-footer {
    text-align: center;
    padding-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
    margin-top: 0.5rem;
}

.auth-footer-text {
    font-size: 0.875rem;
    color: #64748b;
    margin: 0;
    line-height: 1.5;
}

.auth-link {
    background: none;
    border: none;
    color: #3b82f6;
    font-size: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    padding: 0;
    transition: color 0.2s ease;
}

.auth-link:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* ── Dark theme override: always show modals with white bg ───── */
.auth-modal,
.auth-modal *,
.auth-modal-content,
.auth-modal-content *,
.auth-modal-header,
.auth-modal-header *,
.auth-modal-body,
.auth-modal-body * {
    background-color: unset;
    color: unset;
}

.auth-modal-content,
.auth-modal-header,
.auth-modal-body {
    background: #ffffff !important;
}

.auth-title { color: #1e293b !important; }
.auth-subtitle,
.auth-password-hint,
.auth-footer-text,
.auth-divider-text { color: #64748b !important; }

.auth-modal label,
.auth-modal .auth-form label { color: #1f2937 !important; }

.auth-input,
.auth-modal input[type="text"],
.auth-modal input[type="email"],
.auth-modal input[type="password"] {
    color: #1f2937 !important;
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
}

.auth-input::placeholder,
.auth-modal input::placeholder { color: #6b7280 !important; }

.auth-modal .auth-field-error,
.auth-modal #loginFormError,
.auth-modal #signupEmailError,
.auth-modal #confirmPasswordError {
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.1) !important;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
}

.auth-security-badge,
.auth-security-badge span { color: #10b981 !important; }

.auth-modal .auth-link,
.auth-modal a { color: #3b82f6 !important; }

/* ── Mobile (≤ 768px) ───────────────────────────────────────── */
@media (max-width: 768px) {
    .auth-modal {
        padding: 0.25rem !important;
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
        align-items: flex-start !important;
        overflow-y: auto !important;
    }

    .auth-modal-content {
        max-width: calc(100% - 0.5rem) !important;
        width: calc(100% - 0.5rem) !important;
        max-height: none !important;
        overflow-y: visible !important;
        border-radius: 16px !important;
    }

    .auth-modal-header {
        padding: 0.75rem 1rem 0.5rem !important;
    }

    .auth-modal-body {
        padding: 1rem 1rem 1.5rem !important;
    }

    .auth-title {
        font-size: 1.5rem !important;
    }

    .auth-subtitle {
        font-size: 0.95rem !important;
    }

    .auth-security-badge {
        font-size: 0.8rem !important;
        padding: 8px 12px !important;
        white-space: normal !important;
        word-break: break-word !important;
        line-height: 1.3 !important;
    }

    .auth-google-btn {
        font-size: 0.95rem !important;
        padding: 0.875rem 1rem !important;
        border: 2px solid #e5e7eb !important;
    }

    .auth-divider {
        margin: 1rem 0 !important;
    }

    .auth-field-row {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .auth-input {
        padding: 0.875rem 1rem !important;
        border: 2px solid #e5e7eb !important;
    }

    .auth-submit-btn {
        margin-top: 0.5rem !important;
    }

    .auth-footer {
        padding-top: 1rem !important;
        margin-top: 1rem !important;
    }
}

/* ── Small mobile (≤ 500px) - login options row ─────────────── */
@media (max-width: 500px) {
    .login-options-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }

    .login-options-left {
        width: 100% !important;
        justify-content: flex-start !important;
    }

    .login-forgot-link {
        align-self: flex-end !important;
        margin-left: 0 !important;
    }
}

@media (max-width: 400px) {
    .login-option-item label {
        font-size: 12px !important;
    }

    .login-options-left {
        gap: 6px !important;
    }

    .login-option-separator {
        display: none !important;
    }
}
