/* TSW OTP Simple Popup Styles */
#tsw-otp-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.tsw-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 999998;
    backdrop-filter: blur(3px);
}

.tsw-popup-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    width: 95%;
    max-width: 380px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 999999;
    overflow: hidden;
}

.tsw-popup-step {
  display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
}

.tsw-popup-step.active {
    display: block;
}

.tsw-popup-header {
    background: linear-gradient(135deg, #bf212f 0%, #a81c28 100%);
    color: white;
    padding: 15px;
    text-align: center;
}

.tsw-popup-header h3 {
    margin: 0 0 5px 0;
    font-size: 16px;
    color: #fff;
    font-weight: 600;
    line-height: 1.3;
}

.tsw-popup-header p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
    line-height: 1.4;
}

.tsw-popup-header.success {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
}

.tsw-popup-header.error {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.tsw-popup-body {
    padding: 20px;
}

.tsw-form-group {
    flex: 1 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-height: calc(80vh - 120px) !important;
        padding-bottom: 20px !important;
}

.tsw-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 13px;
}

.tsw-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    background: #fff;
}

.tsw-input:focus {
    border-color: #bf212f;
    outline: none;
    box-shadow: 0 0 0 2px rgba(191, 33, 47, 0.1);
}

/* Select2 customization - IMPORTANT: Fix for mobile */
.select2-container {
    z-index: 1000000 !important; /* Higher z-index for mobile */
    width: 100% !important;
}

.select2-container--open .select2-dropdown {
    z-index: 1000001 !important; /* Higher than popup */
    font-size: 13px; /* Smaller font for mobile */
}

.select2-results__option {
    padding: 8px 12px;
    font-size: 13px;
}

.select2-selection--single {
    height: 40px !important;
    padding: 8px 12px !important;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    font-size: 14px !important;
}

.select2-selection__rendered {
    line-height: 24px !important;
    padding-left: 0 !important;
    font-size: 14px !important;
}

.select2-selection__arrow {
    height: 38px !important;
}

/* Phone input group */
.tsw-phone-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tsw-country-code {
    flex: 0 0 70px;
}

.tsw-country-code-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
    background: #f9f9f9;
    font-weight: 600;
    color: #333;
}

.tsw-phone-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}

#tsw-otp-code {
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    letter-spacing: 4px;
    padding: 10px;
}

.tsw-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
    min-height: 16px;
    line-height: 1.3;
}

.tsw-hint {
    color: #666;
    font-size: 11px;
    margin-top: 4px;
    line-height: 1.3;
}

.tsw-popup-buttons {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.tsw-btn {
    flex: 1;
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    min-height: 40px;
}

.tsw-btn-primary {
    background: linear-gradient(135deg, #bf212f 0%, #a81c28 100%);
    color: white;
}

.tsw-btn-primary:hover,
.tsw-btn-primary:active {
    background: linear-gradient(135deg, #a81c28 0%, #911722 100%);
    transform: translateY(-1px);
}

.tsw-btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
}

.tsw-btn-secondary:hover,
.tsw-btn-secondary:active {
    background: linear-gradient(135deg, #5a6268 0%, #494f54 100%);
    transform: translateY(-1px);
}

.tsw-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.tsw-success-message,
.tsw-error-message {
    text-align: center;
    padding: 15px 0;
}

.tsw-success-icon,
.tsw-error-icon {
    width: 50px;
    height: 50px;
    background: #28a745;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 12px;
    font-weight: bold;
}

.tsw-error-icon {
    background: #dc3545;
}

.tsw-success-message h4,
.tsw-error-message h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
}

.tsw-success-message h4 {
    color: #28a745;
}

.tsw-error-message h4 {
    color: #dc3545;
}

.tsw-success-message p,
.tsw-error-message p {
    color: #666;
    margin: 0 0 12px 0;
    font-size: 13px;
    line-height: 1.4;
}

.tsw-spinner {
    width: 25px;
    height: 25px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #28a745;
    border-radius: 50%;
    margin: 10px auto;
    animation: tsw-spin 1s linear infinite;
}

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

/* Loading dots */
.tsw-loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: tsw-spin 1s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

/* Shake animation */
.tsw-shake {
    animation: shake 0.5s ease-in-out;
}

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

/* Mobile-specific optimizations */
@media (max-width: 480px) {
    .tsw-popup-modal {
        width: 92%;
        max-width: 340px;
        max-height: 80vh;
        border-radius: 10px;
		overflow: hidden !important;
    }
    
    .tsw-popup-header {
        padding: 12px;
    }
    
    .tsw-popup-header h3 {
        font-size: 15px;
    }
    
    .tsw-popup-header p {
        font-size: 11px !important;
    }
    
    .tsw-popup-body {
        padding: 16px;
    }
    
    .tsw-form-group label {
        font-size: 12px;
    }
    
    .tsw-input {
        font-size: 13px;
        padding: 8px 11px;
		 height: 40px !important;
    }
    
    .tsw-country-code-input,
    .tsw-phone-input {
        font-size: 13px;
        padding: 8px 10px;
		 height: 40px !important;
    }
    
    #tsw-otp-code {
        font-size: 18px;
        letter-spacing: 3px;
    }
    
    .tsw-btn {
        padding: 9px 12px;
        font-size: 12px;
        min-height: 38px;
    }
    
    .tsw-hint {
        font-size: 10px;
    }
    
    .tsw-error {
        font-size: 11px;
    }
    
    /* Fix for mobile touch - larger touch targets */
    .select2-results__option {
        padding: 10px 12px;
        min-height: 42px;
        display: flex;
        align-items: center;
    }
    
    .select2-selection--single {
        min-height: 42px !important;
    }
    
    .select2-selection__rendered {
        line-height: 22px !important;
        display: flex;
        align-items: center;
    }
}

/* Extra small devices */
@media (max-width: 360px) {
    .tsw-popup-modal {
       width: 95% !important;
        max-width: 320px !important;
        max-height: 85vh !important;
    }
	.tsw-popup-body {
        max-height: calc(85vh - 110px) !important;
    }
    
    .tsw-popup-header h3 {
        font-size: 13px;
    }
    
    .tsw-phone-input-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .tsw-country-code {
        width: 100%;
    }
    
    .tsw-country-code-input {
        width: 100%;
    }
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
    .tsw-popup-modal {
        -webkit-overflow-scrolling: touch;
    }
    
    .tsw-input,
    .tsw-btn {
        -webkit-appearance: none;
        -webkit-border-radius: 6px;
    }
}

/* Ensure dropdown works on mobile */
.select2-dropdown {
    border: 1px solid #ddd !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

/* Prevent body scroll when popup is open */
/* body.tsw-popup-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
} */

body.tsw-popup-open {
    overflow: hidden;
}

/* Mobile-specific Select2 fixes */
.tsw-select2-mobile .select2-results__option {
    padding: 12px 10px !important;
    font-size: 13px !important;
    min-height: 44px !important;
    border-bottom: 1px solid #f0f0f0;
}

.tsw-select2-mobile .select2-search__field {
    height: 40px !important;
    font-size: 14px !important;
}

.tsw-select2-mobile-container .select2-selection--single {
    height: 44px !important;
}

/* Fix for dropdown positioning on mobile */
.select2-dropdown {
    max-height: 250px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

/* Ensure dropdown appears above everything on mobile */
.select2-container--open {
    z-index: 1000002 !important;
}

.select2-dropdown {
    z-index: 1000003 !important;
}

/* Improve touch targets */
.tsw-country-select + .select2 .select2-selection__rendered {
    line-height: 22px;
    display: flex;
    align-items: center;
}


/* Your requested CSS */
.select2-container .select2-selection--single .select2-selection__rendered {
    display: block !important;
    padding: 0px 16px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    line-height: 25px !important;
}

/* Mobile dropdown fixes */
.select2-container--open .select2-dropdown {
    z-index: 1000001 !important;
    font-size: 13px !important;
}

.select2-results__option {
    padding: 10px 12px !important;
    font-size: 13px !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
}

.select2-selection--single {
    height: 42px !important;
    padding: 8px 12px !important;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    font-size: 14px !important;
}

.select2-selection__arrow {
    height: 40px !important;
}

/* Mobile bottom sheet style dropdown */
@media (max-width: 480px) {
    .select2-dropdown {
        max-height: 50vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .select2-search--dropdown {
        padding: 10px !important;
    }
    
    .select2-search__field {
        height: 40px !important;
        font-size: 14px !important;
        border-radius: 6px !important;
    }
    
    .select2-results__option {
        padding: 12px 16px !important;
        border-bottom: 1px solid #f0f0f0 !important;
    }
}

/* Mobile Scroll Container */
@media (max-width: 480px) {
    .tsw-popup-modal {
        display: flex !important;
        flex-direction: column !important;
    }
    
    .tsw-popup-step {
        display: none !important;
        flex: 1 !important;
        flex-direction: column !important;
    }
    
    .tsw-popup-step.active {
        display: flex !important;
    }
    
    .tsw-popup-header {
        flex-shrink: 0 !important;
    }
    
    .tsw-popup-body {
        flex: 1 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 20px 16px !important;
    }
    
    .tsw-popup-buttons {
        flex-shrink: 0 !important;
        padding-top: 15px !important;
        margin-top: auto !important;
    }
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
    .tsw-popup-body {
        overflow-y: scroll !important;
    }
}

/* Prevent body scroll when popup is open */
/* body.tsw-popup-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
} */

body.tsw-select2-open {
    overflow: hidden !important;
    position: fixed !important;
}

/* Desktop specific styles - Override mobile styles */
@media (min-width: 481px) {
    .tsw-popup-step {
        display: none !important;
        flex-direction: column !important;
        height: auto !important;
    }
    
    .tsw-popup-step.active {
        display: block !important;
    }
    
    .tsw-popup-body {
        flex: auto !important;
        overflow-y: visible !important;
        max-height: none !important;
        padding-bottom: 20px !important;
        padding: 20px !important;
    }
    
    .tsw-form-group {
        flex: auto !important;
        overflow-y: visible !important;
        max-height: none !important;
        padding-bottom: 0 !important;
        margin-bottom: 15px !important;
    }
    
    .tsw-popup-buttons {
        flex-shrink: 0 !important;
        padding-top: 15px !important;
        margin-top: 15px !important;
    }
    
    /* Ensure proper display for desktop */
    .tsw-popup-modal {
        display: block !important;
    }
}

/* Mobile-specific optimizations - Only apply below 481px */
@media (max-width: 480px) {
    .tsw-popup-modal {
        width: 92%;
        max-width: 340px;
        max-height: 80vh;
        border-radius: 10px;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .tsw-popup-step {
        display: none !important;
        flex: 1 !important;
        flex-direction: column !important;
        height: 100% !important;
    }
    
    .tsw-popup-step.active {
        display: flex !important;
    }
    
    .tsw-popup-header {
        flex-shrink: 0 !important;
        padding: 12px;
    }
    
    .tsw-popup-header h3 {
        font-size: 15px;
    }
    
    .tsw-popup-header p {
        font-size: 11px !important;
    }
    
    .tsw-popup-body {
        flex: 1 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 16px !important;
        max-height: calc(80vh - 120px) !important;
    }
    
    .tsw-form-group {
        flex: 1 !important;
        overflow-y: visible !important;
        max-height: none !important;
        padding-bottom: 0 !important;
        margin-bottom: 15px !important;
    }
    
    .tsw-form-group label {
        font-size: 12px;
    }
    
    .tsw-input {
        font-size: 13px;
        padding: 8px 11px;
        height: 40px !important;
    }
    
    .tsw-country-code-input,
    .tsw-phone-input {
        font-size: 13px;
        padding: 8px 10px;
        height: 40px !important;
    }
    
    #tsw-otp-code {
        font-size: 18px;
        letter-spacing: 3px;
    }
    
    .tsw-btn {
        padding: 9px 12px;
        font-size: 12px;
        min-height: 38px;
    }
    
    .tsw-hint {
        font-size: 10px;
    }
    
    .tsw-error {
        font-size: 11px;
    }
    
    .tsw-popup-buttons {
        flex-shrink: 0 !important;
        padding-top: 15px !important;
        margin-top: auto !important;
    }
}

/* Default desktop styles - Remove mobile flexbox */
.tsw-popup-step {
    display: none;
    height: auto;
}

.tsw-popup-step.active {
    display: block;
}

.tsw-popup-body {
    padding: 20px;
    overflow-y: visible;
}

.tsw-form-group {
    margin-bottom: 15px;
}

.tsw-popup-buttons {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.tsw-popup-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    width: 95%;
    max-width: 380px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 999999;
    overflow: hidden;
}

