/**
 * Caretrip Authentication Modal - Clean Modern Design
 * Optimized for both Desktop and Mobile
 */

/* ========================================
   MODAL CONTAINER & OVERLAY
   ======================================== */

.ct-auth-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.5) !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 99999 !important;
    padding: 20px !important;
    box-sizing: border-box !important;
}

.ct-auth-modal.ct-active {
    display: flex !important;
}

/* Ensure modal is hidden by default */
.ct-auth-modal:not(.ct-active) {
    display: none !important;
}

/* Debug: Force modal visibility when active */
#authModal.ct-active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.ct-auth-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

/* ========================================
   MODAL CONTENT
   ======================================== */

.ct-auth-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow: hidden;
    z-index: 1;
}

/* ========================================
   MODAL HEADER
   ======================================== */

.ct-auth-modal-header {
    position: relative;
    padding: 0;
    background: transparent;
}

.ct-auth-close-modal {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: #f8f9fa;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #6c757d;
    transition: all 0.2s ease;
    z-index: 2;
}

.ct-auth-close-modal:hover {
    background: #e9ecef;
    color: #495057;
}

/* ========================================
   MODAL BODY
   ======================================== */

.ct-auth-modal-body {
    padding: 32px 24px 24px;
    overflow-y: auto;
    max-height: calc(90vh - 60px);
}

/* ========================================
   STEPS CONTAINER
   ======================================== */

.ct-auth-step {
    display: none;
}

.ct-auth-step.ct-active {
    display: block;
}

/* ========================================
   BRAND SECTION
   ======================================== */

.ct-auth-brand-section {
    text-align: center;
    margin-bottom: 32px;
}

.ct-auth-brand-title {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 8px 0;
}

.ct-auth-brand-tagline {
    font-size: 14px;
    color: #6c757d;
    margin: 0;
    line-height: 1.4;
}

/* ========================================
   INPUT SECTION
   ======================================== */

.ct-auth-input-section {
    margin-bottom: 24px;
}

.ct-auth-mobile-input-container {
    display: flex;
    align-items: center;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: white;
    overflow: hidden;
    margin-bottom: 12px;
    transition: border-color 0.2s ease;
}

.ct-auth-mobile-input-container:focus-within {
    border-color: #3498db;
}

.ct-auth-country-code {
    padding: 14px 12px;
    background: #f8f9fa;
    color: #495057;
    font-weight: 600;
    font-size: 16px;
    border-right: 1px solid #e9ecef;
    flex-shrink: 0;
}

.ct-auth-mobile-input {
    flex: 1;
    padding: 14px 16px;
    border: none;
    background: transparent;
    font-size: 16px;
    color: #1a1a1a;
    outline: none;
}

.ct-auth-mobile-input::placeholder {
    color: #6c757d;
}

.ct-auth-input-note {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6c757d;
    font-size: 13px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.ct-auth-input-note i {
    color: #25d366;
    font-size: 14px;
}

/* ========================================
   FORM ELEMENTS
   ======================================== */

.ct-auth-form-group {
    margin-bottom: 16px;
}

.ct-auth-form-label {
    display: none;
}

.ct-auth-form-input,
.ct-auth-form-select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    color: #1a1a1a;
    background: white;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.ct-auth-form-input:focus,
.ct-auth-form-select:focus {
    outline: none;
    border-color: #3498db;
}

.ct-auth-form-input::placeholder {
    color: #6c757d;
}

/* ========================================
   GENDER BUTTONS
   ======================================== */

.ct-auth-gender-options {
    display: flex;
    gap: 8px;
    width: 100%;
}

.ct-auth-gender-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 8px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #495057;
}

.ct-auth-gender-btn:hover {
    border-color: #3498db;
    background: #f8f9fa;
}

.ct-auth-gender-btn.selected {
    border-color: #3498db;
    background: #e3f2fd;
    color: #1976d2;
}

.ct-auth-gender-btn i {
    font-size: 16px;
}

/* ========================================
   VERIFIED CONTACTS
   ======================================== */

.ct-auth-verified-contacts {
    margin-bottom: 24px;
}

.ct-auth-verified-email-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.ct-auth-verified-email {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e3f2fd;
    color: #1976d2;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.ct-auth-verified-email i {
    font-size: 12px;
}

.ct-auth-edit-email {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6c757d;
    transition: all 0.2s ease;
}

.ct-auth-edit-email:hover {
    background: #e9ecef;
    color: #495057;
    transform: scale(1.05);
}

.ct-auth-edit-email i {
    font-size: 12px;
}

/* ========================================
   DUAL OTP INPUT
   ======================================== */

.ct-auth-dual-otp-section {
    margin: 24px 0;
}

.ct-auth-otp-group {
    margin-bottom: 20px;
    padding: 15px;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    transition: all 0.3s ease;
}

/* OTP Group States */
.ct-auth-otp-group.valid {
    border-color: #27ae60;
    background-color: #f8fff9;
}

.ct-auth-otp-group.invalid {
    border-color: #e74c3c;
    background-color: #fff8f8;
}

.ct-auth-otp-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    margin: 0 0 8px 0;
    justify-content: space-between;
}

.ct-auth-otp-title .fab.fa-whatsapp {
    color: #25d366;
}

.ct-auth-otp-title .fas.fa-envelope {
    color: #3498db;
}

/* OTP Status Indicator */
.ct-otp-status {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 20px;
    display: none;
}

.ct-otp-status.valid {
    display: inline-block;
    color: #27ae60;
    background-color: #e8f5e8;
}

.ct-otp-status.invalid {
    display: inline-block;
    color: #e74c3c;
    background-color: #fdeaea;
}

/* OTP Input States */
.ct-auth-otp-container.valid .ct-auth-otp-digit {
    border-color: #27ae60 !important;
    background-color: #f8fff9 !important;
}

.ct-auth-otp-container.invalid .ct-auth-otp-digit {
    border-color: #e74c3c !important;
    background-color: #fff8f8 !important;
}

/* OTP Error Messages */
.ct-otp-error {
    color: #e74c3c;
    font-size: 14px;
    font-weight: 500;
    margin-top: 8px;
    padding: 8px 12px;
    background-color: #fdeaea;
    border-radius: 6px;
    border-left: 3px solid #e74c3c;
}

.ct-auth-otp-section {
    margin: 24px 0;
}

.ct-auth-otp-container {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 16px;
}

.ct-auth-otp-digit {
    width: 48px;
    height: 48px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: white;
    color: #1a1a1a;
    transition: border-color 0.2s ease;
}

.ct-auth-otp-digit:focus {
    outline: none;
    border-color: #3498db;
}

.ct-auth-otp-digit.filled {
    border-color: #3498db;
    background: #e3f2fd;
}

/* ========================================
   BUTTONS
   ======================================== */

.ct-auth-btn {
    width: 100%;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
}

.ct-auth-btn-primary {
    background: #3498db;
    color: white;
    margin-bottom: 12px;
}

.ct-auth-btn-primary:hover:not(:disabled) {
    background: #2980b9;
    transform: translateY(-1px);
}

.ct-auth-btn-primary:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.ct-auth-btn-secondary {
    background: #f8f9fa;
    color: #6c757d;
    border: 2px solid #e9ecef;
    margin-bottom: 12px;
}

.ct-auth-btn-secondary:hover:not(:disabled) {
    background: #e9ecef;
    color: #495057;
}

.ct-auth-btn-loading {
    display: none;
}

.ct-auth-btn.loading .ct-auth-btn-text {
    display: none;
}

.ct-auth-btn.loading .ct-auth-btn-loading {
    display: inline-block;
}

/* Disabled button state */
.ct-auth-btn:disabled,
.ct-auth-btn.disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

/* Form loading state - disable all inputs during processing */
.ct-auth-input.loading-disabled,
.ct-auth-select.loading-disabled,
.ct-auth-gender-btn.loading-disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    background-color: #f5f5f5 !important;
    color: #999 !important;
    pointer-events: none !important;
}

.ct-auth-mobile-input.loading-disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    background-color: #f5f5f5 !important;
    color: #999 !important;
    pointer-events: none !important;
}

/* ========================================
   VERIFIED MOBILE BADGE
   ======================================== */

.ct-auth-verified-mobile-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.ct-auth-verified-mobile {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e8f5e8;
    color: #27ae60;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.ct-auth-verified-mobile i {
    font-size: 12px;
}

.ct-auth-edit-mobile {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6c757d;
    transition: all 0.2s ease;
}

.ct-auth-edit-mobile:hover {
    background: #e9ecef;
    color: #495057;
    transform: scale(1.05);
}

.ct-auth-edit-mobile i {
    font-size: 12px;
}

/* ========================================
   TERMS & POLICY
   ======================================== */

.ct-auth-terms {
    text-align: center;
    margin-top: 16px;
}

.ct-auth-terms p {
    font-size: 12px;
    color: #6c757d;
    line-height: 1.4;
    margin: 0;
}

.ct-auth-terms a {
    color: #3498db;
    text-decoration: none;
}

.ct-auth-terms a:hover {
    text-decoration: underline;
}

/* ========================================
   TIMER & RESEND
   ======================================== */

.ct-auth-timer-section {
    text-align: center;
    margin: 16px 0;
}

.ct-auth-timer-text {
    font-size: 14px;
    color: #6c757d;
}

.ct-auth-timer-count {
    font-weight: 600;
    color: #e74c3c;
}

.ct-auth-attempt-counter {
    font-size: 12px;
    color: #6c757d;
    margin: 4px 0 0 0;
    text-align: center;
}

.ct-attempt-count {
    font-weight: 600;
    color: #e74c3c;
}

.ct-max-attempts {
    font-weight: 600;
    color: #6c757d;
}

/* ========================================
   SUCCESS STATE
   ======================================== */

.ct-auth-success-content {
    text-align: center;
    padding: 20px 0;
}

.ct-auth-success-icon {
    width: 64px;
    height: 64px;
    background: #27ae60;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: white;
    font-size: 24px;
}

.ct-auth-success-content h3 {
    font-size: 20px;
    color: #1a1a1a;
    margin: 0 0 8px 0;
}

.ct-auth-success-content p {
    font-size: 14px;
    color: #6c757d;
    margin: 0 0 24px 0;
}

/* ========================================
   ERROR MESSAGES
   ======================================== */

.auth-error-message {
    /* Styles are now applied inline via JavaScript */
    transition: opacity 0.3s ease;
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 480px) {
    .ct-auth-modal {
        padding: 16px;
    }
    
    .ct-auth-modal-content {
        max-width: 100%;
        border-radius: 12px;
    }
    
    .ct-auth-modal-body {
        padding: 24px 20px 20px;
    }
    
    .ct-auth-brand-title {
        font-size: 20px;
    }
    
    .ct-auth-form-input,
    .ct-auth-form-select,
    .ct-auth-btn,
    .ct-auth-mobile-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .ct-auth-country-code {
        font-size: 16px;
        padding: 12px 10px;
    }
    
    .ct-auth-mobile-input {
        padding: 12px 14px;
    }
    
    .ct-auth-otp-digit {
        width: 42px;
        height: 42px;
        font-size: 16px;
        /* Force numeric keypad on mobile */
        -webkit-appearance: none;
        -moz-appearance: textfield;
    }
    
    .ct-auth-gender-btn {
        font-size: 13px;
        padding: 10px 6px;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .ct-auth-gender-options {
        flex-direction: column;
        gap: 8px;
    }
    
    .ct-auth-gender-btn {
        justify-content: flex-start;
        padding: 12px 16px;
    }
}

/* ========================================
   PREVENT BODY SCROLL
   ======================================== */

body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    body.modal-open {
        position: fixed;
        width: 100%;
        height: 100vh;
        overflow: hidden;
    }
    
    .ct-auth-modal {
        height: 100vh;
    }
}
