/**
 * AUTH POPUP - Clean Rewrite with Original Design
 * Simple code structure, beautiful design
 */

/* ===== VARIABLES ===== */
:root {
    --auth-yellow: #FFD700;
    --auth-orange: #FFA500;
    --auth-gradient: linear-gradient(135deg, #FFA500 0%, #FFD700 100%);
    --auth-white: #ffffff;
    --auth-dark: #1a1a1a;
    --auth-gray: #666666;
    --auth-light-gray: #999999;
    --auth-border: #d1d5db;
    --auth-success: #4CAF50;
    --auth-error: #DC2626;
}

/* ===== RESET ===== */
.auth-popup-overlay *,
.auth-popup-overlay *::before,
.auth-popup-overlay *::after {
    box-sizing: border-box;
}

/* ===== OVERLAY ===== */
.auth-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    padding: 20px;
}

.auth-popup-overlay.show {
    display: flex;
}

/* ===== POPUP CONTENT ===== */
.auth-popup-content {
    background: var(--auth-white);
    width: 100%;
    max-width: 480px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    display: none;
    animation: slideUp 0.3s ease;
}

.auth-popup-content.show {
    display: block;
}

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

/* ===== CLOSE BUTTON ===== */
.auth-popup-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.auth-popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ===== HEADER ===== */
.auth-popup-header {
    background: var(--auth-gradient);
    padding: 28px 32px 24px;
    text-align: center;
    border-radius: 16px 16px 0 0;
    position: relative;
    z-index: 1;
}

.auth-popup-logo {
    display: none; /* Hidden on desktop, show on mobile */
    width: auto;
    height: 50px;
    margin: 0 auto 12px;
    object-fit: contain;
}

.auth-popup-subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 8px;
    font-weight: 500;
}

.auth-popup-title {
    font-size: 26px;
    font-weight: 700;
    color: white;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ===== BODY ===== */
.auth-popup-body {
    padding: 32px 32px 24px;
    position: relative;
    z-index: 2;
}

.auth-description {
    text-align: center;
    color: var(--auth-gray);
    font-size: 14px;
    /*  margin-bottom: 20px;*/
    line-height: 1.6;
}

/* ===== FORM ===== */
.auth-popup-form {
    padding: 40px 32px 32px;
    position: relative;
    z-index: 2;
}

.auth-form-group {
    position: relative;
    margin-bottom: 20px;
}

/* ===== INPUTS ===== */
.auth-input {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--auth-border);
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.2s;
    background: var(--auth-white);
}

.auth-input:focus {
    outline: none;
    border-color: var(--auth-yellow);
    box-shadow: 0 0 0 1px var(--auth-yellow);
}

/* ===== FLOATING LABELS ===== */
.auth-label {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    padding: 0 6px;
    color: var(--auth-gray);
    font-size: 15px;
    pointer-events: none;
    transition: all 0.2s;
    z-index: 1;
}

.auth-input:focus ~ .auth-label,
.auth-input:not(:placeholder-shown) ~ .auth-label {
    top: 0;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: 500;
    color: var(--auth-dark);
    padding: 0 8px;
}

/* ===== PASSWORD TOGGLE ===== */
.auth-toggle-password {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

/* ===== OPTIONS ROW ===== */
.auth-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* ===== CHECKBOX ===== */
.auth-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    color: var(--auth-gray);
    cursor: pointer;
    line-height: 1.5;
}

.auth-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: var(--auth-orange);
    flex-shrink: 0;
}

.auth-checkbox a {
    color: var(--auth-orange);
    text-decoration: none;
    font-weight: 500;
}

.auth-checkbox a:hover {
    text-decoration: underline;
}

/* ===== LINKS ===== */
.auth-link {
    color: var(--auth-orange);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.auth-link:hover {
    text-decoration: underline;
}

.auth-link-btn {
    background: none;
    border: none;
    color: var(--auth-orange);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 0px 0 20px ;
    display: block;
    width: 100%;
    text-align: center;
}

.auth-link-btn:hover {
    text-decoration: underline;
}

/* ===== SUBMIT BUTTON ===== */
.auth-submit-btn {
    width: 100%;
    padding: 16px;
    background-image: linear-gradient(135deg, rgb(255, 165, 0) 0%, rgb(255, 215, 0) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s;
}

.auth-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 165, 0, 0.3);
}

.auth-submit-btn:active {
    transform: translateY(0);
}

/* ===== FOOTER ===== */
.auth-popup-footer {
    text-align: center;
    padding: 20px 32px 32px;
    font-size: 14px;
    color: var(--auth-gray);
}

.auth-popup-footer a {
    color: var(--auth-orange);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.auth-popup-footer a:hover {
    text-decoration: underline;
}

/* ===== MESSAGES ===== */
.auth-messages {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
}

.auth-messages.show {
    display: block;
}

.auth-messages.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.auth-messages.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ===== OTP INPUTS ===== */
.auth-otp-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 24px 0;
}

.auth-otp-input {
    width: 50px;
    height: 50px;
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    border: 2px solid var(--auth-border);
    border-radius: 10px;
    transition: all 0.3s;
}

.auth-otp-input:focus {
    outline: none;
    border-color: var(--auth-orange);
    box-shadow: 0 0 0 3px rgba(255, 165, 0, 0.1);
}

/* ===== TIMER ===== */
.auth-timer {
    text-align: center;
    margin: 20px 0;
    font-size: 14px;
    color: var(--auth-gray);
}

/* ===== SUCCESS SCREEN ===== */
.auth-success {
    text-align: center;
    padding: 60px 32px;
}

.auth-success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: var(--auth-success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 48px;
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.auth-success h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--auth-dark);
    margin-bottom: 12px;
}

.auth-success p {
    font-size: 14px;
    color: var(--auth-gray);
    line-height: 1.6;
}

/* ===== PROGRESS INDICATORS ===== */
.auth-progress-indicators {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 16px 0 0 0;
    margin-top: 8px;
}

.auth-progress-step {
    width: 8px;
    height: 8px;
    background: #e0e0e0;
    border-radius: 50%;
    transition: all 0.3s ease;
    position: relative;
}

.auth-progress-step.active {
    background: #FFA500;
    width: 24px;
    border-radius: 4px;
}

.auth-progress-step.completed {
    background: #FFA500;
}

/* ===== STEPS ===== */
.auth-popup-step {
    display: none;
}

.auth-popup-step.active {
    display: block;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 640px) {
    .auth-progress-indicators {
        padding: 12px 0 0 0;
        margin-top: 6px;
        gap: 6px;
    }

    .auth-progress-step {
        width: 6px;
        height: 6px;
    }

    .auth-progress-step.active {
        width: 20px;
        border-radius: 3px;
    }

    .auth-popup-overlay {
        padding: 0;
        align-items: stretch;  /* FULL height */
        justify-content: stretch;  /* FULL width */
        background: white;  /* NỀN TRẮNG THAY VÌ MỜ ĐEN */
    }

    .auth-popup-content {
        max-width: none;
        width: 100%;
        height: 100vh;  /* FULL chiều cao màn hình */
        border-radius: 0;
        display: none !important;  /* ẨN tất cả popup mặc định */
        animation: none;
        background: white;  /* NỀN TRẮNG THỐNG NHẤT cho toàn bộ popup */
    }

    .auth-popup-content.show {
        display: flex !important;  /* CHỈ hiện popup có class show */
        flex-direction: column;
        justify-content: flex-start;  /* ✅ ĐỔI từ center sang flex-start để header có thể bị đẩy lên */
        padding: 0;  /* ✅ BỎ padding để cho phép header bị đẩy lên */
        overflow-y: auto;  /* ✅ CHO PHÉP scroll TOÀN BỘ popup để đẩy header lên */
        -webkit-overflow-scrolling: touch;  /* Smooth scroll iOS */
    }

    .auth-popup-header {
        background: transparent;  /* KHÔNG có background riêng - dùng chung nền popup */
        border-bottom: none;  /* XÓA viền ngăn cách */
        padding: 105px 20px 16px;  /* Tăng padding-top để có chỗ cho logo 80px */
        border-radius: 0;
        flex-shrink: 0;  /* Không cho header bị co lại */
        position: relative;
        margin-top: 65px;  /* ✅ THÊM margin-top để giữ khoảng cách ban đầu như padding: 65px 0 */
    }

    .auth-popup-logo {
        display: block;
        position: absolute;
        top: 15px;  /* Giảm khoảng cách để logo không quá cao */
        left: 50%;
        transform: translateX(-50%);
        height: 80px;  /* Height for circle logo */
        width: 80px;  /* Width for circle logo */
        border-radius: 50%;  /* Make it circular */
        object-fit: cover;  /* Ensure logo fits nicely in circle */
    }

    .auth-popup-subtitle {
        color: var(--auth-light-gray);
        font-size: 11px;  /* ✅ Giảm font size */
        margin-bottom: 6px;  /* ✅ Giảm khoảng cách */
    }

    .auth-popup-title {
        color: var(--auth-dark);
        font-size: 20px;  /* ✅ Giảm font size */
        text-transform: none;
        font-weight: 700;
        margin-bottom: 0;  /* ✅ Không margin dưới */
    }

    .auth-popup-close {
        background: transparent;
        border: 2px solid #e0e0e0;
        color: #333;
        width: 40px;
        height: 40px;
        position: absolute;
        top: 20px;
        right: 20px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        cursor: pointer;
        z-index: 10;
    }

    .auth-popup-form {
        padding: 25px 20px 15px 20px;  /* Tăng padding-top để label có chỗ float */
        overflow-y: visible;  /* ✅ BỎ scroll riêng của form */
        max-height: none;  /* ✅ BỎ giới hạn chiều cao - để form tự giãn */
        flex-shrink: 0;  /* ✅ ĐỔI từ 1 sang 0 - không cho co lại */
        background: transparent;  /* KHÔNG có background riêng */
        position: relative;
        z-index: 2;
        margin-bottom: 0;  /* ✅ BỎ margin-bottom vì footer đã có padding-bottom */
    }

    .auth-popup-body {
        padding: 25px 20px 15px 20px;  /* Tăng padding-top để label có chỗ float */
        overflow-y: visible;  /* ✅ BỎ scroll riêng của body */
        max-height: none;  /* ✅ BỎ giới hạn chiều cao */
        flex-shrink: 0;  /* ✅ ĐỔI từ 1 sang 0 - không cho co lại */
        background: transparent;  /* KHÔNG có background riêng */
        position: relative;
        z-index: 2;
        margin-bottom: 0;  /* ✅ BỎ margin-bottom vì footer đã có padding-bottom */
    }

    .auth-form-group {
        margin-bottom: 16px;  /* ✅ Giảm khoảng cách giữa các field */
    }

    .auth-input {
        min-height: 48px;
        font-size: 16px; /* Prevent iOS zoom */
        padding: 12px 14px;
    }

    .auth-popup-footer {
        padding: 15px 20px 120px;  /* ✅ TĂNG padding-bottom lên 120px (từ 65px) để tránh Safari URL bar che mất */
        border-top: none;  /* XÓA viền ngăn cách */
        flex-shrink: 0;  /* Không cho footer bị co lại */
        background: transparent;  /* KHÔNG có background riêng */
    }

    .auth-submit-btn {
        padding: 14px;  /* ✅ Giảm padding nút submit */
        font-size: 15px;  /* ✅ Giảm font size */
    }

    .auth-checkbox {
        margin: 16px 0;  /* ✅ Giảm margin */
        font-size: 13px;  /* ✅ Giảm font size */
    }

    .auth-otp-input {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }
}
