/* ================================
   Calendario de Envíos - v1.5
   Autor: Jonas Gonzalez
   ================================ */

/* Layout principal de 2 columnas */
#ce-cart-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 40px;
    margin: 40px auto;
    max-width: 1200px;
    padding: 0 20px;
    align-items: start;
}

/* COLUMNA IZQUIERDA: Productos del carrito */
.ce-cart-products {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.05);
}

/* Cabecera de la columna de productos: título + papelera global */
.ce-cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.ce-cart-products h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 0;
    color: #1d2327;
}

/* Botón global vaciar carrito */
#ce-empty-cart {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid #ff8c00;
    color: #ff8c00;
    font-size: 13px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.25s ease;
}

#ce-empty-cart:hover {
    background: #ff8c00;
    color: #fff;
}

/* Tabla de productos */
.ce-products-table {
    width: 100%;
    border-collapse: collapse;
}

.ce-products-table thead th {
    text-align: left;
    padding: 12px 15px;
    border-bottom: 2px solid #e0e0e0;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.ce-products-table tbody td {
    padding: 20px 15px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.ce-product-info {
    display: flex;
    gap: 15px;
    align-items: center;
}

.ce-product-thumbnail {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

.ce-product-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.ce-product-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ce-product-details strong {
    font-size: 15px;
    color: #1d2327;
}

.ce-product-price {
    color: #ff8c00;
    font-weight: 600;
    font-size: 14px;
}

/* Cantidad */
.ce-product-quantity {
    text-align: center;
}

.ce-quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ================================
   ESTILO ACTUALIZADO – CONTROLES DE CANTIDAD
   ================================ */

#ce-cart-layout .ce-quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 10px;
}

/* Botones + y – minimalistas */
#ce-cart-layout .ce-qty-minus,
#ce-cart-layout .ce-qty-plus {
    width: 32px;
    height: 32px;
    border: 1px solid #ff8c00;
    background: transparent;
    color: #ff8c00;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.25s ease;
}

#ce-cart-layout .ce-qty-minus:hover,
#ce-cart-layout .ce-qty-plus:hover {
    background: #ff8c00;
    color: #fff;
}

/* Input central */
#ce-cart-layout .ce-quantity-controls input[type=number] {
    width: 50px !important;
    text-align: center;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    padding: 5px;
    font-size: 15px;
    background: #fff;
    color: #1d2327;
    box-shadow: none !important;
    appearance: textfield;
}

#ce-cart-layout .ce-quantity-controls input[type=number]::-webkit-inner-spin-button,
#ce-cart-layout .ce-quantity-controls input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Papelera por fila */
#ce-cart-layout .ce-remove-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #bbb;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

#ce-cart-layout .ce-remove-item:hover {
    color: #c92a2a;
    background: transparent;
}


.ce-qty-minus,
.ce-qty-plus {
    width: 30px;
    height: 30px;
    border: 1px solid #ccc;
    background: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ce-qty-minus:hover,
.ce-qty-plus:hover {
    background: #e9e9e9;
    border-color: #999;
}

.ce-quantity-controls input {
    width: 50px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px;
    font-size: 14px;
}

/* Contenedor subtotal + papelera en celda de total */
.ce-total-with-remove {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.ce-product-total {
    text-align: right;
    font-weight: 600;
    font-size: 16px;
    color: #1d2327;
}

/* COLUMNA DERECHA: Calendario y resumen */
#ce-calendar-wrapper,
.ce-calendar-box {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.05);
    position: sticky;
    top: 30px;
    height: fit-content;
}

#ce-calendar-wrapper h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #1d2327;
}

.ce-calendar-fields {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.ce-field {
    display: flex;
    flex-direction: column;
}

.ce-field label {
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
    font-size: 14px;
}

.ce-calendar-box select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fdfdfd;
    font-size: 14px;
}

/* Ocultar el input original */
#ce-date {
    display: none;
}

/* Estilos del calendario Flatpickr */
.flatpickr-calendar {
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
    margin-bottom: 20px;
}

.flatpickr-months {
    background: transparent !important;
}

.flatpickr-current-month {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #333 !important;
}

.flatpickr-weekdays {
    background: transparent !important;
}

.flatpickr-weekday {
    color: #666 !important;
    font-weight: 600 !important;
}

/* Días del calendario */
.flatpickr-day {
    border-radius: 0 !important;
    font-weight: 500 !important;
    border: none !important;
}

.flatpickr-day.enabled {
    background-color: transparent !important;
    color: #2c2c54 !important;
    font-weight: 600 !important;
    cursor: pointer !important;
}

.flatpickr-day.enabled:hover {
    background-color: #f0f0f0 !important;
    color: #2c2c54 !important;
}

.flatpickr-day.disabled,
.flatpickr-day.flatpickr-disabled {
    background-color: transparent !important;
    color: #2c2c54 !important;
    opacity: 0.3 !important;
    cursor: not-allowed !important;
}

.flatpickr-day.selected,
.flatpickr-day.selected.enabled {
    background-color: #007bff !important;
    color: white !important;
    border-radius: 6px !important;
    font-weight: bold !important;
}

.flatpickr-day.today {
    border: none !important;
}

.flatpickr-day.today.enabled {
    background-color: transparent !important;
    color: #2c2c54 !important;
    font-weight: 600 !important;
}

.flatpickr-day.today.selected {
    background-color: #007bff !important;
    color: white !important;
}

/* Mensaje de estado */
#ce-calendar-message {
    margin: 15px 0;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 4px;
}

#ce-calendar-message.success {
    color: #2e7d32;
    background: #e8f5e9;
}

#ce-calendar-message.error {
    color: #c92a2a;
    background: #ffebee;
}

/* Resumen del carrito */
.ce-cart-summary {
    border-top: 1px solid #e0e0e0;
    padding-top: 20px;
    margin-top: 20px;
}

.ce-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 18px;
}

.ce-summary-row strong {
    font-size: 22px;
    color: #1d2327;
}

.ce-tax-note {
    font-size: 13px;
    color: #666;
    margin-bottom: 20px;
}

.ce-tax-note a {
    color: #ff8c00;
    text-decoration: none;
}

.ce-tax-note a:hover {
    text-decoration: underline;
}

/* Botones principales */
.ce-button-primary,
.ce-button-secondary {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.ce-button-primary {
    background: #ff8c00;
    color: #fff;
}

.ce-button-primary:hover {
    background: #e67e00;
}

.ce-button-secondary {
    background: #fff;
    color: #ff8c00;
    border: 2px solid #ff8c00;
}

.ce-button-secondary:hover {
    background: #fff5e6;
}


tr {
    border-top: solid 1px #ccc !important;
}


/* ================================
   Override para input de cantidad (estrecho y limpio)
   ================================ */

/* Prioridad total dentro del plugin */
#ce-cart-layout .ce-quantity-controls input[type=number] {
    width: 50px !important;      /* 🔹 Controla el ancho exacto */
    text-align: center !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    padding: 5px !important;
    background: #fff !important;
    font-size: 14px !important;
    box-shadow: none !important;
    appearance: textfield !important; /* 🔹 elimina flechas */
}

/* 🔹 Oculta las flechas del input number en Chrome, Edge, Safari */
#ce-cart-layout .ce-quantity-controls input[type=number]::-webkit-outer-spin-button,
#ce-cart-layout .ce-quantity-controls input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* 🔹 Oculta las flechas en Firefox */
#ce-cart-layout .ce-quantity-controls input[type=number] {
    -moz-appearance: textfield;
}

/* 🔹 Botones “+” y “–” más cerca del input */
#ce-cart-layout .ce-quantity-controls {
    gap: 6px !important;
}


/* ================================
   Override total de estilos WooCommerce / Elementor
   ================================ */

/* Elimina bordes y fondos heredados dentro del calendario de envíos */
#ce-cart-layout table,
#ce-cart-layout table th,
#ce-cart-layout table td {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* Forzar fondo blanco solo en el contenedor */
#ce-cart-layout .ce-cart-products,
#ce-cart-layout .ce-products-table {
    background: #fff !important;
}

/* Forzar filas sin alternancia de color */
#ce-cart-layout .ce-products-table tbody tr:nth-child(odd) td,
#ce-cart-layout .ce-products-table tbody tr:nth-child(odd) th,
#ce-cart-layout .ce-products-table tbody tr:nth-child(even) td,
#ce-cart-layout .ce-products-table tbody tr:nth-child(even) th {
    background: #fff !important;
}

/* Evitar herencias visuales de WooCommerce (líneas o sombreados) */
#ce-cart-layout .ce-products-table td,
#ce-cart-layout .ce-products-table th {
    border: none !important;
    box-shadow: none !important;
    background-color: #fff !important;
}

/* Asegurar que WooCommerce no meta sus estilos en la tabla */
.woocommerce #ce-cart-layout table.shop_table td,
.woocommerce #ce-cart-layout table.shop_table th {
    border: none !important;
    background: #fff !important;
    box-shadow: none !important;
}


/* ================================
   Estado de carga del carrito
   ================================ */

@keyframes ce-spin {
    to { transform: rotate(360deg); }
}

.ce-spinner {
    animation: ce-spin 0.7s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

.ce-cart-products.ce-loading {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

/* Responsive */
@media (max-width: 768px) {
    #ce-cart-layout {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 0 15px;
        margin: 20px auto;
    }

    #ce-calendar-wrapper {
        position: static;
        top: 0;
    }

    /* Evita desbordamiento horizontal de la tabla */
    .ce-cart-products {
        overflow-x: auto;
        padding: 15px;
    }

    .ce-products-table {
        width: 100%;
        min-width: 0;
    }

    /* Tabla a layout de bloque: oculta thead y apila celdas */
    .ce-products-table thead {
        display: none;
    }

    .ce-products-table tbody tr {
        display: block;
        padding: 12px 0;
        border-bottom: 1px solid #f0f0f0;
    }

    .ce-products-table tbody td {
        display: block;
        text-align: left;
        padding: 4px 0;
        border-bottom: none !important;
    }

    /* Info de producto: thumbnail + nombre en fila */
    .ce-product-info {
        flex-direction: row;
        align-items: center;
    }

    .ce-product-thumbnail {
        width: 60px;
        height: 60px;
    }

    /* Cantidad y total alineados a la izquierda */
    .ce-product-quantity {
        text-align: left;
    }

    .ce-product-total {
        text-align: left;
    }

    .ce-total-with-remove {
        justify-content: flex-start;
    }
}
