/* ========== Split Screen Layout ========== */
.auth-wrapper {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* RTL Fix: Reverse the split screen */
body[dir="rtl"] .auth-wrapper {
    flex-direction: row-reverse;
}

/* Left Graphic Panel */
.auth-brand-panel {
    width: 45%;
    background: radial-gradient(circle at 30% 20%, #1c1f24 0%, #0a0b0d 70%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px;
    position: relative;
    overflow: hidden;
    border-inline-end: 1px solid var(--border-color);
}

.auth-brand-content {
    position: relative;
    z-index: 2;
}

.auth-brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 48px;
}

.auth-brand-logo img {
    width: 40px;
    height: 40px;
}

.auth-brand-logo h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
}

.auth-brand-logo h1 span {
    color: var(--accent);
}

.auth-brand-text h2 {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 16px;
    background: linear-gradient(90deg, #fff, #8b8f96);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-brand-text p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 400px;
    margin-bottom: 32px;
}

.auth-brand-features {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.auth-feature-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--accent-dim);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* CSS Candlestick Background */
.chart-bg {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    display: flex;
    align-items: flex-end;
    gap: 15px;
    padding: 0 60px 60px 60px;
    opacity: 0.4;
    z-index: 1;
}

.candle {
    flex: 1;
    background: var(--accent);
    border-radius: 4px 4px 0 0;
    position: relative;
    animation: grow 2s infinite alternate ease-in-out;
}

.candle::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 120%;
    background: var(--accent);
    opacity: 0.5;
    z-index: -1;
}

.candle.red {
    background: var(--error);
}
.candle.red::before {
    background: var(--error);
}

@keyframes grow {
    from { height: 20%; }
    to { height: 90%; }
}

/* Right Form Panel */
.auth-form-panel {
    width: 55%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
}

.auth-controls {
    position: absolute;
    top: 32px;
    inset-inline-end: 32px;
    display: flex;
    gap: 12px;
    z-index: 10;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.auth-card {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

/* Tabs */
.auth-tabs {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 32px;
    position: relative;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    transition: color 0.3s ease;
    cursor: pointer;
    position: relative;
    z-index: 2;
    background: transparent;
    border: none;
}

.auth-tab.active { color: var(--accent-text); }

.tab-slider {
    position: absolute;
    top: 4px;
    inset-inline-start: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: var(--accent);
    border-radius: var(--radius-xs);
    transition: inset-inline-start 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-tabs[data-active="signup"] .tab-slider {
    inset-inline-start: 50%;
}

/* Forms */
.auth-form {
    display: none;
    flex-direction: column;
    gap: 20px;
}

.auth-form.active {
    display: flex;
    animation: fadeIn 0.4s ease;
}

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

/* Floating Inputs */
.form-group { position: relative; }

.form-input {
    width: 100%;
    padding: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    text-align: start;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-label {
    position: absolute;
    inset-inline-start: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
    transition: all 0.2s ease;
    background: var(--bg-input);
    padding: 0 4px;
}

.form-input:focus + .form-label,
.form-input:not(:placeholder-shown) + .form-label {
    top: 0;
    font-size: 0.75rem;
    color: var(--accent);
}

/* Referral Field Animation */
.referral-group {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.3s ease;
    margin-bottom: 0;
}

.referral-group.show {
    max-height: 100px;
    opacity: 1;
    margin-bottom: 20px;
}

/* reCAPTCHA */
.recaptcha-container { margin-bottom: 24px; }

.recaptcha-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
}

.recaptcha-box:hover { border-color: var(--border-hover); }

.recaptcha-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--text-muted);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.recaptcha-box.checked .recaptcha-checkbox {
    background: var(--success);
    border-color: var(--success);
}

.recaptcha-checkbox svg { opacity: 0; transition: opacity 0.2s; }
.recaptcha-box.checked .recaptcha-checkbox svg { opacity: 1; }

.recaptcha-label { flex: 1; font-size: 0.85rem; color: var(--text-secondary); }
.recaptcha-logo { font-size: 1.5rem; opacity: 0.3; }

/* Submit Button */
.auth-submit {
    width: 100%;
    padding: 16px;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-bottom: 20px;
}

.auth-submit:hover { background: var(--accent-hover); }
.auth-submit:active { transform: scale(0.98); }

/* Links */
.auth-links {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.auth-links a {
    color: var(--text-secondary);
    transition: color 0.2s;
}

.auth-links a:hover { color: var(--accent); }

.terms-text {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.terms-text a { color: var(--text-secondary); text-decoration: underline; }

/* ========== Modal & Country Dropdown (RTL Bulletproof) ========== */
.modal-overlay {
    position: fixed; 
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
}

.modal-overlay.show { 
    opacity: 1; 
    visibility: visible; 
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 440px;
    box-sizing: border-box;
    transform: scale(0.95);
    transition: transform 0.3s ease;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.modal-overlay.show .modal { 
    transform: scale(1); 
}

.modal-header { margin-bottom: 24px; }
.modal-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; }
.modal-subtitle { color: var(--text-secondary); font-size: 0.9rem; }

.phone-input-wrapper { 
    display: flex; 
    gap: 8px; 
    margin-bottom: 20px; 
    align-items: stretch; /* Ensure equal height */
}

.country-select-wrapper {
    position: relative;
    flex-shrink: 0;
    width: 120px; /* Fixed width so it doesn't squish the phone input */
}

.country-select-btn {
    display: flex; 
    align-items: center; 
    gap: 8px;
    padding: 14px 16px; 
    background: var(--bg-input);
    border: 1px solid var(--border-color); 
    border-radius: var(--radius-sm);
    color: var(--text-primary); 
    white-space: nowrap; 
    cursor: pointer;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    direction: ltr; /* FORCE LTR so +57 doesn't become 57+ in Farsi */
}

.country-flag { font-size: 1.2rem; }
.country-code { font-size: 0.9rem; font-weight: 600; }

.country-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-start: 0;
    width: 100%;
    min-width: 280px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.country-dropdown.show { display: flex; }

.country-search {
    padding: 12px 16px;
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    font-size: 0.9rem;
    width: 100%;
    box-sizing: border-box;
}

.country-list {
    max-height: 250px;
    overflow-y: auto;
}

.country-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.country-item:hover { background: var(--bg-hover); }
.country-item .flag { font-size: 1.3rem; }
.country-item .name { flex: 1; font-size: 0.9rem; color: var(--text-secondary); }
.country-item .dial-code { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }

/* Responsive Modal */
@media (max-width: 480px) {
    .modal {
        padding: 24px 20px;
        max-width: 95%;
        border-radius: 16px;
    }
    .phone-input-wrapper {
        flex-direction: column;
        gap: 10px;
    }
    .country-select-wrapper {
        width: 100%;
    }
    .country-dropdown {
        min-width: 100%;
    }
}

/* Hide brand panel on mobile */
@media (max-width: 900px) {
    .auth-brand-panel { display: none; }
    .auth-form-panel { width: 100%; padding: 20px; }
}
