/* Modern Login Form - Clean & Autofill-Proof */

/* Container */
.modern-login-container {
    min-height: calc(100vh - 160px); /* اطرح ارتفاع navbar و footer */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: var(--bg-primary);
}

.modern-login-card {
    width: 100%;
    max-width: 480px;
    background: var(--bg-secondary);
    border-radius: 24px;
    padding: 40px 40px;
    border: 2px solid rgba(0, 217, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    margin: 0 auto;
}

/* Header */
.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    font-size: 64px;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 20px rgba(0, 217, 255, 0.3));
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.login-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0;
}

/* Steps */
.login-step {
    display: none;
}

.login-step.active {
    display: block;
    animation: fadeSlideIn 0.4s ease-out;
}

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

/* Form */
.modern-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Input Groups */
.modern-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modern-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.label-icon {
    font-size: 18px;
}

/* Modern Input - THE KEY TO FIXING AUTOFILL */
.modern-input {
    width: 100%;
    height: 56px;
    padding: 0 20px;
    font-size: 16px;
    font-family: inherit;
    direction: rtl;
    text-align: right;
    color: var(--text-primary);
    background: transparent;
    border: 2px solid rgba(0, 217, 255, 0.2);
    border-radius: 12px;
    outline: none;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

/* Phone input override - always LTR */
.modern-input[type="tel"] {
    direction: ltr !important;
    text-align: left !important;
    padding: 0 20px 0 100px !important;
}

/* Input wrapper with background */
.modern-phone-input,
.password-field {
    position: relative;
    background: var(--bg-card);
    border-radius: 12px;
}

.modern-phone-input::before,
.password-field::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--bg-card);
    border-radius: 12px;
    z-index: 0;
    pointer-events: none;
}

/* Input focus state */
.modern-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 4px rgba(0, 217, 255, 0.1);
}

.modern-input:hover {
    border-color: rgba(0, 217, 255, 0.3);
}

/* Error state */
.modern-input.error {
    border-color: var(--error-color);
}

/* AUTOFILL FIX - Using filter approach */
.modern-input:-webkit-autofill,
.modern-input:-webkit-autofill:hover,
.modern-input:-webkit-autofill:focus,
.modern-input:-webkit-autofill:active {
    -webkit-background-clip: text;
    -webkit-text-fill-color: var(--text-primary);
    transition: background-color 5000s ease-in-out 0s;
    box-shadow: inset 0 0 20px 20px var(--bg-card);
    border: 2px solid rgba(0, 217, 255, 0.2);
}

/* Alternative: Make the browser's autofill match our theme */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-text-fill-color: #e2e8f0 !important;
    -webkit-box-shadow: 0 0 0px 1000px #1e2939 inset !important;
    transition: background-color 5000s ease-in-out 0s;
    caret-color: #e2e8f0 !important;
}

/* Placeholder */
.modern-input::placeholder {
    color: rgba(148, 163, 184, 0.6);
}

/* Input hints */
.input-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: -4px;
}

.input-error {
    font-size: 13px;
    color: var(--error-color);
    margin-top: -4px;
    min-height: 18px;
}

/* Password Field */
.password-field {
    position: relative;
}

.password-field input {
    padding-right: 56px;
}

.password-toggle {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
    z-index: 2;
}

.password-toggle:hover {
    background: rgba(0, 217, 255, 0.1);
}

/* OTP Input */
.otp-input {
    font-size: 24px;
    letter-spacing: 8px;
    text-align: center;
    font-weight: 600;
}

/* Buttons */
.modern-btn {
    height: 56px;
    padding: 0 32px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s ease;
    outline: none;
}

.modern-btn.primary {
    background: linear-gradient(135deg, var(--accent-cyan), #00b8d9);
    color: #0f1729;
    box-shadow: 0 4px 20px rgba(0, 217, 255, 0.3);
}

.modern-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(0, 217, 255, 0.4);
}

.modern-btn.primary:active {
    transform: translateY(0);
}

.modern-btn.primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.modern-btn.secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid rgba(0, 217, 255, 0.2);
}

.modern-btn.secondary:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    background: rgba(0, 217, 255, 0.05);
}

.btn-arrow {
    font-size: 20px;
    transition: transform 0.3s;
}

.modern-btn:hover .btn-arrow {
    transform: translateX(-4px);
}

.modern-btn.secondary:hover .btn-arrow {
    transform: translateX(4px);
}

/* Checkbox */
.modern-checkbox-group {
    padding: 16px 0;
}

.modern-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.modern-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkbox-custom {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: 2px solid rgba(0, 217, 255, 0.3);
    border-radius: 6px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modern-checkbox input:checked + .checkbox-custom {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.modern-checkbox input:checked + .checkbox-custom::after {
    content: '✓';
    color: #0f1729;
    font-size: 16px;
    font-weight: bold;
}

.checkbox-label {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.link-accent {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: opacity 0.2s;
}

.link-accent:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Alerts */
.modern-alert {
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 15px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modern-alert.error {
    background: rgba(255, 71, 87, 0.1);
    color: #ff4757;
    border: 2px solid rgba(255, 71, 87, 0.3);
}

/* Resend Section */
.resend-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid rgba(0, 217, 255, 0.1);
    text-align: center;
}

.resend-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 12px 0;
}

.resend-btn {
    background: transparent;
    border: none;
    color: var(--accent-cyan);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s;
}

.resend-btn:hover {
    background: rgba(0, 217, 255, 0.1);
}

.resend-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.resend-icon.rotating {
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* intl-tel-input overrides */
/* Phone input must be LTR regardless of page direction */
.phone-input-wrapper,
.phone-input-wrapper * {
    direction: ltr !important;
    text-align: left !important;
}

.phone-input-wrapper input[type="tel"] {
    direction: ltr !important;
    text-align: left !important;
    padding: 0 20px 0 100px !important;
}

.iti {
    width: 100%;
}

/* Flag container - move to LEFT side */
.iti__flag-container {
    left: 0 !important;
    right: auto !important;
}

.iti__selected-flag {
    padding: 0 12px 0 16px !important;
    background: transparent;
    border-right: 1px solid rgba(0, 217, 255, 0.2) !important;
    border-left: none !important;
    display: flex !important;
    align-items: center !important;
}

/* Flag positioning in selected flag */
.iti__selected-flag .iti__flag {
    margin-right: 8px !important;
    margin-left: 0 !important;
}

.iti__selected-dial-code {
    color: var(--text-secondary);
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.iti__country-list {
    background: var(--bg-secondary);
    border: 2px solid rgba(0, 217, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-height: 300px;
    left: 0 !important;
    right: auto !important;
}

.iti__country {
    padding: 12px 16px;
    color: var(--text-primary);
}

.iti__country:hover {
    background: var(--bg-card);
}

.iti__country.iti__highlight {
    background: rgba(0, 217, 255, 0.1);
}

.iti__dial-code {
    color: var(--text-secondary);
}

/* Additional fixes for RTL override */
.iti__arrow {
    margin-left: 6px !important;
    margin-right: 0 !important;
    border-left: 3px solid transparent !important;
    border-right: 3px solid transparent !important;
    border-top: 4px solid var(--text-secondary) !important;
    border-bottom: none !important;
}

/* Fix for dropdown positioning in RTL context */
[dir="rtl"] .iti__flag-container,
[dir="rtl"] .iti--allow-dropdown .iti__flag-container {
    left: 0 !important;
    right: auto !important;
}

[dir="rtl"] .iti__country-list {
    left: 0 !important;
    right: auto !important;
}

[dir="rtl"] .iti--allow-dropdown .iti__country-container {
    right: auto !important;
    left: auto !important;
}

/* Search input in dropdown */
.iti__search-input {
    direction: ltr !important;
    text-align: left !important;
}

/* Country items in dropdown */
.iti__country {
    direction: ltr !important;
    text-align: left !important;
}

/* Ensure flag comes first, then country name, then dial code */
.iti__country .iti__flag {
    margin-right: 10px !important;
    margin-left: 0 !important;
}

.iti__country .iti__country-name {
    margin-right: auto !important;
    margin-left: 0 !important;
}

.iti__country .iti__dial-code {
    margin-left: 10px !important;
    margin-right: 0 !important;
}

/* Responsive */
@media (max-width: 640px) {
    .modern-login-container {
        min-height: calc(100vh - 120px); /* قيم أصغر للموبايل */
        padding: 20px 15px;
    }

    .modern-login-card {
        padding: 32px 24px;
    }

    .login-title {
        font-size: 24px;
    }

    .login-subtitle {
        font-size: 14px;
    }

    .modern-input {
        height: 52px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    .modern-btn {
        height: 52px;
    }
}

@media (max-width: 400px) {
    .modern-login-container {
        padding: 15px 10px;
    }

    .modern-login-card {
        padding: 24px 20px;
    }
}

/* Modern Checkbox Styles */
.modern-checkbox-group {
    margin: 24px 0;
}

.modern-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.modern-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkbox-mark {
    position: relative;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0, 217, 255, 0.3);
    border-radius: 6px;
    background: transparent;
    transition: all 0.3s ease;
    flex-shrink: 0;
    margin-top: 2px;
}

.checkbox-mark::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 6px;
    height: 10px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.2s ease;
}

.modern-checkbox:hover .checkbox-mark {
    border-color: rgba(0, 217, 255, 0.6);
    box-shadow: 0 0 12px rgba(0, 217, 255, 0.2);
}

.modern-checkbox input[type="checkbox"]:checked + .checkbox-mark {
    background: linear-gradient(135deg, #00d9ff, #0099cc);
    border-color: #00d9ff;
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.4);
}

.modern-checkbox input[type="checkbox"]:checked + .checkbox-mark::after {
    transform: rotate(45deg) scale(1);
}

.checkbox-text {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.terms-link {
    color: #00d9ff;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.terms-link:hover {
    color: #ffffff;
    text-decoration: underline;
}

/* Focus styles for accessibility */
.modern-checkbox input[type="checkbox"]:focus + .checkbox-mark {
    outline: 2px solid rgba(0, 217, 255, 0.5);
    outline-offset: 2px;
}

/* Animation for checkbox check */
@keyframes checkboxPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.modern-checkbox input[type="checkbox"]:checked + .checkbox-mark {
    animation: checkboxPulse 0.3s ease;
}

/* OTP Method Selection Styles */
.otp-method-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 12px;
}

.otp-method-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    background: var(--bg-card);
    border: 2px solid rgba(0, 217, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    gap: 8px;
    font-family: inherit;
}

.otp-method-btn:hover {
    border-color: rgba(0, 217, 255, 0.4);
    background: rgba(0, 217, 255, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.otp-method-btn.active {
    border-color: var(--accent-cyan);
    background: rgba(0, 217, 255, 0.1);
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.3);
}

.otp-method-btn[disabled] {
    cursor: not-allowed;
    position: relative;
}

.otp-method-btn[disabled]:hover {
    transform: none;
    border-color: rgba(0, 217, 255, 0.2);
    background: var(--bg-card);
    box-shadow: none;
}

.coming-soon-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 18px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

.method-icon {
    font-size: 32px;
    margin-bottom: 4px;
}

.method-icon .bi-telegram {
    color: #0088cc;
}

.method-icon .bi-whatsapp {
    color: #25D366;
}

.method-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.method-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

@media (max-width: 640px) {
    .otp-method-buttons {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .otp-method-btn {
        padding: 16px 12px;
    }
}
