/**
 * Carrito de Reservas - Estilos Depurados y Optimizados
 * Incluye dependencias de tickets + dropdown completo
 * Versión: 2.1.0 - Sistema de variables dinámicas desde theme.json
 *
 * NOTA: Las variables principales (--calendario-*, --reservas-*) se generan
 * dinámicamente desde class-theme-integration.php basándose en el theme.json
 * del tema activo. Solo definimos aquí variables específicas del carrito.
 */

:root {
    /* Colores específicos del sistema de carrito (no dependen del tema) */
    --carrito-color-dependencia: #e74c3c;
    --carrito-color-restringido: #f39c12;

    /* Las siguientes variables se generan dinámicamente desde PHP,
     * pero las redeclaramos aquí con fallbacks universales por compatibilidad */
    --reservas-color-primary: var(--calendario-color-primary, var(--wp--preset--color--primary, #007cba));
    --reservas-color-secondary: var(--calendario-color-secondary, var(--wp--preset--color--secondary, #005a87));
    --reservas-color-text-primary: var(--calendario-color-text-primary, var(--wp--preset--color--foreground, #333333));
    --reservas-color-text-secondary: var(--calendario-color-text-secondary, var(--wp--preset--color--muted, #666666));
    --reservas-color-border: var(--calendario-color-border, var(--wp--preset--color--tertiary, #e1e5e9));
    --reservas-transition: var(--calendario-transition-normal, 0.3s ease);
    --reservas-shadow-lg: var(--reservas-shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.1));
    --reservas-font-family: var(--calendario-font-family, var(--wp--preset--font-family--body, system-ui, sans-serif));
}

/* ===== DEPENDENCIAS DE TICKETS ===== */

/* Estilos para tickets con dependencias restringidas */
.cart-item-has-dependents {
    position: relative;
}

.cart-item-has-dependents .remove::before {
    content: '🔒';
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--carrito-color-dependencia);
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item-dependency-notice {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 5px 0;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-item-dependency-notice::before {
    content: '⚠️';
    font-size: 14px;
}

/* ===== DROPDOWN DEL CARRITO - ESTILOS DEPURADOS ===== */

/* Reset específico para carrito - Evitar interferencias de selectores complejos */
.reservas-cart-shortcode, .reservas-cart-shortcode * {
    box-sizing: border-box;
}

.reservas-cart-shortcode h1, .reservas-cart-shortcode h2, .reservas-cart-shortcode h3, .reservas-cart-shortcode h4, .reservas-cart-shortcode h5, .reservas-cart-shortcode h6 {
    font-family: var(--reservas-font-family, 'Montserrat', sans-serif);
    margin: 0;
    padding: 0;
    font-weight: normal;
    line-height: 1.4;
}

.reservas-cart-shortcode p, .reservas-cart-shortcode div, .reservas-cart-shortcode span {
    margin: 0;
    padding: 0;
    font-family: var(--reservas-font-family, 'Montserrat', sans-serif);
}

/* Contenedor principal del dropdown */
.reservas-cart-shortcode {
    position: relative !important;
    display: inline-block;
}

/* Dropdown del carrito */
.reservas-cart-shortcode .cart-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 400px;
    max-width: 90vw;
    max-height: 500px;
    background: white !important;
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25) !important;
    border: 1px solid #E6E6E6;
    z-index: 10000 !important;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    margin-top: 8px;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

#cart-dropdown-shortcode[aria-hidden="false"], #cart-dropdown-shortcode.show, .reservas-cart-shortcode .cart-dropdown[aria-hidden="false"], .reservas-cart-shortcode .cart-dropdown.show {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
}

.reservas-cart-shortcode .cart-dropdown[aria-hidden="false"] *, .reservas-cart-shortcode .cart-dropdown.show * {
    pointer-events: auto !important;
}

/* Contenido del dropdown */
.cart-dropdown-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Estado vacío */
.cart-empty {
    padding: 40px 24px;
    text-align: center;
}

.cart-empty p {
    margin: 0;
    color: #666;
    font-style: italic;
}

/* Items del carrito */
.cart-items {
    padding: 16px 0;
}

.cart-dropdown-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 15px 20px !important;
    border-radius: 0 !important;
    margin: 0 !important;
    position: relative !important;
    transition: var(--reservas-transition, 0.3s ease) !important;
    color: white !important;
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
}

.cart-item-row {
    display: flex !important;
    align-items: flex-start !important;
    gap: 12px !important;
}

.cart-item-controls {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 12px !important;
}

.cart-item-date {
    font-size: 13px !important;
    color: rgba(255, 255, 255, 0.8) !important;
    margin-top: 4px !important;
}

.cart-dropdown-item:last-child {
    border-bottom: none !important;
}

.cart-dropdown-item:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Imagen del producto */
.cart-item-image {
    width: 50px !important;
    height: 40px !important;
    border-radius: 4px !important;
    overflow: hidden !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
    flex-shrink: 0 !important;
}

.cart-item-image img {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

/* Detalles del producto */
.cart-item-details {
    flex: 1 !important;
    min-width: 0 !important;
}

.reservas-cart-shortcode .cart-dropdown .cart-item-name {
    margin: 0 0 4px 0;
    font-size: var(--wp--preset--font-size--small, 16px) !important;
    font-weight: 600;
    color: white;
    font-family: var(--reservas-font-family, 'Montserrat', sans-serif);
    line-height: 1.3;
}

.cart-item-date {
    font-size: 12px !important;
    color: rgba(255, 255, 255, 0.8) !important;
    margin: 2px 0 6px 0 !important;
    font-style: normal !important;
    font-weight: 400 !important;
}

/* Override específico para el estilo inline del cart-item-date */
.cart-dropdown-item .cart-item-date[style*="color"] {
    color: rgba(255, 255, 255, 0.8) !important;
}

.cart-item-price {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.cart-item-price .price-unit {
    font-size: 12px;
    opacity: 0.8;
    font-weight: normal;
    margin-bottom: 2px;
}

.cart-item-price .price-total {
    font-size: 14px;
    font-weight: 700;
}

/* Controles de cantidad */
.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.quantity-btn,
.cart-quantity-btn {
    background: rgba(255, 255, 255, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: 6px !important;
    width: 28px !important;
    height: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    color: white !important;
    transition: var(--reservas-transition, 0.3s ease) !important;
    z-index: 10 !important;
    padding: 0 !important;
}

.quantity-btn:hover:not(:disabled),
.cart-quantity-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
}

.quantity-btn:disabled,
.cart-quantity-btn:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
}

.cart-quantity-btn svg,
.quantity-btn svg {
    display: block !important;
    width: 16px !important;
    height: 16px !important;
    pointer-events: none !important;
}

.cart-quantity-btn svg path,
.quantity-btn svg path {
    stroke: currentColor !important;
    color: white !important;
}

.quantity-input {
    width: 40px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Botón eliminar producto */
.cart-item-remove {
    border: none;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: var(--reservas-transition, 0.3s ease);
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    background: none; /* Sin background */
}

.cart-item-remove:hover {
    /* Sin hover background */
}

/* Footer del dropdown */
.cart-total {
    padding: 20px 24px;
    border-top: 1px solid var(--reservas-color-border, #E6E6E6);
    background-color: rgba(0, 171, 158, 0.02);
    text-align: center;
    font-size: 16px;
    color: var(--reservas-color-text-primary, #333333);
    margin: 0;
}

.cart-total strong {
    font-weight: 700;
    color: var(--reservas-color-primary, #00A99D);
}

/* Acciones del carrito */
.cart-actions {
    display: flex;
    gap: 12px;
    padding: 0 24px 20px;
}

.cart-actions .btn-view-cart, .cart-actions .btn-checkout {
    flex: 1;
    padding: 0 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--reservas-transition, 0.3s ease);
    border: 2px solid transparent;
    font-family: var(--reservas-font-family, 'Montserrat', sans-serif);
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.cart-actions .btn-view-cart:hover, .cart-actions .btn-checkout:hover {
    transform: translateY(0);
    text-decoration: none;
}

.btn-view-cart {
    background-color: transparent;
    color: var(--reservas-color-primary, #00A99D);
    border-color: var(--reservas-color-primary, #00A99D);
}

.btn-view-cart:hover {
    background-color: var(--reservas-color-primary, #00A99D);
    color: white;
}

.btn-checkout {
    background-color: var(--reservas-color-primary, #00A99D);
    color: white;
    border-color: var(--reservas-color-primary, #00A99D);
}

.btn-checkout:hover {
    background-color: var(--reservas-color-secondary, #38ac96);
    transform: translateY(-2px);
    box-shadow: var(--reservas-shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.1));
}

/* ===== COMPATIBILIDAD CON HEADER SOCIAL ===== */

/* Ajustar posición para header social */
.header-social .reservas-cart-shortcode {
    position: relative;
    overflow: visible !important;
    margin: 0 4px !important;
}

.header-social .cart-dropdown {
    right: 0;
    margin-top: 8px;
}

/* Asegurar que el badge del contador no se corte en el header social */
.header-social {
    overflow: visible;
}

/* ===== COMPATIBILIDAD CON WOOCOMMERCE ===== */

/* Estilos para página de carrito WooCommerce */
.woocommerce-cart .cart-item-has-dependents td {
    border-left: 3px solid var(--carrito-color-dependencia);
}

.woocommerce-cart .cart-item-dependency-notice {
    margin: 10px 0;
    grid-column: 1 / -1;
}

/* Estilos para WooCommerce Blocks */
.wc-block-cart-item.has-dependents {
    border-left: 3px solid var(--carrito-color-dependencia);
    background-color: rgba(231, 76, 60, 0.05);
}

.wc-block-cart-item .dependency-notice {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: 8px;
    border-radius: 4px;
    margin: 8px 0;
    font-size: 12px;
}

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

@media (max-width: 768px) {
    .cart-dropdown {
        width: 350px;
        right: -50px;
    }

    .cart-item {
        padding: 12px 16px;
    }

    .cart-total, .cart-actions {
        padding-left: 16px;
        padding-right: 16px;
    }

    .reservas-cart-shortcode {
        order: 1;
    }
}

@media (max-width: 480px) {
    .cart-dropdown {
        width: 320px;
        right: -80px;
    }

    .cart-actions {
        flex-direction: column;
    }

    .cart-actions .btn-view-cart, .cart-actions .btn-checkout {
        padding: 0 12px;
        font-size: 13px;
        height: 38px;
    }
}

/* ===== ESTILOS PARA WOOCOMMERCE BLOCKS (CARRITO Y CHECKOUT) ===== */

/* Imágenes de productos en WooCommerce Blocks */
.editor-styles-wrapper table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__image img,
table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__image img {
    background: var(--wp--preset--color--light-gray, #f0f0f0);
    border-radius: 8px;
    object-fit: cover;
    width: 100%;
    height: auto;
}

/* Contenedor de imagen en bloques */
.wc-block-cart-item__image {
    min-width: 80px;
    max-width: 100px;
}

/* Responsive para bloques */
@media (max-width: 768px) {
    .wc-block-cart-item__image {
        min-width: 60px;
        max-width: 80px;
    }
}
