/* ============================================================
 * Carrito Flotante — Icono + Mini-cart lateral
 *
 * Se carga en todo el frontend via inc/cart.php.
 * El icono aparece en la esquina inferior derecha con un badge
 * que muestra la cantidad de items. Al hacer click se despliega
 * un panel lateral con los productos del carrito.
 * ============================================================ */

/* ── Icono flotante ── */
.cb-cart-float {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99990;
    display: none; /* JS lo muestra cuando hay al menos 1 item */
}

.cb-cart-float.is-visible {
    display: flex;
}

.cb-cart-float__trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: #0F172A;
    color: #FFFFFF;
    border: 0;
    border-radius: 50%;
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.25);
    cursor: pointer;
    font-size: 22px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.cb-cart-float__trigger:hover,
.cb-cart-float__trigger:focus-visible {
    transform: scale(1.08);
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.35);
    outline: 3px solid #1456FF;
    outline-offset: 3px;
}

.cb-cart-float__trigger:active {
    transform: scale(0.96);
}

.cb-cart-float__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: #EF4444;
    color: #FFFFFF;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.40);
    animation: cb-cart-badge-pop 0.3s ease;
}

@keyframes cb-cart-badge-pop {
    0%   { transform: scale(0.4); opacity: 0; }
    70%  { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

/* ── Panel lateral (mini-cart) ── */
.cb-cart-float__overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 99985;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.cb-cart-float__overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.cb-cart-float__panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 92vw;
    height: 100vh;
    height: 100dvh;
    background: #FFFFFF;
    z-index: 99990;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: -8px 0 40px rgba(15, 23, 42, 0.18);
    overflow: hidden;
}

.cb-cart-float__panel.is-open {
    transform: translateX(0);
}

.cb-cart-float__panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #E5E7EB;
    flex-shrink: 0;
}

.cb-cart-float__panel-title {
    font-size: 17px;
    font-weight: 800;
    color: #0F172A;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cb-cart-float__panel-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #64748B;
    transition: background 0.15s ease, color 0.15s ease;
}

.cb-cart-float__panel-close:hover,
.cb-cart-float__panel-close:focus-visible {
    background: #F1F5F9;
    color: #0F172A;
    outline: 2px solid #1456FF;
    outline-offset: 2px;
}

/* ── Body del panel ── */
.cb-cart-float__panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
}

.cb-cart-float__empty {
    text-align: center;
    padding: 60px 20px;
    color: #94A3B8;
}

.cb-cart-float__empty i {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
    color: #CBD5E1;
}

.cb-cart-float__empty p {
    margin: 0;
    font-size: 15px;
    color: #64748B;
}

/* ── Item del carrito ── */
.cb-cart-float__item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #F1F5F9;
}

.cb-cart-float__item:last-child {
    border-bottom: 0;
}

.cb-cart-float__item-info {
    flex: 1;
    min-width: 0;
}

.cb-cart-float__item-name {
    font-size: 14px;
    font-weight: 700;
    color: #0F172A;
    margin: 0 0 4px;
    line-height: 1.3;
}

.cb-cart-float__item-meta {
    font-size: 12px;
    color: #64748B;
    margin: 0;
}

.cb-cart-float__item-price {
    font-size: 14px;
    font-weight: 800;
    color: #059669;
    white-space: nowrap;
}

.cb-cart-float__item-remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #94A3B8;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.cb-cart-float__item-remove:hover,
.cb-cart-float__item-remove:focus-visible {
    background: #FEF2F2;
    color: #EF4444;
    outline: 2px solid #EF4444;
    outline-offset: 2px;
}

/* ── Footer del panel ── */
.cb-cart-float__panel-footer {
    padding: 16px 24px;
    border-top: 1px solid #E5E7EB;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cb-cart-float__total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.cb-cart-float__total-label {
    font-size: 14px;
    color: #64748B;
    font-weight: 600;
}

.cb-cart-float__total-amount {
    font-size: 20px;
    font-weight: 900;
    color: #0F172A;
}

.cb-cart-float__actions {
    display: flex;
    gap: 8px;
}

.cb-cart-float__btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    border: 0;
    text-decoration: none !important;
    transition: all 0.15s ease;
    font-family: inherit;
    line-height: 1;
}

.cb-cart-float__btn--secondary {
    background: #F1F5F9;
    color: #334155;
}

.cb-cart-float__btn--secondary:hover,
.cb-cart-float__btn--secondary:focus-visible {
    background: #E2E8F0;
    color: #0F172A;
    outline: 2px solid #1456FF;
    outline-offset: 2px;
}

.cb-cart-float__btn--primary {
    background: #0F172A;
    color: #FFFFFF;
}

.cb-cart-float__btn--primary:hover,
.cb-cart-float__btn--primary:focus-visible {
    background: #1E293B;
    color: #FFFFFF;
    outline: 2px solid #1456FF;
    outline-offset: 2px;
}

.cb-cart-float__btn--primary:visited {
    color: #FFFFFF;
}

/* ── Animacion de agregado (pulse en el icono) ── */
.cb-cart-float__trigger.cb-cart-pulse {
    animation: cb-cart-pulse 0.4s ease;
}

@keyframes cb-cart-pulse {
    0%   { transform: scale(1); }
    25%  { transform: scale(1.2); }
    50%  { transform: scale(0.95); }
    75%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .cb-cart-float { bottom: 16px; right: 16px; }
    .cb-cart-float__trigger { width: 48px; height: 48px; font-size: 20px; }
    .cb-cart-float__panel { width: 100vw; max-width: 100vw; }
    .cb-cart-float__panel-header,
    .cb-cart-float__panel-body { padding-left: 20px; padding-right: 20px; }
    .cb-cart-float__panel-footer { padding: 14px 20px; }
}
