@import url('https://fonts.googleapis.com/css2?family=Rammetto+One&display=swap');

:root {
    --brown: #8B4513;
    --brown-dark: #6F370F;
    --brown-light: #a0522d;
    --accent: #ff9800;
    --accent-light: #ffb74d;
    --bg: #faf9f6;
    --success: #4CAF50;
    --success-bg: #d4edda;
    --success-border: #c3e6cb;
    --error: #721c24;
    --error-bg: #f8d7da;
    --error-border: #f5c6cb;
    --info: #0c5460;
    --info-bg: #d1ecf1;
    --info-border: #bee5eb;
    --shadow: rgba(139, 69, 19, 0.12);
    --transition: 0.25s ease;
}

/* ══════════════════════════════════════════════════════════
   GLOBAL RESET FOR AUTH PAGE - Prevents Horizontal Scroll
   ══════════════════════════════════════════════════════════ */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Scoped Reset: Only for Auth Elements */
.auth-container *,
.auth-container *::before,
.auth-container *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ══════════════════════════════════════════════════════════
   AUTH CONTAINER - Main Wrapper
   ══════════════════════════════════════════════════════════ */
.auth-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    min-height: 80vh;
    padding: 1.5rem 1rem;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ══════════════════════════════════════════════════════════
   AUTH BOX - Card Container
   ══════════════════════════════════════════════════════════ */
.auth-box {
    background: white;
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 24px var(--shadow);
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: slideUp 0.4s ease-out;
}

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

.auth-box h2 {
    font-family: "Rammetto One", sans-serif;
    color: var(--brown);
    font-size: 1.25rem;
    margin-bottom: 1.2rem;
    text-align: center;
    line-height: 1.4;
}

/* ══════════════════════════════════════════════════════════
   AUTH TOGGLE TABS - Login/Register & Email/Phone
   ══════════════════════════════════════════════════════════ */
.auth-toggle,
.auth-sub-toggle {
    display: flex;
    width: 100%;
    margin-bottom: 1rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    background: #f7f7f7;
}

.auth-toggle button,
.auth-sub-toggle button {
    flex: 1;
    padding: 0.75rem 0.5rem;
    background: transparent;
    color: var(--brown);
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.auth-toggle button:hover,
.auth-sub-toggle button:hover {
    background: rgba(139, 69, 19, 0.08);
}

.auth-toggle button.active,
.auth-sub-toggle button.active {
    background: var(--brown);
    color: #fff;
    box-shadow: 0 2px 8px rgba(139, 69, 19, 0.3);
}

.auth-toggle button:focus,
.auth-sub-toggle button:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* ══════════════════════════════════════════════════════════
   AUTH FORM - Form Styles
   ══════════════════════════════════════════════════════════ */
.auth-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-form label {
    font-size: 0.95rem;
    color: var(--brown);
    font-weight: 600;
    margin-bottom: -0.25rem;
}

.auth-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    background: #fafafa;
    color: #333;
    font-size: 1rem;
    transition: all var(--transition);
}

.auth-form input:focus {
    border-color: var(--brown);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.auth-form input:disabled {
    background: #f0f0f0;
    cursor: not-allowed;
    opacity: 0.7;
}

.auth-form input::placeholder {
    color: #999;
    font-size: 0.9rem;
}

/* ══════════════════════════════════════════════════════════
   FORM ACTIONS - Buttons
   ══════════════════════════════════════════════════════════ */
.form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.auth-form button[type="submit"] {
    width: 100%;
    background: var(--brown);
    color: white;
    border: none;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.auth-form button[type="submit"]:hover:not(:disabled) {
    background: var(--accent);
    color: var(--brown-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

.auth-form button[type="submit"]:active:not(:disabled) {
    transform: translateY(0);
}

.auth-form button[type="submit"]:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.auth-form button[type="submit"]:disabled,
.auth-form button[type="submit"].loading {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ══════════════════════════════════════════════════════════
   INPUT WITH BUTTON - OTP Field (FIXED - Single Definition)
   ══════════════════════════════════════════════════════════ */
.input-with-button {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    align-items: stretch;
}

.input-with-button input {
    flex: 1;
    min-width: 0; /* Prevents input from overflowing */
    padding-right: 0.75rem;
}

.input-with-button button {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0.65rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    background-color: var(--brown);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.input-with-button button:hover:not(:disabled) {
    background-color: var(--brown-light);
}

.input-with-button button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.input-with-button button.loading {
    opacity: 0.7;
    cursor: wait;
}

/* ══════════════════════════════════════════════════════════
   FORM ROW - Checkbox & Forgot Link
   ══════════════════════════════════════════════════════════ */
.form-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #555;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
    accent-color: var(--brown);
}

.forgot-link,
.forgot a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color var(--transition);
}

.forgot-link:hover,
.forgot a:hover {
    color: var(--brown-dark);
    text-decoration: underline;
}

/* ══════════════════════════════════════════════════════════
   MESSAGES - Success, Error, Info
   ══════════════════════════════════════════════════════════ */
.message {
    width: 100%;
    max-width: 400px;
    padding: 0.9rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

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

.message.success,
.alert {
    background: var(--success-bg);
    color: #155724;
    border: 1px solid var(--success-border);
}

.message.error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid var(--error-border);
}

.message.info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid var(--info-border);
}

/* ══════════════════════════════════════════════════════════
   OTP SECTION & RESEND TIMER
   ══════════════════════════════════════════════════════════ */
#otp-section {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(76, 175, 80, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(76, 175, 80, 0.25);
    width: 100%;
}

.resend-timer {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.75rem;
    text-align: center;
    padding: 0.5rem;
    background: rgba(139, 69, 19, 0.05);
    border-radius: 6px;
}

.resend-timer span {
    font-weight: 700;
    color: var(--success);
}

/* ══════════════════════════════════════════════════════════
   FOOTER (Scoped to Auth)
   ══════════════════════════════════════════════════════════ */
footer {
    background: var(--brown);
    color: white;
    text-align: center;
    padding: 1.2rem 1rem;
    font-size: 0.95rem;
    margin-top: auto;
    font-family: system-ui, -apple-system, sans-serif;
    width: 100%;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE DESIGN - Mobile First
   ══════════════════════════════════════════════════════════ */

/* Tablets and below */
@media (max-width: 768px) {
    .nav-links {
        display: none !important;
    }

    .menu-toggle {
        display: block !important;
    }

    .auth-container {
        padding: 1rem 0.75rem;
        min-height: 75vh;
    }

    .auth-box {
        padding: 1.25rem 1rem;
        max-width: 95%;
        border-radius: 12px;
    }

    .auth-box h2 {
        font-size: 1.15rem;
    }

    .auth-form input,
    .auth-form button[type="submit"] {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 0.8rem 0.9rem;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .auth-container {
        padding: 0.75rem 0.5rem;
    }

    .auth-box {
        padding: 1rem 0.75rem;
        max-width: 100%;
        border-radius: 10px;
        margin: 0 0.25rem;
    }

    .auth-box h2 {
        font-size: 1.05rem;
        margin-bottom: 1rem;
    }

    .auth-toggle button,
    .auth-sub-toggle button {
        padding: 0.65rem 0.25rem;
        font-size: 0.85rem;
    }

    .auth-form label {
        font-size: 0.9rem;
    }

    .auth-form input {
        padding: 0.7rem 0.75rem;
    }

    .input-with-button {
        flex-direction: column;
        gap: 0.5rem;
    }

    .input-with-button button {
        width: 100%;
        padding: 0.7rem;
    }

    .form-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .message {
        font-size: 0.9rem;
        padding: 0.75rem;
        max-width: 100%;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .auth-box {
        padding: 0.9rem 0.6rem;
    }

    .auth-toggle button,
    .auth-sub-toggle button {
        font-size: 0.8rem;
        padding: 0.6rem 0.2rem;
    }
}

/* ══════════════════════════════════════════════════════════
   ACCESSIBILITY & FOCUS STATES
   ══════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .auth-box {
        border: 2px solid var(--brown);
    }

    .auth-form input {
        border-width: 2px;
    }
}

/* ══════════════════════════════════════════════════════════
   UTILITY CLASSES
   ══════════════════════════════════════════════════════════ */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}