/**
 * KPS Cart — Estilos Frontend
 * assets/css/kps-cart.css
 *
 * Estilos para:
 *  - [kps_cart_icon] shortcode: icono + badge + dropdown mini-carrito
 *  - Botón .kps-download-btn (productos gratuitos)
 */

/* ============================================================
   WRAPPER PRINCIPAL
   ============================================================ */
.kps-cart-wrapper {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

/* ============================================================
   ICONO
   ============================================================ */
.kps-cart-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: opacity 0.15s ease;
    outline: none;
}
.kps-cart-icon-wrap:hover,
.kps-cart-icon-wrap:focus {
    opacity: 0.8;
}

/* Imagen personalizada */
.kps-cart-icon-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    display: block;
}

/* SVG por defecto */
.kps-cart-icon-svg {
    width: 30px;
    height: 30px;
    color: #333;
    display: block;
}

/* ============================================================
   BADGE / CONTADOR
   ============================================================ */
.kps-cart-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e74c3c;  /* sobreescrito inline desde PHP/shortcode */
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    padding: 0 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    transition: background 0.25s ease, transform 0.15s ease;
    /* Oculto cuando count=0 */
    display: none;
}

/* Visible solo cuando hay items */
.kps-cart-badge[data-count]:not([data-count="0"]) {
    display: block;
    animation: kpsBadgePop 0.25s ease;
}

@keyframes kpsBadgePop {
    0%   { transform: scale(0.6); }
    70%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ============================================================
   DROPDOWN CARRITO
   ============================================================ */
.kps-cart-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 290px;
    max-width: 360px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.13);
    z-index: 99999;
    /* Flecha decorativa */
}
.kps-cart-dropdown::before {
    content: '';
    position: absolute;
    top: -7px;
    right: 14px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    border-top: 1px solid #e2e8f0;
    transform: rotate(45deg);
}

/* Visible al hover (modo hover) */
.kps-open-on-hover:hover .kps-cart-dropdown,
.kps-open-on-hover.is-open .kps-cart-dropdown {
    display: block;
    animation: kpsDropdownIn 0.2s ease;
}

/* Visible al clic (modo click) */
.kps-open-on-click.is-open .kps-cart-dropdown {
    display: block;
    animation: kpsDropdownIn 0.2s ease;
}

@keyframes kpsDropdownIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   INTERIOR DEL DROPDOWN
   ============================================================ */
.kps-cart-dropdown-inner {
    padding: 14px 16px;
}

/* Mensaje carrito vacío */
.kps-cart-empty {
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    padding: 18px 0 10px;
    margin: 0;
}
.kps-cart-empty::before {
    content: '';
    display: block;
    width: 36px;
    height: 36px;
    margin: 0 auto 8px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='1.5'%3E%3Ccircle cx='9' cy='21' r='1'/%3E%3Ccircle cx='20' cy='21' r='1'/%3E%3Cpath d='M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* Lista de productos en mini-carrito (WooCommerce la llena) */
.kps-cart-items {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    max-height: 260px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #e2e8f0 transparent;
}
.kps-cart-items::-webkit-scrollbar { width: 4px; }
.kps-cart-items::-webkit-scrollbar-track { background: transparent; }
.kps-cart-items::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }

/* Estilo de cada item (WooCommerce añade <li.woocommerce-mini-cart-item>) */
.kps-cart-items .woocommerce-mini-cart-item,
.kps-cart-items li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}
.kps-cart-items .woocommerce-mini-cart-item:last-child,
.kps-cart-items li:last-child {
    border-bottom: none;
}
.kps-cart-items img {
    width: 46px;
    height: 46px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}
.kps-cart-items .remove {
    color: #ef4444;
    font-size: 16px;
    line-height: 1;
    margin-left: auto;
    text-decoration: none;
}

/* Total del mini-carrito */
.kps-cart-items .woocommerce-mini-cart__total,
.woocommerce-mini-cart__total {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 13px;
    padding-top: 6px;
    border-top: 1px solid #f1f5f9;
    margin-top: 4px;
}

/* Ocultar botones nativos de WooCommerce dentro de nuestro dropdown
   (woocommerce_mini_cart() los inyecta; usamos los nuestros) */
.kps-cart-dropdown .woocommerce-mini-cart__buttons {
    display: none !important;
}

/* ============================================================
   ACCIONES (Ver carrito / Finalizar compra)
   ============================================================ */
.kps-cart-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.kps-cart-btn-view,
.kps-cart-btn-checkout {
    flex: 1 1 0;
    text-align: center;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none !important;
    transition: filter 0.15s;
    cursor: pointer;
}
.kps-cart-btn-view {
    background: #f8fafc;
    color: #334155 !important;   /* sobreescrito por inline CSS con badge color */
    border: 1px solid #e2e8f0;   /* sobreescrito por inline CSS con badge color */
    transition: background 0.15s, color 0.15s;
}
.kps-cart-btn-view:hover {
    background: #f1f5f9;
    filter: none;
}

.kps-cart-btn-checkout {
    background: #0f7c4c;         /* sobreescrito por inline CSS con badge color */
    color: #fff !important;
    border: 1px solid #0f7c4c;   /* sobreescrito por inline CSS con badge color */
}
.kps-cart-btn-checkout:hover { filter: brightness(0.88); }

/* ============================================================
   BOTÓN "DESCARGAR" (productos precio 0)
   ============================================================ */
.kps-download-btn {
    background: #16a34a !important; /* sobreescrito por inline CSS con badge color */
    color: #fff !important;
    border-color: #16a34a !important;
    border-radius: 4px;
    padding: 0.6em 1.2em;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: background 0.15s, filter 0.15s;
    cursor: pointer;
}
.kps-download-btn:hover {
    filter: brightness(0.88);
    color: #fff !important;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
    .kps-cart-dropdown {
        right: auto;
        left: 0;
        min-width: 260px;
    }
    .kps-cart-dropdown::before {
        right: auto;
        left: 14px;
    }
}
