/**
 * ============================================================================
 * WARAP AUTH MODAL v2.0 - GAFAM STYLE CSS
 * ============================================================================
 * Modern, premium authentication experience
 * Inspired by Google, Apple, Microsoft login flows
 * ============================================================================
 */

/* ============================================================================
   CSS VARIABLES
   ============================================================================ */
:root {
    /* Auth Colors */
    --auth-bg: #ffffff;
    --auth-overlay: rgba(0, 0, 0, 0.6);
    --auth-surface: #f8fafc;
    --auth-border: #e2e8f0;
    --auth-border-focus: #F59E0B;
    --auth-text: #1e293b;
    --auth-text-secondary: #64748b;
    --auth-text-muted: #94a3b8;
    --auth-primary: #F59E0B;
    --auth-primary-hover: #D97706;
    --auth-primary-light: rgba(245, 158, 11, 0.1);
    --auth-error: #EF4444;
    --auth-error-light: rgba(239, 68, 68, 0.1);
    --auth-success: #10B981;
    --auth-success-light: rgba(16, 185, 129, 0.1);
    --auth-whatsapp: #25D366;

    /* Auth Shadows */
    --auth-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --auth-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --auth-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --auth-shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

    /* Auth Transitions */
    --auth-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --auth-transition-fast: all 0.15s ease;

    /* Auth Sizing */
    --auth-modal-width: 420px;
    --auth-radius: 16px;
    --auth-radius-sm: 8px;
    --auth-radius-full: 50px;
}

/* ============================================================================
   OVERLAY
   ============================================================================ */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: var(--auth-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: var(--auth-transition);
}

.auth-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================================================
   MODAL
   ============================================================================ */
.auth-modal {
    background: var(--auth-bg);
    width: 100%;
    max-width: var(--auth-modal-width);
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-shadow-xl);
    position: relative;
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    transition: var(--auth-transition);
    max-height: 90vh;
    overflow-y: auto;
    padding: 40px;
}

.auth-overlay.active .auth-modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ============================================================================
   CLOSE BUTTON
   ============================================================================ */
.auth-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--auth-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--auth-transition-fast);
    z-index: 10;
}

.auth-close:hover {
    background: var(--auth-surface);
    color: var(--auth-text);
}

/* ============================================================================
   PROGRESS BAR
   ============================================================================ */
.auth-progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--auth-surface);
    border-radius: var(--auth-radius) var(--auth-radius) 0 0;
    overflow: hidden;
}

.auth-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--auth-primary), var(--auth-primary-hover));
    transition: width 0.4s ease;
}

/* ============================================================================
   LOGO
   ============================================================================ */
.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo img {
    height: 48px;
    width: auto;
}

.auth-logo-text {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--auth-primary), var(--auth-primary-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================================================
   STEPS
   ============================================================================ */
.auth-step {
    display: none;
    animation: authFadeIn 0.3s ease forwards;
}

.auth-step.active {
    display: block;
}

@keyframes authFadeIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================================================
   BACK BUTTON
   ============================================================================ */
.auth-back {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--auth-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--auth-transition-fast);
    font-size: 18px;
}

.auth-back:hover {
    background: var(--auth-surface);
    color: var(--auth-text);
}

/* ============================================================================
   TITLES
   ============================================================================ */
.auth-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--auth-text);
    margin: 0 0 8px 0;
    text-align: center;
    line-height: 1.3;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--auth-text-secondary);
    text-align: center;
    margin: 0 0 32px 0;
    line-height: 1.5;
}

/* ============================================================================
   USER BADGE
   ============================================================================ */
.auth-user-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--auth-surface);
    border-radius: var(--auth-radius-full);
    margin: 0 auto 24px;
    width: fit-content;
    font-size: 14px;
    color: var(--auth-text);
}

.auth-user-badge i {
    font-size: 20px;
    color: var(--auth-primary);
}

/* ============================================================================
   FORM & INPUTS
   ============================================================================ */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-input-group {
    position: relative;
}

.auth-input {
    width: 100%;
    padding: 18px 50px 18px 20px;
    font-size: 16px;
    border: 2px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    background: var(--auth-bg);
    color: var(--auth-text);
    transition: var(--auth-transition-fast);
    outline: none;
    font-family: inherit;
}

.auth-input:focus {
    border-color: var(--auth-border-focus);
    box-shadow: 0 0 0 4px var(--auth-primary-light);
}

.auth-input.error {
    border-color: var(--auth-error);
    box-shadow: 0 0 0 4px var(--auth-error-light);
}

.auth-input.success {
    border-color: var(--auth-success);
}

/* Floating Label */
.auth-label {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--auth-text-muted);
    pointer-events: none;
    transition: var(--auth-transition-fast);
    background: var(--auth-bg);
    padding: 0 4px;
}

.auth-input:focus~.auth-label,
.auth-input:not(:placeholder-shown)~.auth-label {
    top: 0;
    font-size: 12px;
    color: var(--auth-primary);
}

.auth-label-select {
    top: -10px;
    font-size: 12px;
    color: var(--auth-primary);
}

/* Select Styling */
.auth-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 50px;
}

/* Input Icon */
.auth-input-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--auth-text-muted);
    pointer-events: none;
}

/* Toggle Password */
.auth-toggle-password {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--auth-text-muted);
    cursor: pointer;
    padding: 4px;
    transition: var(--auth-transition-fast);
}

.auth-toggle-password:hover {
    color: var(--auth-text);
}

/* ============================================================================
   PASSWORD STRENGTH
   ============================================================================ */
.auth-password-strength {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--auth-text-muted);
}

.strength-bar {
    flex: 1;
    height: 4px;
    background: var(--auth-border);
    border-radius: 2px;
    overflow: hidden;
}

.strength-bar span {
    display: block;
    height: 100%;
    width: 0%;
    background: var(--auth-error);
    transition: var(--auth-transition);
}

.strength-bar.weak span {
    width: 33%;
    background: var(--auth-error);
}

.strength-bar.medium span {
    width: 66%;
    background: var(--auth-primary);
}

.strength-bar.strong span {
    width: 100%;
    background: var(--auth-success);
}

/* ============================================================================
   ERROR MESSAGE
   ============================================================================ */
.auth-error {
    font-size: 13px;
    color: var(--auth-error);
    display: none;
    padding: 10px 14px;
    background: var(--auth-error-light);
    border-radius: var(--auth-radius-sm);
    margin-top: -10px;
}

.auth-error.show {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-error::before {
    content: "⚠️";
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--auth-radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--auth-transition);
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.auth-btn-primary {
    background: linear-gradient(135deg, var(--auth-primary), var(--auth-primary-hover));
    color: white;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
}

.auth-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

.auth-btn-primary:active {
    transform: translateY(0);
}

.auth-btn-success {
    background: linear-gradient(135deg, var(--auth-success), #059669);
}

.auth-btn-text {
    background: transparent;
    color: var(--auth-text-secondary);
    box-shadow: none;
    font-weight: 500;
}

.auth-btn-text:hover {
    color: var(--auth-text);
    background: var(--auth-surface);
}

.auth-btn-full {
    width: 100%;
}

/* Loading State */
.auth-btn.loading {
    pointer-events: none;
}

.auth-btn-loader {
    display: none;
}

.auth-btn.loading .auth-btn-text,
.auth-btn.loading .auth-btn-icon {
    opacity: 0;
}

.auth-btn.loading .auth-btn-loader {
    display: block;
    position: absolute;
}

/* ============================================================================
   SOCIAL BUTTONS
   ============================================================================ */
.auth-social-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 500;
    border-radius: var(--auth-radius-sm);
    border: 2px solid var(--auth-border);
    background: var(--auth-bg);
    color: var(--auth-text);
    cursor: pointer;
    transition: var(--auth-transition);
    width: 100%;
}

.auth-btn-social:hover {
    border-color: var(--auth-text-muted);
    background: var(--auth-surface);
}

.auth-btn-social i {
    font-size: 20px;
}

.auth-btn-whatsapp {
    border-color: var(--auth-whatsapp);
    color: var(--auth-whatsapp);
}

.auth-btn-whatsapp:hover {
    background: var(--auth-whatsapp);
    color: white;
}

/* ============================================================================
   DIVIDER
   ============================================================================ */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
    color: var(--auth-text-muted);
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--auth-border);
}

/* ============================================================================
   FOOTER & LINKS
   ============================================================================ */
.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--auth-text-secondary);
}

.auth-footer a {
    color: var(--auth-primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--auth-transition-fast);
}

.auth-footer a:hover {
    text-decoration: underline;
}

.auth-forgot-link {
    display: block;
    text-align: right;
    font-size: 14px;
    color: var(--auth-primary);
    text-decoration: none;
    margin-top: -10px;
}

.auth-forgot-link:hover {
    text-decoration: underline;
}

/* ============================================================================
   HINT
   ============================================================================ */
.auth-hint {
    font-size: 13px;
    color: var(--auth-text-muted);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-hint i {
    color: var(--auth-primary);
}

/* ============================================================================
   FORGOT PASSWORD CONTENT
   ============================================================================ */
.auth-forgot-content {
    text-align: center;
}

.auth-forgot-content p {
    font-size: 14px;
    color: var(--auth-text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

/* ============================================================================
   SUCCESS ANIMATION
   ============================================================================ */
.auth-success-animation {
    text-align: center;
    padding: 40px 20px;
}

.auth-success-checkmark {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
}

.checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    stroke-width: 2;
    stroke: var(--auth-success);
    stroke-miterlimit: 10;
    animation: fill 0.4s ease-in-out 0.4s forwards, scale 0.3s ease-in-out 0.9s both;
}

.checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    stroke-miterlimit: 10;
    stroke: var(--auth-success);
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes scale {

    0%,
    100% {
        transform: none;
    }

    50% {
        transform: scale3d(1.1, 1.1, 1);
    }
}

@keyframes fill {
    100% {
        box-shadow: inset 0 0 0 100px rgba(16, 185, 129, 0.1);
    }
}

.auth-success-title {
    color: var(--auth-success) !important;
    animation: authFadeIn 0.5s ease 1s both;
}

/* ============================================================================
   RESPONSIVE (The "App-like" Experience)
   ============================================================================ */
@media (max-width: 480px) {

    /* Use dvh for true viewport height on mobile browsers with dynamic bars */
    .auth-overlay {
        padding: 0;
        align-items: flex-end;
        /* Align to bottom */
        height: 100dvh;
        /* Use dynamic viewport height */
    }

    .auth-modal {
        max-width: 100%;
        width: 100%;
        border-radius: 24px 24px 0 0;
        /* Rounded top corners only */
        padding: 32px 24px calc(20px + env(safe-area-inset-bottom));
        /* Add safe area padding */
        max-height: 85dvh;
        /* 85% of screen height max */
        transform: translateY(100%);
        /* Start from below */
        margin: 0;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
    }

    .auth-overlay.active .auth-modal {
        transform: translateY(0);
    }

    /* Animation specifically for bottom sheet */
    @keyframes authBottomSheetUp {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    /* Larger touch targets */
    .auth-input {
        padding: 16px 45px 16px 16px;
        font-size: 16px;
        /* Prevent iOS Zoom */
        height: 52px;
    }

    .auth-btn {
        padding: 16px 20px;
        height: 52px;
        font-size: 16px;
    }

    .auth-label {
        left: 16px;
    }

    /* Close button easier to reach */
    .auth-close {
        top: 20px;
        right: 20px;
        width: 36px;
        height: 36px;
        background: var(--auth-surface);
        /* Visible background */
    }

    /* Improve back button */
    .auth-back {
        top: 20px;
        left: 20px;
        width: 36px;
        height: 36px;
        background: var(--auth-surface);
    }

    /* Adjust Title */
    .auth-title {
        font-size: 22px;
        margin-top: 20px;
    }

    .auth-logo {
        margin-bottom: 20px;
    }

    .auth-logo img {
        height: 40px;
    }
}

/* ============================================================================
   DARK MODE SUPPORT
   ============================================================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --auth-bg: #1e293b;
        --auth-surface: #334155;
        --auth-border: #475569;
        --auth-text: #f1f5f9;
        --auth-text-secondary: #94a3b8;
        --auth-text-muted: #64748b;
        --auth-overlay: rgba(0, 0, 0, 0.85);
        /* Darker overlay */
    }
}

/* Force dark mode for WARAP via class */
body.dark-mode {
    --auth-bg: #1e293b;
    --auth-surface: #334155;
    --auth-border: #475569;
    --auth-text: #f1f5f9;
    --auth-text-secondary: #94a3b8;
    --auth-text-muted: #64748b;
    --auth-overlay: rgba(0, 0, 0, 0.85);
}

body.dark-mode .auth-modal {
    background: var(--auth-bg);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

body.dark-mode .auth-input {
    background: var(--auth-bg);
    color: var(--auth-text);
    border-color: var(--auth-border);
}

body.dark-mode .auth-input:focus {
    border-color: var(--auth-border-focus);
}

body.dark-mode .auth-label {
    background: var(--auth-bg);
    color: var(--auth-text-muted);
}