/* OTP Modal Styles */
.otp-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    align-items: center;
    justify-content: center;
}

/* Spinner animation for loading states */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Show modal with flex when display is set to flex */
.otp-modal[style*="display: flex"] {
    display: flex !important;
}

.otp-modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s ease;
}

body.dark-mode .otp-modal-content {
    background: #1a1a1a;
    color: white;
}

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

.otp-close-btn {
    position: absolute;
    top: 15px;
    /* Support both LTR and RTL */
    right: 15px;
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #666;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

/* RTL support for close button */
[dir="rtl"] .otp-close-btn {
    right: auto;
    left: 15px;
}

.otp-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #E87722;
    transform: rotate(90deg);
}

body.dark-mode .otp-close-btn {
    color: #ccc;
}

body.dark-mode .otp-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.otp-close-btn:focus-visible {
    outline: 2px solid var(--primary-orange);
    outline-offset: 2px;
}

/* OTP Header */
.otp-header {
    text-align: center;
    margin-bottom: 30px;
}

.otp-icon {
    font-size: 60px;
    margin-bottom: 15px;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.otp-header h2 {
    font-size: 24px;
    margin-bottom: 10px;
    color: var(--text-dark);
}

body.dark-mode .otp-header h2 {
    color: white;
}

.otp-header p {
    color: #666;
    font-size: 14px;
    margin-bottom: 5px;
}

body.dark-mode .otp-header p {
    color: #aaa;
}

.otp-phone-display {
    color: var(--primary-orange);
    font-weight: bold;
    font-size: 16px;
    direction: ltr;
}

/* OTP Input Container */
.otp-input-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    direction: ltr;
}

.otp-input {
    width: 50px;
    height: 60px;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    border: 2px solid #ddd;
    border-radius: 10px;
    transition: all 0.3s ease;
    background: white;
    color: var(--text-dark);
}

/* Better mobile keyboard for OTP inputs */
.otp-input[type="text"] {
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
}

body.dark-mode .otp-input {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.otp-input:hover:not(:disabled) {
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 2px rgba(232, 119, 34, 0.05);
}

.otp-input:focus {
    outline: none;
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 3px rgba(232, 119, 34, 0.1);
    transform: scale(1.05);
}

.otp-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f5f5f5;
}

body.dark-mode .otp-input:disabled {
    background: rgba(255, 255, 255, 0.05);
}

/* Remove spinner arrows completely */
.otp-input::-webkit-outer-spin-button,
.otp-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
    display: none;
}

.otp-input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* OTP Timer */
.otp-timer {
    text-align: center;
    margin-bottom: 15px;
    color: #666;
    font-size: 14px;
    direction: ltr; /* Force LTR for timer numbers */
}

body.dark-mode .otp-timer {
    color: #aaa;
}

#otpTimerValue {
    color: var(--primary-orange);
    font-weight: bold;
    font-size: 16px;
    margin-right: 5px;
    margin-left: 5px; /* Add margin for both directions */
}

/* OTP Error */
.otp-error {
    display: none;
    background: #ffe6e6;
    color: #d32f2f;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 15px;
    font-size: 14px;
    border: 1px solid #ffcdd2;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

body.dark-mode .otp-error {
    background: rgba(211, 47, 47, 0.2);
    color: #ff6b6b;
    border-color: rgba(211, 47, 47, 0.3);
}

/* OTP Buttons */
.otp-verify-btn,
.otp-resend-btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.otp-verify-btn {
    background: linear-gradient(135deg, var(--primary-orange), var(--secondary-yellow));
    color: white;
}

.otp-verify-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(232, 119, 34, 0.3);
}

.otp-verify-btn:active {
    transform: translateY(0);
}

.otp-verify-btn:focus-visible {
    outline: 3px solid var(--primary-orange);
    outline-offset: 2px;
}

.otp-resend-btn {
    background: transparent;
    color: var(--primary-orange);
    border: 2px solid var(--primary-orange);
}

.otp-resend-btn:hover:not(:disabled) {
    background: var(--primary-orange);
    color: white;
}

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

.otp-resend-btn:focus-visible {
    outline: 2px solid var(--primary-orange);
    outline-offset: 2px;
}

/* OTP Loading */
.otp-loading {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 20px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

body.dark-mode .otp-loading {
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(8px);
}

.otp-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-orange);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.otp-loading p {
    margin-top: 15px;
    color: #666;
    font-size: 14px;
}

body.dark-mode .otp-loading p {
    color: #aaa;
}

/* Success Overlay */
.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.success-content {
    background: white;
    border-radius: 20px;
    padding: 50px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: scaleIn 0.4s ease;
}

body.dark-mode .success-content {
    background: #1a1a1a;
    color: white;
}

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

.success-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: bounce 1s infinite;
}

.success-content h2 {
    font-size: 28px;
    margin-bottom: 15px;
    color: var(--primary-orange);
}

.success-content p {
    color: #666;
    font-size: 16px;
    margin-bottom: 30px;
}

body.dark-mode .success-content p {
    color: #aaa;
}

.success-close-btn {
    padding: 15px 40px;
    background: linear-gradient(135deg, var(--primary-orange), var(--secondary-yellow));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.success-close-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(232, 119, 34, 0.3);
}

/* Notification Toast */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 10px;
    color: white;
    font-weight: bold;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    z-index: 10002;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

/* RTL support for notifications */
[dir="rtl"] .notification {
    right: auto;
    left: 20px;
    transform: translateX(-400px);
}

[dir="rtl"] .notification.show {
    transform: translateX(0);
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    background: linear-gradient(135deg, #4caf50, #8bc34a);
}

.notification-error {
    background: linear-gradient(135deg, #f44336, #e91e63);
}

.notification-info {
    background: linear-gradient(135deg, #2196F3, #03A9F4);
}

/* Confetti Animation */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: var(--primary-orange);
    z-index: 10000;
    animation: confetti-fall 3s linear forwards;
}

@keyframes confetti-fall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Responsive Design - Enhanced Mobile Experience */

/* Extra Small Devices (Mobile - Portrait) */
@media (max-width: 480px) {
    .otp-modal-content {
        padding: 25px 18px;
        width: 95%;
        max-width: 95%;
    }
    
    .otp-close-btn {
        width: 36px;
        height: 36px;
        font-size: 24px;
        top: 10px;
        right: 10px;
    }
    
    [dir="rtl"] .otp-close-btn {
        left: 10px;
        right: auto;
    }
    
    .otp-icon {
        font-size: 50px;
        margin-bottom: 12px;
    }
    
    .otp-header h2 {
        font-size: 18px;
        margin-bottom: 8px;
    }
    
    .otp-header p {
        font-size: 13px;
    }
    
    .otp-phone-display {
        font-size: 15px;
    }
    
    .otp-input-container {
        gap: 6px;
        margin-bottom: 18px;
    }

    .otp-input {
        width: 42px;
        height: 52px;
        font-size: 20px;
        border-radius: 8px;
        /* Prevent zoom on iOS */
        font-size: 16px;
    }
    
    .otp-timer {
        font-size: 13px;
        margin-bottom: 12px;
    }
    
    #otpTimerValue {
        font-size: 15px;
    }
    
    .otp-error {
        padding: 10px;
        font-size: 13px;
        margin-bottom: 12px;
    }
    
    .otp-verify-btn,
    .otp-resend-btn {
        padding: 14px;
        font-size: 15px;
        min-height: 50px;
        border-radius: 8px;
    }
    
    .success-content {
        padding: 35px 18px;
        width: 95%;
    }

    .success-icon {
        font-size: 55px;
        margin-bottom: 15px;
    }

    .success-content h2 {
        font-size: 20px;
        margin-bottom: 12px;
    }
    
    .success-content p {
        font-size: 14px;
        margin-bottom: 25px;
    }
    
    .success-close-btn {
        padding: 14px 35px;
        font-size: 15px;
    }

    .notification {
        right: 10px;
        left: 10px;
        top: 10px;
        width: calc(100% - 20px);
        max-width: none;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    [dir="rtl"] .notification {
        right: 10px;
        left: 10px;
    }
}

/* Small Devices (Mobile - Landscape & Small Tablets) */
@media (max-width: 768px) {
    .otp-modal-content {
        padding: 30px 20px;
    }

    .otp-input {
        width: 45px;
        height: 55px;
        font-size: 20px;
    }

    .otp-header h2 {
        font-size: 20px;
    }

    .success-content {
        padding: 40px 20px;
    }

    .success-icon {
        font-size: 60px;
    }

    .success-content h2 {
        font-size: 24px;
    }

    .notification {
        right: 10px;
        left: 10px;
        top: 10px;
        width: calc(100% - 20px);
        max-width: none;
    }
    
    [dir="rtl"] .notification {
        right: 10px;
        left: 10px;
    }
}

/* Landscape Orientation Optimization */
@media (max-height: 600px) and (orientation: landscape) {
    .otp-modal-content {
        max-height: 90vh;
        overflow-y: auto;
        padding: 20px 18px;
    }
    
    .otp-icon {
        font-size: 40px;
        margin-bottom: 10px;
    }
    
    .otp-header {
        margin-bottom: 20px;
    }
    
    .otp-input {
        height: 45px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .otp-input {
        /* Larger touch target */
        min-height: 50px;
        min-width: 44px;
    }
    
    .otp-close-btn {
        /* Larger touch target */
        min-width: 44px;
        min-height: 44px;
    }
    
    .otp-verify-btn,
    .otp-resend-btn {
        /* Better touch target */
        min-height: 50px;
    }
}

