/* WooDeliverySlots Pro - Frontend CSS - Thème Bardibois */

:root {
    --wcds-primary: #E66F27;
    --wcds-primary-dark: #C55A1B;
    --wcds-primary-light: #FEF6F0;
    --wcds-success: #2E7D32;
    --wcds-white: #FFFFFF;
    --wcds-bg: #FDFBF7;
    --wcds-border: #E5DFD3;
    --wcds-text: #2C2416;
    --wcds-text-light: #5C5245;
    --wcds-text-muted: #8C8577;
    --wcds-shadow: 0 4px 12px rgba(44, 36, 22, 0.1);
    --wcds-radius: 12px;
    --wcds-transition: all 0.2s ease;
}

/* Delivery Row */
.wcds-delivery-row {
    background: transparent !important;
}

.wcds-delivery-row td {
    padding: 0 !important;
}

/* Picker Container */
.wcds-pro-picker {
    background: var(--wcds-white);
    border: 2px solid var(--wcds-border);
    border-radius: var(--wcds-radius);
    padding: 24px;
    margin: 20px 0;
    box-shadow: var(--wcds-shadow);
    position: relative;
    z-index: 50;
}

/* Picker Header */
.wcds-picker-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--wcds-border);
}

.wcds-picker-icon {
    font-size: 26px;
    line-height: 1;
}

.wcds-picker-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--wcds-text);
}

/* Picker Body */
.wcds-picker-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Picker Field */
.wcds-picker-field {
    display: flex;
    flex-direction: column;
    position: relative !important;
    z-index: 100 !important;
}

.wcds-picker-field label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--wcds-text);
    margin-bottom: 8px;
}

.wcds-picker-field label .dashicons {
    color: var(--wcds-primary);
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Date Input */
.wcds-datepicker {
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 500;
    color: var(--wcds-text);
    background: var(--wcds-white);
    border: 2px solid var(--wcds-border);
    border-radius: 8px;
    transition: var(--wcds-transition);
    cursor: pointer;
}

.wcds-datepicker:hover {
    border-color: var(--wcds-primary);
}

.wcds-datepicker:focus {
    outline: none;
    border-color: var(--wcds-primary);
    box-shadow: 0 0 0 3px rgba(230, 111, 39, 0.15);
}

.wcds-datepicker.wcds-selected {
    border-color: var(--wcds-success);
    background-color: #F0FDF4;
}

/* Calendar Container */
.wcds-calendar {
    position: absolute !important;
    background: var(--wcds-white);
    border: 2px solid var(--wcds-border);
    border-radius: var(--wcds-radius);
    box-shadow: 0 8px 24px rgba(44, 36, 22, 0.2);
    padding: 16px;
    z-index: 9999 !important;
    width: 300px;
    top: 100% !important;
    left: 0 !important;
    margin-top: 8px;
    display: none;
}

.wcds-calendar-inner {
    display: flex;
    flex-direction: column;
}

/* Calendar Month */
.wcds-cal-month {
    width: 100%;
}

/* Calendar Header */
.wcds-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 12px 0;
    border-bottom: 1px solid var(--wcds-border);
    margin-bottom: 12px;
    gap: 8px;
}

.wcds-cal-month-title {
    flex: 1;
    font-weight: 700;
    font-size: 15px;
    color: var(--wcds-primary);
    text-align: center;
    text-transform: capitalize;
    line-height: 1.2;
}

/* Navigation Buttons */
.wcds-cal-nav-btn {
    background: var(--wcds-primary);
    color: var(--wcds-white);
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: var(--wcds-transition);
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.wcds-cal-nav-btn:hover:not(.disabled) {
    background: var(--wcds-primary-dark);
}

.wcds-cal-nav-btn:active:not(.disabled) {
    transform: scale(0.95);
}

.wcds-cal-nav-btn.disabled {
    background: var(--wcds-border);
    color: var(--wcds-text-muted);
    cursor: not-allowed;
}

/* Days Header */
.wcds-cal-days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 6px;
}

.wcds-cal-day-name {
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--wcds-text-muted);
    padding: 4px 0;
    text-transform: uppercase;
}

/* Days Grid */
.wcds-cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.wcds-cal-date {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--wcds-transition);
    border: 1px solid transparent;
    background: var(--wcds-bg);
    color: var(--wcds-text);
    min-height: 32px;
    max-height: 36px;
}

.wcds-cal-date:not(.disabled):not(.empty):hover {
    background: var(--wcds-primary-light);
    border-color: var(--wcds-primary);
}

.wcds-cal-date.disabled {
    background: #F5F5F5;
    color: #CCCCCC;
    cursor: not-allowed;
}

.wcds-cal-date.empty {
    background: transparent;
    cursor: default;
}

.wcds-cal-date.today {
    border-color: var(--wcds-primary);
    font-weight: 700;
    background: var(--wcds-primary-light);
}

.wcds-cal-date.selected {
    background: var(--wcds-primary);
    color: var(--wcds-white);
    font-weight: 700;
    border-color: var(--wcds-primary);
}

/* Select (for slots) */
.wcds-select {
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 500;
    color: var(--wcds-text);
    background: var(--wcds-white);
    border: 2px solid var(--wcds-border);
    border-radius: 8px;
    transition: var(--wcds-transition);
    cursor: pointer;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23E66F27" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 22px;
}

.wcds-select:hover {
    border-color: var(--wcds-primary);
}

.wcds-select:focus {
    outline: none;
    border-color: var(--wcds-primary);
    box-shadow: 0 0 0 3px rgba(230, 111, 39, 0.15);
}

.wcds-select:disabled {
    background-color: #F5F5F5;
    cursor: not-allowed;
    color: var(--wcds-text-muted);
}

.wcds-select.wcds-selected {
    border-color: var(--wcds-success);
    background-color: #F0FDF4;
}

.wcds-select option {
    padding: 10px;
    font-size: 15px;
}

/* Success Check */
.wcds-success-check {
    color: var(--wcds-success);
    margin-top: 8px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Loading State */
.wcds-select.wcds-loading {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="none" stroke="%23E66F27" stroke-width="2"><animateTransform attributeName="transform" type="rotate" from="0 12 12" to="360 12 12" dur="1s" repeatCount="indefinite"/></circle></svg>');
    background-size: 20px;
    background-position: right 12px center;
}

/* Success State */
.wcds-picker-field.wcds-success label {
    color: var(--wcds-success);
}

.wcds-picker-field.wcds-success .wcds-select {
    border-color: var(--wcds-success);
    background-color: #F0FDF4;
}

/* Error Message */
.wcds-error-message {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 10px 14px;
    background: #FEE2E2;
    color: #991B1B;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}

.wcds-error-message::before {
    content: '⚠️';
    font-size: 16px;
}

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

@media (max-width: 768px) {
    .wcds-pro-picker {
        padding: 16px;
        margin: 16px 0;
    }
    
    .wcds-picker-header {
        margin-bottom: 16px;
        padding-bottom: 12px;
    }
    
    .wcds-picker-header h3 {
        font-size: 16px;
    }
    
    .wcds-picker-icon {
        font-size: 22px;
    }
    
    .wcds-picker-body {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .wcds-datepicker,
    .wcds-select {
        padding: 12px 14px;
        font-size: 14px;
    }
    
    /* Calendrier en position fixe centrée sur mobile */
    .wcds-calendar {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%);
        width: 290px;
        max-width: calc(100vw - 40px);
        margin: 0;
        box-shadow: 0 10px 40px rgba(44, 36, 22, 0.3);
        z-index: 10000 !important;
    }
    
    .wcds-cal-date {
        font-size: 12px;
        min-height: 30px;
        max-height: 34px;
    }
    
    .wcds-cal-nav-btn {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    
    .wcds-cal-month-title {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .wcds-pro-picker {
        padding: 12px;
        margin: 12px 0;
        border-radius: 8px;
    }
    
    .wcds-picker-header h3 {
        font-size: 15px;
    }
    
    .wcds-calendar {
        padding: 12px;
        width: 280px;
    }
    
    .wcds-cal-date {
        font-size: 11px;
        min-height: 28px;
        max-height: 32px;
    }
    
    .wcds-cal-day-name {
        font-size: 9px;
    }
    
    .wcds-cal-month-title {
        font-size: 13px;
    }
    
    .wcds-cal-nav-btn {
        width: 26px;
        height: 26px;
        font-size: 10px;
    }
}

/* Overlay pour mobile */
/* IMPORTANT (bug mobile résolu 07/2026) : le calendrier vit DANS .wcds-pro-picker
   (z-index:50) et .wcds-picker-field (z-index:100), qui créent des stacking contexts.
   Son z-index global est donc PLAFONNÉ à 50, quel que soit son propre z-index.
   L'overlay étant attaché à <body>, un z-index de 9999 le plaçait AU-DESSUS du
   calendrier sur téléphone : chaque tap touchait le voile (qui referme le calendrier)
   → impossible de choisir une date. On place donc le voile SOUS le plafond de 50 :
   il grise toujours la page, mais laisse le calendrier cliquable. */
.wcds-calendar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(44, 36, 22, 0.5);
    z-index: 45;
}

.wcds-calendar-overlay.active {
    display: block;
}

/* Fix pour éviter le débordement */
.wcds-picker-field {
    position: relative !important;
    z-index: 100 !important;
    overflow: visible;
}

/* Le champ DATE (1er de la liste) doit dominer son frère "Créneau horaire" :
   les deux sont des stacking contexts frères à z-index égal, et le frère étant
   après dans le DOM, il se dessinait AU-DESSUS du calendrier ouvert (libellé et
   menu déroulant visibles à travers le calendrier sur mobile). */
.wcds-picker-body .wcds-picker-field:first-child {
    z-index: 300 !important;
}

/* S'assurer que le calendrier est au-dessus de tout */
.wcds-calendar.active,
.wcds-calendar[style*="display: block"] {
    z-index: 10001 !important;
}
