/**
 * HDKN Dynamic Forms - Frontend Styles
 * Radio/Checkbox simples et natifs
 */

/* ==========================================================================
   VARIABLES
   ========================================================================== */

.hdkn-form-wrapper {
    --hdkn-primary: #0073aa;
    --hdkn-primary-hover: #005a87;
    --hdkn-text: #333;
    --hdkn-text-light: #666;
    --hdkn-border: #ccc;
    --hdkn-radius: 4px;
    --hdkn-error: #dc3545;
    --hdkn-success: #28a745;
    --hdkn-btn-bg: #0073aa;
    --hdkn-btn-hover: #005a87;
    --hdkn-btn-text: #ffffff;
    --hdkn-btn-prev-bg: #f0f0f0;
    --hdkn-btn-prev-hover: #e0e0e0;
    --hdkn-btn-prev-text: #333333;
}

/* ==========================================================================
   BASE
   ========================================================================== */

.hdkn-form-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--hdkn-text);
}

.hdkn-form-wrapper * {
    box-sizing: border-box;
}

/* ==========================================================================
   LAYOUT CHAMPS
   ========================================================================== */

.hdkn-step-fields {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.hdkn-field {
    width: 100%;
    padding: 0 10px;
    margin-bottom: 14px;
}

/* Largeurs en % */
.hdkn-field.hdkn-width-100 { width: 100%; }
.hdkn-field.hdkn-width-90 { width: 90%; }
.hdkn-field.hdkn-width-80 { width: 80%; }
.hdkn-field.hdkn-width-75 { width: 75%; }
.hdkn-field.hdkn-width-70 { width: 70%; }
.hdkn-field.hdkn-width-60 { width: 60%; }
.hdkn-field.hdkn-width-50 { width: 50%; }
.hdkn-field.hdkn-width-40 { width: 40%; }
.hdkn-field.hdkn-width-30 { width: 30%; }
.hdkn-field.hdkn-width-25 { width: 25%; }
.hdkn-field.hdkn-width-20 { width: 20%; }

/* Responsive : mobile = toujours 100% */
@media (max-width: 600px) {
    .hdkn-field[class*="hdkn-width-"] {
        width: 100%;
    }
}

.hdkn-field.hdkn-hidden {
    display: none !important;
}

/* ==========================================================================
   SÉPARATEUR (DIVIDER)
   ========================================================================== */

.hdkn-divider {
    border: none;
    border-top: 1px solid var(--hdkn-border);
    margin: 20px 0;
}

.hdkn-divider.hdkn-divider-margin-small { margin: 10px 0; }
.hdkn-divider.hdkn-divider-margin-medium { margin: 20px 0; }
.hdkn-divider.hdkn-divider-margin-large { margin: 30px 0; }
.hdkn-divider.hdkn-divider-margin-xlarge { margin: 50px 0; }

/* ==========================================================================
   HEADING (TITRE)
   ========================================================================== */

.hdkn-heading {
    margin: 0 0 10px 0;
    color: var(--hdkn-text);
    font-weight: 600;
    line-height: 1.3;
}

.hdkn-heading.hdkn-align-left { text-align: left; }
.hdkn-heading.hdkn-align-center { text-align: center; }
.hdkn-heading.hdkn-align-right { text-align: right; }

/* ==========================================================================
   PARAGRAPH (TEXTE)
   ========================================================================== */

.hdkn-paragraph {
    margin: 0 0 15px 0;
    color: var(--hdkn-text-light);
    line-height: 1.6;
}

.hdkn-paragraph.hdkn-align-left { text-align: left; }
.hdkn-paragraph.hdkn-align-center { text-align: center; }
.hdkn-paragraph.hdkn-align-right { text-align: right; }

.hdkn-paragraph.hdkn-size-small { font-size: 13px; }
.hdkn-paragraph.hdkn-size-normal { font-size: 15px; }
.hdkn-paragraph.hdkn-size-large { font-size: 17px; }
.hdkn-paragraph.hdkn-size-xlarge { font-size: 20px; }

/* ==========================================================================
   LABELS
   ========================================================================== */

.hdkn-label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 14px;
    color: var(--hdkn-text);
}

.hdkn-required {
    color: var(--hdkn-error);
    margin-left: 2px;
}

/* ==========================================================================
   INPUTS STANDARDS
   ========================================================================== */

.hdkn-form-wrapper input[type="text"],
.hdkn-form-wrapper input[type="email"],
.hdkn-form-wrapper input[type="tel"],
.hdkn-form-wrapper input[type="url"],
.hdkn-form-wrapper input[type="number"],
.hdkn-form-wrapper input[type="date"],
.hdkn-form-wrapper input[type="time"],
.hdkn-form-wrapper input[type="password"],
.hdkn-form-wrapper select,
.hdkn-form-wrapper textarea {
    width: 100%;
    padding: 6px 10px;
    font-size: 14px;
    font-family: inherit;
    color: #333333;
    background: #fff;
    border: 1px solid var(--hdkn-border);
    border-radius: var(--hdkn-radius);
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Fix spécifique pour les inputs date/time - couleur forcée */
.hdkn-form-wrapper input[type="date"],
.hdkn-form-wrapper input[type="time"],
.hdkn-form-wrapper input[type="datetime-local"] {
    color: #333333 !important;
}

/* Webkit date picker */
.hdkn-form-wrapper input[type="date"]::-webkit-datetime-edit,
.hdkn-form-wrapper input[type="date"]::-webkit-datetime-edit-fields-wrapper,
.hdkn-form-wrapper input[type="date"]::-webkit-datetime-edit-text,
.hdkn-form-wrapper input[type="date"]::-webkit-datetime-edit-month-field,
.hdkn-form-wrapper input[type="date"]::-webkit-datetime-edit-day-field,
.hdkn-form-wrapper input[type="date"]::-webkit-datetime-edit-year-field {
    color: #333333;
}

.hdkn-form-wrapper input:focus,
.hdkn-form-wrapper select:focus,
.hdkn-form-wrapper textarea:focus {
    outline: none;
    border-color: var(--hdkn-primary);
    box-shadow: 0 0 0 3px rgba(0,115,170,0.15);
}

.hdkn-form-wrapper textarea {
    min-height: 100px;
    resize: vertical;
}

.hdkn-form-wrapper select {
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ==========================================================================
   RADIO ET CHECKBOX - AVEC OPTIONS
   ========================================================================== */

/* Container du champ */
.hdkn-radio-field,
.hdkn-checkbox-field {
    margin-bottom: 5px;
}

/* Label du champ (optionnel) */
.hdkn-radio-field > .hdkn-field-label,
.hdkn-checkbox-field > .hdkn-field-label {
    display: block;
    font-weight: 600;
    color: var(--hdkn-text);
    margin-bottom: 10px;
}

/* Container des options - en ligne */
.hdkn-radio-options,
.hdkn-checkbox-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    align-items: center;
}

/* Item individuel : bouton + texte */
.hdkn-radio-item,
.hdkn-checkbox-item {
    display: inline-flex;
    align-items: center;
}

/* Input natif */
.hdkn-radio-item input[type="radio"],
.hdkn-checkbox-item input[type="checkbox"] {
    -webkit-appearance: auto;
    -moz-appearance: auto;
    appearance: auto;
    width: 16px;
    height: 16px;
    margin: 0;
    margin-right: 6px;
    padding: 0;
    accent-color: var(--hdkn-primary);
    cursor: pointer;
    vertical-align: middle;
}

/* Label texte à côté du bouton */
.hdkn-radio-item label,
.hdkn-checkbox-item label {
    font-weight: 400;
    color: var(--hdkn-text);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
}

/* Ancienne structure (compatibilité fieldset) */
.hdkn-fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.hdkn-fieldset legend.hdkn-label {
    margin-bottom: 10px;
    padding: 0;
    float: none;
    width: 100%;
}

.hdkn-radio-group,
.hdkn-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    align-items: center;
}

.hdkn-radio-option,
.hdkn-checkbox-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.hdkn-radio-option input[type="radio"],
.hdkn-checkbox-option input[type="checkbox"] {
    -webkit-appearance: auto;
    -moz-appearance: auto;
    appearance: auto;
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    accent-color: var(--hdkn-primary);
    cursor: pointer;
}

.hdkn-radio-option span,
.hdkn-checkbox-option span {
    font-weight: 400;
    color: var(--hdkn-text);
    font-size: 15px;
    line-height: 1.4;
}

/* ==========================================================================
   FILE INPUT
   ========================================================================== */

.hdkn-file-input {
    position: relative;
}

.hdkn-file {
    width: 100%;
    padding: 12px;
    border: 2px dashed var(--hdkn-border);
    border-radius: var(--hdkn-radius);
    background: #fafafa;
    cursor: pointer;
}

.hdkn-file:hover {
    border-color: var(--hdkn-primary);
    background: #f0f7fc;
}

.hdkn-file-preview {
    margin-top: 8px;
}

.hdkn-file-name {
    font-size: 14px;
    color: var(--hdkn-text-light);
}

.hdkn-field-hint {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--hdkn-text-light);
}

/* ==========================================================================
   LAYOUT ELEMENTS
   ========================================================================== */

.hdkn-heading {
    margin: 30px 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
    color: var(--hdkn-text);
}

.hdkn-paragraph {
    margin: 15px 0;
    color: var(--hdkn-text-light);
    line-height: 1.6;
}

.hdkn-divider {
    height: 1px;
    background: #eee;
    margin: 25px 0;
    border: none;
}

/* ==========================================================================
   ERREURS
   ========================================================================== */

.hdkn-field-error {
    color: var(--hdkn-error);
    font-size: 13px;
    margin-top: 5px;
}

.hdkn-field.has-error input,
.hdkn-field.has-error select,
.hdkn-field.has-error textarea {
    border-color: var(--hdkn-error);
}

/* ==========================================================================
   BOUTONS - Couleurs personnalisables
   ========================================================================== */

.hdkn-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--hdkn-radius);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.hdkn-btn-submit,
.hdkn-btn-next {
    background: var(--hdkn-btn-bg, var(--hdkn-primary));
    color: var(--hdkn-btn-text, #fff);
}

.hdkn-btn-submit:hover,
.hdkn-btn-next:hover {
    background: var(--hdkn-btn-hover, var(--hdkn-primary-hover));
}

.hdkn-btn-prev {
    background: var(--hdkn-btn-prev-bg, #f0f0f0);
    color: var(--hdkn-btn-prev-text, var(--hdkn-text));
    border: 1px solid var(--hdkn-border);
}

.hdkn-btn-prev:hover {
    background: var(--hdkn-btn-prev-hover, #e0e0e0);
}

.hdkn-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.hdkn-btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.hdkn-btn.loading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid var(--hdkn-btn-text, #fff);
    border-top-color: transparent;
    border-radius: 50%;
    animation: hdkn-spin 0.8s linear infinite;
}

@keyframes hdkn-spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   MESSAGES
   ========================================================================== */

.hdkn-message {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: var(--hdkn-radius);
}

.hdkn-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.hdkn-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ==========================================================================
   MULTI-STEP
   ========================================================================== */

.hdkn-progress-bar {
    margin-bottom: 30px;
}

.hdkn-progress-track {
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-bottom: 20px;
}

.hdkn-progress-fill {
    height: 100%;
    background: var(--hdkn-primary);
    border-radius: 2px;
    transition: width 0.3s;
}

.hdkn-progress-steps {
    display: flex;
    justify-content: space-between;
}

.hdkn-progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.hdkn-step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
}

.hdkn-progress-step.active .hdkn-step-number,
.hdkn-progress-step.completed .hdkn-step-number {
    background: var(--hdkn-primary);
    color: #fff;
}

.hdkn-progress-step .hdkn-step-title {
    font-size: 13px;
    color: #999;
}

.hdkn-progress-step.active .hdkn-step-title,
.hdkn-progress-step.completed .hdkn-step-title {
    color: var(--hdkn-text);
    font-weight: 500;
}

/* Masquer le titre d'une étape spécifique */
.hdkn-progress-step.hdkn-hide-title .hdkn-step-title {
    display: none;
}

.hdkn-form-step {
    display: none;
}

.hdkn-form-step.active {
    display: block;
    animation: hdkn-fadeIn 0.3s ease;
}

@keyframes hdkn-fadeIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.hdkn-step-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.hdkn-step-header .hdkn-step-title {
    font-size: 20px;
    margin: 0 0 5px 0;
}

.hdkn-step-description {
    color: var(--hdkn-text-light);
    margin: 0;
}

.hdkn-step-navigation {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.hdkn-step-navigation .hdkn-btn:only-child {
    margin-left: auto;
}

.hdkn-form-footer {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* ==========================================================================
   STYLES PRESETS
   ========================================================================== */

.hdkn-form-style-minimal input[type="text"],
.hdkn-form-style-minimal input[type="email"],
.hdkn-form-style-minimal input[type="tel"],
.hdkn-form-style-minimal select,
.hdkn-form-style-minimal textarea {
    border: none;
    border-bottom: 2px solid #e0e0e0;
    border-radius: 0;
    padding: 10px 0;
    background: transparent;
}

.hdkn-form-style-minimal input:focus,
.hdkn-form-style-minimal select:focus,
.hdkn-form-style-minimal textarea:focus {
    box-shadow: none;
    border-bottom-color: var(--hdkn-primary);
}

.hdkn-form-wrapper.hdkn-style-modern {
    background: linear-gradient(135deg, #f5f7fa, #e4e8ec);
    padding: 30px;
    border-radius: 12px;
}

.hdkn-form-wrapper.hdkn-style-boxed {
    background: #fff;
    padding: 35px;
    border: 2px solid #e0e0e0;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .hdkn-field.hdkn-width-75,
    .hdkn-field.hdkn-width-66,
    .hdkn-field.hdkn-width-50,
    .hdkn-field.hdkn-width-33,
    .hdkn-field.hdkn-width-25 {
        width: 100%;
    }
    
    .hdkn-step-navigation {
        flex-direction: column;
    }
    
    .hdkn-step-navigation .hdkn-btn {
        width: 100%;
    }
    
    .hdkn-radio-group,
    .hdkn-checkbox-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* ==========================================================================
   ESTIMATION DE PRIX
   ========================================================================== */

.hdkn-price-estimate {
    background: #fff;
    border: 2px solid var(--price-header-bg, #0073aa);
    border-radius: var(--hdkn-radius, 4px);
    margin: 20px 0;
    overflow: hidden;
}

.hdkn-price-header {
    background: var(--price-header-bg, #0073aa);
    padding: 12px 15px;
}

.hdkn-price-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--price-header-text, #ffffff);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
}

.hdkn-price-items {
    padding: 12px 15px;
    max-height: 200px;
    overflow-y: auto;
    background: #ffffff;
}

.hdkn-price-empty {
    color: var(--price-item-text, #666666);
    font-style: italic;
    font-size: 14px;
    padding: 8px 0;
}

.hdkn-price-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed #ddd;
    font-size: 14px;
}

.hdkn-price-item:last-child {
    border-bottom: none;
}

.hdkn-price-item-label {
    color: var(--price-item-text, #333333);
    flex: 1;
    padding-right: 10px;
    font-weight: 500;
}

.hdkn-price-item-value {
    color: var(--price-total-color, #0073aa);
    font-weight: 600;
    white-space: nowrap;
}

.hdkn-price-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-top: 2px solid var(--price-header-bg, #0073aa);
}

.hdkn-price-total-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--price-item-text, #333333);
    text-transform: uppercase;
}

.hdkn-price-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--price-total-color, #0073aa);
}

.hdkn-price-amount {
    transition: all 0.3s ease;
}

.hdkn-price-suffix {
    font-size: 18px;
    margin-left: 3px;
}

.hdkn-price-estimate.updating .hdkn-price-amount {
    opacity: 0.5;
}

@media (max-width: 600px) {
    .hdkn-price-items {
        max-height: 150px;
    }
}
