/* ========================================
   CSS ISOLATION AND RESET FOR WRAPPER
   ======================================== */

/* Wrapper base styles (no hard reset) */
.cnc-form-isolated-wrapper {
    font-family: inherit;
}

/* Keep children default behavior; no global unset to avoid breaking third-party widgets */
/* .cnc-form-isolated-wrapper * { } */

/* Restore critical element behaviors - no hard resets */
.cnc-form-isolated-wrapper input,
.cnc-form-isolated-wrapper textarea,
.cnc-form-isolated-wrapper button,
.cnc-form-isolated-wrapper select,
.cnc-form-isolated-wrapper .checkbox-text,
.cnc-form-isolated-wrapper .checkbox-subtext,
.cnc-form-isolated-wrapper .submit-btn {
    box-sizing: border-box;
    display: inline-block;
    font-family: inherit !important;
}

.cnc-form-isolated-wrapper form {
    display: block;
}

.cnc-form-isolated-wrapper div {
    display: block;
    box-sizing: border-box;
}

/* CSS Variables for customization - synchronized with defaults.php */
:root {
    --form-background-color: #ffffff;
    --field-background-color: #f1f3f4;
    --field-font-size: 12px;
    --field-spacing: 10px;
    --button-background-color: #b52d20;
    --button-text-color: #ffffff;
    --link-color: #1a73e8;
    --text-color: #333333;
    --required-checkbox-text-color: #5f6368;
    --checkbox-background-color: #f1f3f4;
    --checkbox-border-color: #e1e5e9;
    --checkbox-font-size: 12px;
    --subtext-color: #666666;
    --subtext-font-size: 10px;
    --icon-color: #666666;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8f9fa;
    padding: 40px 20px;
}

.cnc-form-isolated-wrapper .form-container {
    width: 100% !important;
    margin: 0 !important;
    background: var(--form-background-color) !important;
    padding: 16px !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08) !important;
}

/* Input with icon styling */
.cnc-form-isolated-wrapper .form-container .input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.cnc-form-isolated-wrapper .form-container .input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--icon-color);
    font-size: 16px;
    z-index: 3;
    pointer-events: none;
    line-height: 1;
    display: inline-block;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
}

/* Ensure inputs have enough left padding and proper stacking */
.cnc-form-isolated-wrapper .input-with-icon input {
    padding-left: 40px;
    position: relative;
    z-index: 2;
}

.cnc-form-isolated-wrapper .input-with-icon input {
    padding-left: 40px;
}

/* Base styles for all inputs */
.cnc-form-isolated-wrapper input, .cnc-form-isolated-wrapper select, .cnc-form-isolated-wrapper textarea {
    width: 100%;
    padding: 14px 16px; /* slightly less vertical padding to center text with icon */
    border: none;
    background-color: var(--field-background-color);
    border-radius: 8px;
    font-size: var(--field-font-size) !important; /* force theme overrides to respect plugin setting */
    color: var(--text-color);
    font-family: inherit;
    transition: all 0.2s ease;
    margin-bottom: var(--field-spacing);
}

.cnc-form-isolated-wrapper input:focus, .cnc-form-isolated-wrapper select:focus, .cnc-form-isolated-wrapper textarea:focus {
    outline: none;
    background-color: #e8f0fe;
    color: #1a73e8;
}

.cnc-form-isolated-wrapper input::placeholder, .cnc-form-isolated-wrapper textarea::placeholder {
    color: var(--text-color);
    opacity: 0.7;
    font-family: inherit !important;
    font-size: var(--field-font-size) !important;
}

/* Ensure intl-tel-input uses theme font and size too */
.cnc-form-isolated-wrapper .iti *,
.cnc-form-isolated-wrapper .iti input,
.cnc-form-isolated-wrapper .iti__country-list,
.cnc-form-isolated-wrapper .iti__country-name,
.cnc-form-isolated-wrapper .iti__dial-code {
    font-family: inherit !important;
    font-size: var(--field-font-size) !important;
}

/* Dial code beside the input should also match size */
.cnc-form-isolated-wrapper .iti .iti__selected-dial-code {
    font-size: var(--field-font-size) !important;
}

/* Row with two fields side by side */
.cnc-form-isolated-wrapper .form-row {
    display: flex;
    gap: 12px;
    margin-bottom: var(--field-spacing);
}

/* Elements that should not have bottom margin */
.cnc-form-isolated-wrapper .form-row input,
.cnc-form-isolated-wrapper .phone-row,
.cnc-form-isolated-wrapper .phone-row input,
.cnc-form-isolated-wrapper .phone-row select,
.cnc-form-isolated-wrapper .amount-row input,
.cnc-form-isolated-wrapper .iti,
.cnc-form-isolated-wrapper .iti input,
.cnc-form-isolated-wrapper .phone-input-container input {
    margin-bottom: 0;
}

.cnc-form-isolated-wrapper .form-row input {
    flex: 1;
}

.cnc-form-isolated-wrapper .form-row .input-with-icon {
    flex: 1;
}

/* Single field in form-row should take full width */
.cnc-form-isolated-wrapper .form-row:has(> .input-with-icon:only-child) {
    display: block;
}

.cnc-form-isolated-wrapper .form-row:has(> .input-with-icon:only-child) .input-with-icon {
    width: 100%;
}

/* Phone line */
.cnc-form-isolated-wrapper .phone-row {
    display: flex;
    gap: 12px;
}

.cnc-form-isolated-wrapper .phone-row select {
    width: 120px;
    flex-shrink: 0;
}

.cnc-form-isolated-wrapper .phone-row input {
    flex: 1;
}

/* Amount field with currency */
.cnc-form-isolated-wrapper .amount-row {
    position: relative;
    margin-bottom: var(--field-spacing);
}

.cnc-form-isolated-wrapper .amount-row input {
    padding-right: 60px;
}

.cnc-form-isolated-wrapper .currency {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #d93025;
    font-weight: 500;
    font-size: 14px;
    pointer-events: none;
}

/* Select with custom arrow */
.cnc-form-isolated-wrapper select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239aa0a6' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

/* Textarea */
.cnc-form-isolated-wrapper textarea {
    resize: vertical;
    min-height: 120px;
}

/* intl-tel-input wrapper styling */
.cnc-form-isolated-wrapper .iti {
    width: 100%;
}

.cnc-form-isolated-wrapper .iti input {
    padding-left: 90px; /* Space for flag and country code with extra spacing */
}

/* Style the flag container */
.cnc-form-isolated-wrapper .iti__flag-container {
    background-color: transparent;
    border-right: 1px solid #e1e5e9;
}

.cnc-form-isolated-wrapper .iti__selected-flag {
    background-color: transparent;
    border: none;
    padding: 0 8px;
    height: 100%;
    display: flex;
    align-items: center;
}

/* Flag sprite styles */
.cnc-form-isolated-wrapper .iti__flag {
    width: 20px;
    height: 15px;
    /* Laisser la librairie intl-tel-input définir le sprite et la taille */
    display: inline-block;
    margin-right: 6px;
}

/* High DPI flag support - use defaults from intl-tel-input CSS */

/* Use intl-tel-input's own flag positions and sprites to ensure correct mapping. */

/* Style the country dropdown */
.cnc-form-isolated-wrapper .iti__country-list {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    font-size: 14px;
}

.cnc-form-isolated-wrapper .iti__country {
    padding: 8px 12px;
    border-bottom: 1px solid #f1f3f4;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.cnc-form-isolated-wrapper .iti__country:hover {
    background-color: #f8f9fa;
}

.cnc-form-isolated-wrapper .iti__country.iti__highlight {
    background-color: #e8f0fe;
}

.cnc-form-isolated-wrapper .iti__country-name {
    margin-left: 6px;
    color: #5f6368;
}

.cnc-form-isolated-wrapper .iti__dial-code {
    color: #9aa0a6;
    margin-left: auto;
}

/* Style the dial code display */
.iti__selected-dial-code {
    color: #5f6368;
    font-size: 14px;
    margin-left: 4px;
}

/* Phone input container */
.cnc-form-isolated-wrapper .phone-input-container {
    position: relative;
    margin-bottom: var(--field-spacing);
}

/* Ensure phone field gets intl-tel-input styling */
.cnc-form-isolated-wrapper #phone {
    width: 100%;
}

/* Submit button */
.cnc-form-isolated-wrapper .submit-btn {
    width: 100%;
    padding: 16px;
    background-color: var(--button-background-color);
    color: var(--button-text-color);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cnc-form-isolated-wrapper .submit-btn:hover {
    background-color: var(--button-background-color);
    opacity: 0.9;
}

/* Error messages */
.cnc-form-isolated-wrapper .error-message {
    color: #d93025;
    font-size: 12px;
    display: none;
    padding: 8px 12px;
    background-color: #fce8e6;
    border-radius: 4px;
    margin-top: -12px;
    margin-bottom: var(--field-spacing);
}

.cnc-form-isolated-wrapper .required-asterisk {
    color: #d93025;
    font-weight: bold;
}

/* Blocked form message */
.cnc-form-isolated-wrapper .cnc-form-blocked {
    width: 100%;
    margin: 0;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.cnc-form-isolated-wrapper .cnc-form-blocked p {
    color: #856404;
    font-size: 16px;
    margin: 0;
    font-weight: 500;
}

/* Required checkbox styling */
.cnc-form-isolated-wrapper .required-checkbox-container {
    margin-bottom: var(--field-spacing);
    padding: 16px;
    background-color: var(--field-background-color);
    border: 1px solid var(--checkbox-border-color);
    border-radius: 8px;
}

.cnc-form-isolated-wrapper .checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.cnc-form-isolated-wrapper .checkbox-row input[type="checkbox"] {
    margin: 0;
    margin-top: 2px; /* Align with first line of text */
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    flex-shrink: 0;
    accent-color: var(--button-background-color);
    cursor: pointer;
}

.cnc-form-isolated-wrapper .checkbox-text-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.cnc-form-isolated-wrapper .checkbox-text {
    font-size: var(--checkbox-font-size);
    color: var(--required-checkbox-text-color);
    line-height: 1.4;
    font-weight: 500;
    cursor: pointer;
    margin: 0;
    display: block;
}

.cnc-form-isolated-wrapper .checkbox-subtext {
    font-size: var(--subtext-font-size);
    color: var(--subtext-color);
    line-height: 1.4;
    display: block;
}

.cnc-form-isolated-wrapper .checkbox-text:hover,
.cnc-form-isolated-wrapper .checkbox-row input[type="checkbox"]:hover + .checkbox-text-container .checkbox-text {
    color: var(--button-background-color);
}

/* Responsive */
@media (max-width: 600px) {
    .cnc-form-isolated-wrapper .form-row,
    .cnc-form-isolated-wrapper .phone-row {
        flex-direction: column;
    }
    
    .cnc-form-isolated-wrapper .phone-row select {
        width: 100%;
    }
}