/* ==========================================================================
   Fecha de Entrega para WooCommerce - Estilos mejorados con Recargos
   ========================================================================== */

/* Contenedor principal - estilo bloques */
.fewc-delivery-wrapper {
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    padding: 1.5rem !important;
    margin: 1.5rem 0 !important;
}

.fewc-delivery-wrapper h3 {
    margin: 0 0 1rem 0 !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: #1e1e1e !important;
    text-transform: none !important;
}

/* Campos de entrada */
.fewc-delivery-date-field,
.fewc-timeslot-field {
    width: 100% !important;
    padding: 0.75rem !important;
    font-size: 1rem !important;
    line-height: 1.5 !important;
    color: #1e1e1e !important;
    background-color: #fff !important;
    border: 1px solid #949494 !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    transition: border-color 0.2s ease !important;
    box-sizing: border-box !important;
}

/* Campo de fecha con espacio para icono */
.fewc-delivery-date-field {
    padding-right: 3rem !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23757575' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 20px 20px !important;
}

/* Placeholder */
.fewc-delivery-date-field::placeholder {
    color: #757575 !important;
    opacity: 1 !important;
}

.fewc-delivery-date-field::-webkit-input-placeholder {
    color: #757575 !important;
}

.fewc-delivery-date-field::-moz-placeholder {
    color: #757575 !important;
}

.fewc-delivery-date-field:-ms-input-placeholder {
    color: #757575 !important;
}

/* Estados hover y focus */
.fewc-delivery-date-field:hover,
.fewc-timeslot-field:hover {
    border-color: #1e1e1e !important;
}

.fewc-delivery-date-field:focus,
.fewc-timeslot-field:focus {
    outline: none !important;
    border-color: #000 !important;
    box-shadow: 0 0 0 1px #000 !important;
}

.fewc-delivery-date-field[readonly] {
    cursor: pointer !important;
    background-color: #fff !important;
}

/* Mensaje de recargo */
.fewc-surcharge-message {
    margin-top: 1rem !important;
    padding: 12px 16px !important;
    background: #fff3cd !important;
    border: 1px solid #ffc107 !important;
    border-radius: 4px !important;
    color: #856404 !important;
    font-size: 0.9rem !important;
    line-height: 1.5 !important;
    animation: fadeIn 0.3s ease !important;
}

.fewc-surcharge-message strong {
    font-weight: 600 !important;
    color: #664d03 !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estilos del Datepicker - Modernizado */
.ui-datepicker {
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    padding: 1rem !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
    width: auto !important;
    z-index: 99999 !important;
}

.ui-datepicker-header {
    background: #1e1e1e !important;
    color: #fff !important;
    border-radius: 6px !important;
    padding: 0.75rem !important;
    margin-bottom: 1rem !important;
    position: relative !important;
    border: none !important;
}

.ui-datepicker-title {
    text-align: center !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    line-height: 1.5 !important;
}

.ui-datepicker-prev,
.ui-datepicker-next {
    cursor: pointer !important;
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 4px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.2s ease !important;
    border: none !important;
}

.ui-datepicker-prev:hover,
.ui-datepicker-next:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

.ui-datepicker-prev {
    left: 0.5rem !important;
}

.ui-datepicker-next {
    right: 0.5rem !important;
}

.ui-datepicker-prev span,
.ui-datepicker-next span {
    display: none !important;
}

.ui-datepicker-prev::before,
.ui-datepicker-next::before {
    content: "" !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    border: solid #fff !important;
    border-width: 0 2px 2px 0 !important;
    padding: 4px !important;
}

.ui-datepicker-prev::before {
    transform: translate(-50%, -50%) rotate(135deg) !important;
}

.ui-datepicker-next::before {
    transform: translate(-50%, -50%) rotate(-45deg) !important;
}

/* Selector de mes y año */
.ui-datepicker-month,
.ui-datepicker-year {
    background: rgba(255, 255, 255, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: #fff !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    font-weight: 600 !important;
    margin: 0 4px !important;
}

.ui-datepicker-month option,
.ui-datepicker-year option {
    color: #1e1e1e !important;
    background: #fff !important;
}

/* Tabla del calendario */
.ui-datepicker table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-top: 0.5rem !important;
}

.ui-datepicker th {
    padding: 0.5rem 0 !important;
    text-align: center !important;
    font-weight: 600 !important;
    font-size: 0.75rem !important;
    color: #757575 !important;
    text-transform: uppercase !important;
}

.ui-datepicker td {
    padding: 2px !important;
    text-align: center !important;
    position: relative !important;
}

.ui-datepicker td a,
.ui-datepicker td span {
    display: block !important;
    padding: 0.5rem !important;
    text-decoration: none !important;
    border-radius: 6px !important;
    font-size: 0.875rem !important;
    transition: all 0.2s ease !important;
    font-weight: 500 !important;
    position: relative !important;
}

/* Días disponibles */
.ui-datepicker td a {
    background: #f5f5f5 !important;
    color: #1e1e1e !important;
    cursor: pointer !important;
}

.ui-datepicker td a:hover {
    background: #1e1e1e !important;
    color: #fff !important;
    transform: scale(1.05) !important;
}

/* Día seleccionado */
.ui-datepicker td a.ui-state-active {
    background: #1e1e1e !important;
    color: #fff !important;
    font-weight: 600 !important;
}

/* Día actual */
.ui-datepicker td a.ui-state-highlight {
    background: #e3f2fd !important;
    color: #1976d2 !important;
    font-weight: 600 !important;
    border: 2px solid #1976d2 !important;
}

/* Días deshabilitados */
.ui-datepicker td.ui-state-disabled span {
    color: #ccc !important;
    background: transparent !important;
    cursor: not-allowed !important;
}

/* Días de vacaciones */
.ui-datepicker td.fewc-holiday span {
    background: #ffebee !important;
    color: #c62828 !important;
    text-decoration: line-through !important;
}

/* Días no laborables */
.ui-datepicker td.fewc-disabled-day span {
    background: #fafafa !important;
    color: #bbb !important;
    text-decoration: line-through !important;
}

/* Días con recargo - NUEVO */
.ui-datepicker td.fewc-surcharge-day a {
    background: linear-gradient(135deg, #fff9e6 0%, #fffaeb 100%) !important;
    border: 2px solid #ffc107 !important;
    color: #856404 !important;
    font-weight: 600 !important;
    position: relative !important;
    padding-right: 1.8rem !important;
}

.ui-datepicker td.fewc-surcharge-day a:hover {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%) !important;
    border-color: #f59e0b !important;
    color: #664d03 !important;
}

/* Emoji en días con recargo */
.ui-datepicker td.fewc-surcharge-day a .surcharge-emoji {
    position: absolute !important;
    right: 4px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    font-size: 14px !important;
    line-height: 1 !important;
}

/* Tooltip para días con recargo */
.ui-datepicker td.fewc-surcharge-day {
    position: relative !important;
}

.ui-datepicker td.fewc-surcharge-day a:after {
    content: attr(title) !important;
    position: absolute !important;
    bottom: 100% !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: rgba(0, 0, 0, 0.8) !important;
    color: #fff !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.2s ease !important;
    margin-bottom: 5px !important;
}

.ui-datepicker td.fewc-surcharge-day a:hover:after {
    opacity: 1 !important;
}

/* Otros meses */
.ui-datepicker td.ui-datepicker-other-month {
    opacity: 0.3 !important;
}

/* Ocultar el botón de cerrar del datepicker */
.ui-datepicker-buttonpane {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .fewc-delivery-wrapper {
        padding: 1rem !important;
    }
    
    .ui-datepicker {
        font-size: 0.875rem !important;
        padding: 0.75rem !important;
        max-width: 320px !important;
    }
    
    .ui-datepicker td a,
    .ui-datepicker td span {
        padding: 0.4rem !important;
        font-size: 0.813rem !important;
    }
    
    .ui-datepicker td.fewc-surcharge-day a {
        padding-right: 1.5rem !important;
    }
    
    .ui-datepicker td.fewc-surcharge-day a .surcharge-emoji {
        font-size: 12px !important;
        right: 2px !important;
    }
    
    .ui-datepicker th {
        font-size: 0.688rem !important;
        padding: 0.4rem 0 !important;
    }
    
    .fewc-surcharge-message {
        font-size: 0.85rem !important;
        padding: 10px 12px !important;
    }
}

/* Asegurar que los campos tengan el mismo tamaño que los nativos */
.wc-block-checkout .fewc-delivery-date-field,
.wc-block-checkout .fewc-timeslot-field {
    height: auto !important;
    min-height: 48px !important;
}

/* Ajustes para móvil */
@media (max-width: 480px) {
    .fewc-delivery-date-field,
    .fewc-timeslot-field {
        font-size: 16px !important; /* Prevenir zoom en iOS */
        min-height: 44px !important;
    }
}

/* Animación de aparición */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fewc-delivery-wrapper {
    animation: fadeInUp 0.3s ease !important;
}

/* Estado de error */
.woocommerce-invalid .fewc-delivery-date-field,
.woocommerce-invalid .fewc-timeslot-field {
    border-color: #cc1818 !important;
}

/* Estado validado */
.woocommerce-validated .fewc-delivery-date-field,
.woocommerce-validated .fewc-timeslot-field {
    border-color: #1a8754 !important;
}

/* Compatibilidad con checkout por bloques */
.wp-block-woocommerce-checkout .fewc-delivery-date-wrapper {
    margin-bottom: 20px !important;
}

.wc-block-checkout__shipping-fields .fewc-delivery-date-wrapper {
    width: 100% !important;
}

/* Resaltar visualmente días con recargo */
.ui-datepicker td.fewc-surcharge-day a {
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2) !important;
}

.ui-datepicker td.fewc-surcharge-day a:hover {
    box-shadow: 0 4px 8px rgba(245, 158, 11, 0.3) !important;
}

/* ==========================================================================
   Checkout por bloques (v1.6.0) — bloque fecha-entrega-wc/delivery-date
   Recuadro con título fuera del campo, icono de calendario y franja debajo.
   Los colores heredan del tema (currentColor) para encajar en cualquier web.
   ========================================================================== */

.fewc-blocks-delivery {
    margin-top: 24px;
    padding: 24px;
    border: 1px solid rgba(0, 0, 0, 0.11);
    border-radius: 4px;
    background: #fff;
}

.fewc-blocks-delivery .fewc-blocks-field + .fewc-blocks-field,
.fewc-blocks-delivery .fewc-field-description + .fewc-blocks-field,
.fewc-blocks-delivery .fewc-surcharge-message + .fewc-blocks-field {
    margin-top: 16px;
}

.fewc-blocks-delivery .fewc-blocks-title,
.fewc-blocks-delivery .fewc-blocks-label {
    display: block;
    margin: 0 0 8px;
    font-weight: 600;
    line-height: 1.4;
    color: inherit;
}

.fewc-blocks-delivery .fewc-blocks-title {
    margin-bottom: 16px;
    font-size: 1em;
}

.fewc-blocks-delivery .fewc-blocks-label {
    font-size: 0.875em;
}

.fewc-blocks-delivery .fewc-required {
    color: #cc1818;
}

.fewc-blocks-delivery .fewc-blocks-control {
    position: relative;
}

.fewc-blocks-delivery .fewc-blocks-input {
    box-sizing: border-box;
    display: block;
    width: 100%;
    min-height: 3.125em;
    margin: 0;
    padding: 0.75em 1em;
    font-family: inherit;
    font-size: 1em;
    line-height: 1.4;
    color: inherit;
    background-color: #fff;
    border: 1px solid #8f8f8f;
    border-radius: 4px;
    box-shadow: none;
    cursor: pointer;
}

.fewc-blocks-delivery input.fewc-blocks-input {
    padding-right: 3em;
}

.fewc-blocks-delivery .fewc-blocks-input::placeholder {
    color: #757575;
    opacity: 1;
}

.fewc-blocks-delivery .fewc-blocks-input:focus {
    outline: 2px solid currentColor;
    outline-offset: -1px;
}

.fewc-blocks-delivery .fewc-blocks-icon {
    position: absolute;
    top: 50%;
    right: 1em;
    transform: translateY(-50%);
    pointer-events: none;
    opacity: 0.7;
}

.fewc-blocks-delivery .has-error .fewc-blocks-input {
    border-color: #cc1818;
}

.fewc-blocks-delivery .wc-block-components-validation-error {
    margin-top: 6px;
}

.fewc-blocks-delivery .fewc-field-description {
    margin: 8px 0 0;
    font-size: 0.875em;
    opacity: 0.8;
    line-height: 1.4;
}

.fewc-blocks-delivery .fewc-surcharge-message {
    margin-top: 12px !important;
}

@media (max-width: 480px) {
    .fewc-blocks-delivery {
        padding: 16px;
    }
}

/* El calendario debe quedar por encima de los bloques del checkout */
#ui-datepicker-div {
    z-index: 9999 !important;
}

/* Cambio de precios programado */
.fewc-blocks-delivery .fewc-price-change-notice,
.fewc-delivery-date-wrapper .fewc-price-change-notice {
    margin: 12px 0 0;
    padding: 10px 14px;
    font-size: 0.875em;
    line-height: 1.4;
    background: #f0f6fc;
    border-left: 3px solid #2271b1;
    border-radius: 2px;
}

.fewc-blocks-delivery .fewc-price-change-notice + .fewc-blocks-field {
    margin-top: 16px;
}

.fewc-next-price {
    display: block;
    margin-top: 2px;
    font-size: 0.8em;
    font-weight: normal;
    opacity: 0.85;
}
