:root {
    --primary: #1E6FDB;
    --primary-dark: #1659B3;
    --secondary: #5C9CE6;
    /* Lighter blue for gradients */
    --success: #38ef7d;
    --danger: #f5576c;
    --warning: #ffa726;

    --gray-900: #1a202c;
    --gray-800: #2d3748;
    --gray-700: #4a5568;
    --gray-600: #718096;
    --gray-500: #a0aec0;
    --gray-400: #cbd5e0;
    --gray-300: #e2e8f0;
    --gray-200: #edf2f7;
    --gray-100: #f7fafc;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container {
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    max-width: 480px;
    width: 100%;
    padding: 40px;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    /* Solid color for better readability or simpler brand alignment */
    margin-bottom: 8px;
}

.auth-logo p {
    color: var(--gray-600);
    font-size: 15px;
}

.toggle-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
    background: var(--gray-100);
    border-radius: 12px;
    padding: 4px;
}

.toggle-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-weight: 500;
    font-size: 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.form-container {
    display: none;
}

.form-container.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    color: var(--gray-700);
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 16px;
    pointer-events: none;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    border: 2px solid var(--gray-300);
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.2s ease;
    background: white;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-wrapper input.error {
    border-color: var(--danger);
}

.input-wrapper input.success {
    border-color: var(--success);
}

.password-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--gray-600);
}

.forgot-password {
    text-align: right;
    margin-bottom: 20px;
}

.forgot-password a {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.forgot-password a:hover {
    color: var(--primary-dark);
}

.btn-submit {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.btn-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 0;
    transition: color 0.2s;
}

.btn-link:hover:not(:disabled) {
    color: var(--primary-dark);
    text-decoration: underline;
}

.legal-links {
    margin-top: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.6;
}

.legal-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.legal-links a:hover {
    text-decoration: underline;
}

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== Email Verification Styles ========== */
.verification-step {
    display: none;
    animation: fadeIn 0.3s ease;
}

.verification-step.active {
    display: block;
}

.verification-step h3 {
    color: var(--gray-900);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
}

.step-description {
    color: var(--gray-600);
    font-size: 15px;
    margin-bottom: 25px;
    text-align: center;
}

.code-sent-info {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

.code-sent-info i {
    font-size: 32px;
    margin-bottom: 10px;
    display: block;
}

.code-sent-info p {
    margin: 0;
    font-size: 15px;
}

.code-sent-info strong {
    font-weight: 600;
}

.code-input-container {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 30px 0;
}

.code-digit {
    width: 60px;
    height: 70px;
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    border: 2px solid var(--gray-300);
    border-radius: 12px;
    transition: all 0.2s ease;
    background: white;
    color: var(--gray-900);
}

.code-digit:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: scale(1.05);
}

.code-digit.error {
    border-color: var(--danger);
    animation: shake 0.3s;
}

.verified-badge {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 25px;
    font-size: 15px;
}

.verified-badge i {
    margin-right: 8px;
    font-size: 18px;
}

.resend-section {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

.resend-section p {
    color: var(--gray-600);
    font-size: 14px;
    margin-bottom: 8px;
}

#resend-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#countdown {
    color: var(--gray-500);
    font-size: 13px;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Responsive */
/* ========== RESPONSIVE ADAPTATION ========== */

/* XS: 0px – 359px (Smallest Phones) */
@media (max-width: 359px) {
    body {
        padding: 10px;
        align-items: flex-start;
        /* Better for small screens with keyboard open */
    }

    .auth-container {
        padding: 24px 16px;
        border-radius: 16px;
        margin-top: 10px;
        box-shadow: var(--shadow-md);
        /* Lighter shadow for mobile */
    }

    .auth-logo {
        margin-bottom: 20px;
    }

    .auth-logo h1 {
        font-size: 24px;
        /* Smaller title */
    }

    .auth-logo p {
        font-size: 13px;
    }

    .toggle-buttons {
        gap: 8px;
        margin-bottom: 20px;
    }

    .toggle-btn {
        padding: 10px;
        font-size: 13px;
    }

    .input-group {
        margin-bottom: 16px;
    }

    .input-group label {
        font-size: 13px;
    }

    .input-wrapper input {
        padding: 10px 14px 10px 40px;
        font-size: 14px;
        height: 44px;
    }

    .input-icon {
        left: 14px;
        font-size: 14px;
    }

    .btn-submit {
        padding: 12px;
        font-size: 14px;
    }

    .forgot-password {
        text-align: center;
        /* Center text as requested */
        margin-bottom: 16px;
    }

    .forgot-password a {
        font-size: 13px;
    }

    /* Verification Code Mobile */
    .code-input-container {
        gap: 6px;
    }

    .code-digit {
        width: 38px;
        height: 48px;
        font-size: 20px;
        border-radius: 8px;
    }
}

/* SM: 360px – 479px (Standard Mobile) */
@media (min-width: 360px) and (max-width: 479px) {
    body {
        padding: 16px;
    }

    .auth-container {
        padding: 32px 20px;
        border-radius: 18px;
    }

    .auth-logo h1 {
        font-size: 28px;
    }

    .input-wrapper input {
        font-size: 15px;
        height: 48px;
    }

    .forgot-password {
        text-align: center;
    }

    /* Verification Code Mobile */
    .code-input-container {
        gap: 10px;
    }

    .code-digit {
        width: 48px;
        height: 58px;
        font-size: 24px;
        border-radius: 10px;
    }
}

/* LM: 480px – 639px (Large Mobile / Phablets) */
@media (min-width: 480px) and (max-width: 639px) {
    .auth-container {
        padding: 40px 30px;
        max-width: 420px;
        /* Limit width */
        margin: 0 auto;
    }

    .auth-logo h1 {
        font-size: 30px;
    }

    .forgot-password {
        text-align: center;
    }
}

/* Common Mobile Optimizations (Tablets & Mobile) */
@media (max-width: 639px) {
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .modal-header {
        padding: 20px;
        flex-shrink: 0;
    }

    .modal-body {
        padding: 20px;
        overflow-y: auto;
        flex-grow: 1;
    }

    /* Keep legal links readable */
    .legal-links {
        font-size: 12px;
        padding: 0 10px;
    }

    /* Better touch targets */
    button,
    input,
    a {
        touch-action: manipulation;
    }
}

/* ========== Verification Modal ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 25px 30px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    color: var(--gray-900);
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-600);
}

.modal-body {
    padding: 30px;
}

.modal-description {
    text-align: center;
    color: var(--gray-600);
    font-size: 15px;
    margin-bottom: 25px;
}

#modal-resend-btn:disabled,
#modal-resend-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#modal-countdown {
    color: var(--gray-500);
    font-size: 13px;
}