/* =============================================================================
   cart-bar.css — Estilos del componente de barra lateral del carrito
   Módulo: app/modules/cart
   SRP: Única responsabilidad → estilos del cart-bar sidebar.
   ============================================================================= */

/* ── Overlay de carga ─────────────────────────────────────────────────────── */

.cb-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.cb-loading-content {
    background: #fff;
    padding: 20px 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.cb-loading-content p {
    margin: 0;
    font-weight: 600;
}

.cb-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: cb-spin 1s linear infinite;
}

@keyframes cb-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── Layout: header fijo, productos con scroll, botones pegados abajo ──────── */

.cart-bar {
    overflow: hidden !important;
}

.cart-bar > .product-area {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.cart-bar > .cart-bottom-area {
    flex-shrink: 0;
}

/* ── Tarjeta de ítem del carrito ────────────────────────────────────────────── */

.carrito-item-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    border: 1px solid #eee;
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 12px;
    background-color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    min-width: 0;
}

/* Imagen: columna izquierda de tamaño fijo */
.item-imagen {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
}

.item-imagen img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Detalles: columna derecha que ocupa el espacio restante */
.item-detalles {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.item-titulo {
    font-size: 13px;
    margin: 0 0 6px 0;
    color: inherit;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-word;
    max-width: 100%;
}

.item-sku,
.item-modalidad {
    font-size: 11px;
    color: #666;
    margin: 0;
    font-weight: 500;
    opacity: 0.95;
}

.item-precio-unitario {
    font-size: 13px;
    color: #0b5cff;
    font-weight: 700;
    margin: 2px 0;
}

p.item-subtotal {
    font-size: 12px;
    font-weight: 700;
    margin: 4px 0 0 0;
    color: #333;
}

/* ── Controles de cantidad ───────────────────────────────────────────────── */

.item-cantidad-controles {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
    flex-wrap: nowrap;
}

/* Ensure children inside controls have no extra margins and align middle */
.item-cantidad-controles > * {
    margin: 0 !important;
    vertical-align: middle !important;
}

.item-cantidad-controles .btn-disminuir,
.item-cantidad-controles .btn-aumentar,
.item-cantidad-controles .btn-eliminar-total {
    width: 34px;
    height: 34px;
    min-width: 34px;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    border: none;
    cursor: pointer;
    transition: all 0.16s ease;
}

.item-cantidad-controles .btn-disminuir,
.item-cantidad-controles .btn-aumentar {
    background-color: #333;
    color: white;
}

.item-cantidad-controles .btn-disminuir:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.item-cantidad {
    font-weight: bold;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    min-width: 14px;
    font-size: 13px;
    line-height: 1;
}

.btn-eliminar-total {
    background-color: #ffc107; /* amarillo similar a UI */
    color: #111;
    border: none;
    border-radius: 8px;
    padding: 0 !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    transition: all 0.16s ease;
}

.btn-eliminar-total:hover {
    background-color: #c82333;
    transform: scale(1.05);
}

.btn-eliminar-total svg,
.item-cantidad-controles .btn-eliminar-total svg {
    width: 16px;
    height: 16px;
    pointer-events: none;
}

/* ── Botón cerrar carrito ──────────────────────────────────────────────────── */

.cart-bar .close-cart {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 4px 8px;
    font-size: 20px;
    line-height: 1;
    color: #404040;
    cursor: pointer;
    border-radius: 4px;
    width: auto !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 200ms;
    flex-shrink: 0;
}

.cart-bar .close-cart:hover {
    background: #f5f5f5 !important;
    color: #000;
}

/* ── Botones de acción (checkout / ver carrito) ────────────────────────────── */

span#transporte-carrito {
    display: none;
}

#checkout-btn {
    background-color: #ffbd27;
    border: 2px solid #ffbd27;
    color: #ffffff;
    padding: 12px 18px;
    border-radius: 8px;
    display: inline-block;
    width: 100%;
    text-align: center;
    font-weight: 700;
}

#checkout-btn:hover {
    background-color: #f6b21f;
    color: #ffffff;
    border-color: #f6b21f;
}

#view-cart-btn {
    background-color: #333;
    color: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    display: inline-block;
    width: 100%;
    text-align: center;
    font-weight: 700;
    border: 2px solid transparent;
}

#view-cart-btn:hover {
    background-color: #444;
}

/* ── Card de gran total ─────────────────────────────────────────────────────── */

.grand-total-card {
    background: #fff;
    border: 1px solid #f1f1f1;
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 6px 0 12px 0;
    width: 100%;
    box-sizing: border-box;
}

.grand-total-label {
    font-size: 13px;
    color: #333;
    font-weight: 600;
}

.grand-total-amount {
    font-size: 16px;
    font-weight: 800 !important;
    color: #28a745;
}

/* ── Mensajes de feedback ───────────────────────────────────────────────────── */

#mensaje-carrito.mensaje {
    display: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin: 6px 0;
}

#mensaje-carrito.mensaje.exito {
    background: #d4edda;
    color: #155724;
}

#mensaje-carrito.mensaje.error {
    background: #f8d7da;
    color: #721c24;
}

/* ── Overlay de oscurecimiento del fondo ────────────────────────────────────── */

.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    z-index: 1050;
    pointer-events: none;
}

.cart-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ── Productos disponibles (compatibilidad legacy) ──────────────────────────── */

.producto-disponible {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px dashed #eee;
    margin-bottom: 10px;
}

.producto-disponible:last-child {
    border-bottom: none;
}

.producto-disponible img {
    margin-right: 10px;
    border-radius: 4px;
}

.producto-disponible .producto-info {
    flex-grow: 1;
}

.producto-disponible .titulo {
    font-weight: bold;
}

.producto-disponible .precio {
    color: #007bff;
}

.producto-disponible .modalidad {
    font-size: 0.8em;
    color: #888;
    margin-top: 2px;
}

.producto-disponible .btn-agregar {
    background-color: #333;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}
