/**
 * Enhanced Contact Forms Styling
 * Includes country phone selector and improved form layouts
 */

/* Phone Input Container with Country Selector */
.phone-input-container {
    display: flex !important;
    align-items: center !important;
    border: 2px solid #C9A96E !important;
    border-radius: 6px !important;
    background: white !important;
    overflow: hidden !important;
    transition: all 0.3s ease !important;
}

.phone-input-container:focus-within {
    border-color: #B8956A !important;
    box-shadow: 0 0 0 3px rgba(201, 169, 110, 0.1) !important;
}

.country-selector {
    border: none !important;
    background: #f8f9fa !important;
    padding: 12px 8px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #333 !important;
    cursor: pointer !important;
    outline: none !important;
    min-width: 80px !important;
    border-right: 1px solid #e5e7eb !important;
    border-left: none !important;
}

.country-selector:focus {
    background: #e9ecef !important;
}

.phone-input-container input[type="tel"] {
    border: none !important;
    flex: 1 !important;
    padding: 12px !important;
    font-size: 14px !important;
    outline: none !important;
    background: transparent !important;
    text-align: center !important;
    direction: ltr !important;
    unicode-bidi: plaintext !important;
    pointer-events: auto !important;
    user-select: text !important;
    caret-color: auto !important;
}

/* Country Code Box for Modal Forms */
.country-code-box {
    position: absolute !important;
    right: 8px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: #f8f9fa !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 4px !important;
    padding: 4px 8px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #666 !important;
    cursor: pointer !important;
    z-index: 10 !important;
    min-width: 50px !important;
    text-align: center !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
    transition: all 0.2s ease !important;
}

.country-code-box:hover {
    background: #e9ecef !important;
}

.phone-input-container input[type="tel"] {
    border: none !important;
    flex: 1 !important;
    padding: 12px !important;
    font-size: 14px !important;
    outline: none !important;
    background: transparent !important;
}


    border-color: #C9A96E !important;
}

/* Modal form styling */
.modal .form-group {
    position: relative !important;
    margin-bottom: 15px !important;
}

.modal .form-group.phone-input-group input[type="tel"] {
    padding-right: 70px !important;
}

/* Enhanced Form Styling */
.contact_us form {
    display: grid;
    gap: 20px;
}

.modal .contact_us form {
    gap: 15px;
}

.cusinpput {
    position: relative;
}

.cusinpput label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 14px;
}

.cusinpput input[type="text"],
.cusinpput input[type="email"],
.cusinpput input[type="tel"],
.cusinpput textarea,
.modal .form-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
    box-sizing: border-box;
}

/* Modal specific input styling */
.modal .form-input {
    border: 1px solid #ddd;
    padding: 15px;
    font-size: 16px;
}

.modal .form-input:focus {
    border-color: #C9A96E;
    box-shadow: 0 0 0 2px rgba(201, 169, 110, 0.1);
    outline: none;
}

.cusinpput input:focus,
.cusinpput textarea:focus {
    border-color: #C9A96E;
    box-shadow: 0 0 0 3px rgba(201, 169, 110, 0.1);
    outline: none;
}

.cusinpput input::placeholder,
.cusinpput textarea::placeholder {
    color: #9ca3af;
    opacity: 1;
}

/* Email field styling */
.cusinpput input[type="email"] {
    background-image: url("data:image/svg+xml,%3csvg width='20' height='20' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M2.003 5.884L10 9.882l7.997-3.998A2 2 0 0016 4H4a2 2 0 00-1.997 1.884z' fill='%23C9A96E'/%3e%3cpath d='M18 8.118l-8 4-8-4V14a2 2 0 002 2h12a2 2 0 002-2V8.118z' fill='%23C9A96E'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 40px;
}

/* Submit button styling */
.contact_us .submit {
    background: linear-gradient(135deg, #C9A96E 0%, #D4B575 100%) !important;
    color: #000000 !important;
    border: none !important;
    padding: 15px 30px !important;
    border-radius: 8px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    text-transform: none !important;
    box-shadow: 0 4px 15px rgba(201, 169, 110, 0.3) !important;
}

.contact_us .submit:hover {
    background: linear-gradient(135deg, #B8956A 0%, #C9A96E 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(201, 169, 110, 0.4) !important;
}

.contact_us .submit:active {
    transform: translateY(0) !important;
}

/* Phone number validation styles */
.phone-valid {
    border-color: #10b981 !important;
    background-image: url("data:image/svg+xml,%3csvg width='16' height='16' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z' fill='%2310b981'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: left 12px center !important;
    padding-left: 35px !important;
}

.phone-invalid {
    border-color: #ef4444 !important;
    background-image: url("data:image/svg+xml,%3csvg width='16' height='16' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z' fill='%23ef4444'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: left 12px center !important;
    padding-left: 35px !important;
}

.phone-validation-message {
    color: #ef4444 !important;
    font-size: 12px !important;
    margin-top: 4px !important;
    text-align: right !important;
    direction: rtl !important;
    font-weight: 500 !important;
}

/* Form validation styles */
.cusinpput input:invalid {
    border-color: #ef4444;
}

.cusinpput input:valid {
    border-color: #10b981;
}

/* Disable submit button if phone is invalid */
.contact_us .submit:disabled {
    background: #9ca3af !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
}

.contact_us .submit:disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Loading state */
.contact_us .submit.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.contact_us .submit.loading::after {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid transparent;
    border-top: 2px solid #000000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Success/Error messages */
.form-message {
    padding: 12px 16px;
    border-radius: 6px;
    margin-top: 15px;
    font-weight: 500;
}

.form-message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.form-message.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Responsive Design */
@media (max-width: 768px) {
    .phone-input-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .country-selector {
        border-right: none !important;
        border-bottom: 1px solid #e5e7eb !important;
        min-width: auto !important;
        width: 100% !important;
    }
    
    .contact_us form {
        gap: 15px;
        padding-bottom: 60px; /* Add space for mobile bottom bars */
    }
    
    .cusinpput input,
    .cusinpput textarea {
        padding: 10px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .contact_us .submit,
    .modal .submit-btn,
    .modal .submit {
        padding: 12px 24px !important;
        font-size: 15px !important;
        width: 100% !important;
        display: block !important;
        margin-top: 20px !important;
        margin-bottom: 20px !important;
        min-height: 50px !important;
        box-sizing: border-box !important;
    }
    
    /* Modal specific fixes for mobile */
    .modal .modal-content {
        max-height: 90vh !important;
        overflow-y: auto !important;
        padding-bottom: 30px !important;
    }
    
    /* Ensure submit button is always visible in modal */
    .modal .contact_us form {
        padding-bottom: 40px !important;
    }
    
    .modal .submit-btn,
    .modal .submit {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        transform: none !important;
        z-index: 1000 !important;
    }
}

@media (max-width: 480px) {
    .phone-input-container {
        border-radius: 4px !important;
    }
    
    .cusinpput input,
    .cusinpput textarea {
        border-radius: 4px;
        padding: 8px;
    }
    
    .contact_us .submit,
    .modal .submit-btn,
    .modal .submit {
        padding: 15px 20px !important;
        font-size: 16px !important;
        border-radius: 6px !important;
        min-height: 55px !important;
        margin-bottom: 30px !important;
        position: relative !important;
        bottom: 0 !important;
        width: 100% !important;
        display: block !important;
    }
    
    /* Extra padding for very small screens */
    .modal .contact_us form {
        padding-bottom: 50px !important;
    }
    
    /* Ensure modal content doesn't overflow */
    .modal .modal-content {
        max-height: 95vh !important;
        margin: 2.5vh auto !important;
        padding: 20px !important;
    }
    
    /* Fix for iOS Safari bottom bar */
    .modal {
        padding-bottom: env(safe-area-inset-bottom, 20px) !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .phone-input-container {
        background: #1f2937 !important;
        border-color: #374151 !important;
    }
    
    .country-selector {
        background: #374151 !important;
        color: #f9fafb !important;
        border-color: #4b5563 !important;
    }
    
    .cusinpput input,
    .cusinpput textarea {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .cusinpput label {
        color: #f9fafb;
    }
    
    .cusinpput input::placeholder,
    .cusinpput textarea::placeholder {
        color: #9ca3af;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .phone-input-container,
    .cusinpput input,
    .cusinpput textarea {
        border-width: 3px !important;
    }
    
    .contact_us .submit {
        border: 3px solid #000000 !important;
    }
}

/* Critical mobile submit button fix */
@media (max-width: 768px) {
    /* Override any inline styles that might hide the button */
    .modal button[type="submit"],
    .modal .submit-btn,
    .modal .submit,
    #contactModal button[type="submit"],
    #contactModal .submit-btn,
    #contactModal .submit {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        width: 100% !important;
        margin: 20px 0 30px 0 !important;
        padding: 15px !important;
        min-height: 50px !important;
        background: #C9A96E !important;
        color: #000000 !important;
        border: none !important;
        border-radius: 8px !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        cursor: pointer !important;
        z-index: 9999 !important;
        box-sizing: border-box !important;
    }
    
    /* Ensure modal form has enough bottom space */
    .modal form,
    #contactModal form {
        padding-bottom: 60px !important;
        min-height: auto !important;
        overflow: visible !important;
    }
    
    /* Ensure modal content is scrollable */
    .modal .modal-content,
    #contactModal .modal-content {
        overflow-y: auto !important;
        max-height: 90vh !important;
        padding-bottom: 40px !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .phone-input-container,
    .cusinpput input,
    .cusinpput textarea,
    .contact_us .submit {
        transition: none !important;
    }
    
    .contact_us .submit.loading::after {
        animation: none !important;
    }
}
