/* ==========================================================================
   Merkadocom Side Cart — Estilo 1 (Base estructural)
   Los colores y visibilidad se inyectan vía CSS dinámico desde PHP.
   ========================================================================== */

/* Oculto por defecto — la visibilidad se controla desde settings */
#msc-side-cart {
    display: none;
}

/* ------------------------------------------------------------------
   Container (solo estructura)
------------------------------------------------------------------ */
#msc-side-cart {
    flex-direction: row;
    align-items: flex-start;
    position: fixed;
    top: 100px;
    right: 0;
    max-height: calc(100vh - 120px);
}

/* ------------------------------------------------------------------
   Panel wrapper (border, shadow, width — structural container)
------------------------------------------------------------------ */
.msc-panel {
    background: #ffffff;
    border: 1px solid #e2e2e2;
    border-right: none;
    border-radius: 8px 0 0 8px;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.12);
    width: 200px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 120px);
    overflow: hidden;
}

/* ------------------------------------------------------------------
   Inner panel (scrollable products area)
------------------------------------------------------------------ */
.msc-inner {
    flex: 1;
    padding: 12px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: #cccccc transparent;
}

.msc-inner::-webkit-scrollbar        { width: 4px; }
.msc-inner::-webkit-scrollbar-thumb  { background: #cccccc; border-radius: 2px; }

/* ------------------------------------------------------------------
   Footer (buttons — always below scroll, visible)
------------------------------------------------------------------ */
.msc-footer {
    flex-shrink: 0;
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: #ffffff;
}

/* Ocultar footer cuando el carrito está colapsado */
#msc-side-cart.msc-is-collapsed .msc-footer {
    display: none !important;
}

/* ------------------------------------------------------------------
   Header
------------------------------------------------------------------ */
.msc-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #eeeeee;
}

.msc-subtotal-label {
    font-size: 11px;
    color: #666666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.msc-subtotal-amount {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    margin-top: 2px;
}

/* ------------------------------------------------------------------
   Buttons (defaults — overridden by dynamic CSS)
------------------------------------------------------------------ */
.msc-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 9px 6px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-decoration: none !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    position: relative;
    z-index: 10;
    background-color: transparent;
    color: #111111 !important;
    border: 2px solid #111111 !important;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
    box-sizing: border-box;
}

.msc-btn:hover {
    background-color: #111111 !important;
    color: #ffffff !important;
    text-decoration: none !important;
    transform: translateY(-1px);
}

.msc-btn:active {
    transform: translateY(0);
}

/* ------------------------------------------------------------------
   Product list
------------------------------------------------------------------ */
.msc-items-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msc-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.msc-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.msc-item-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #eeeeee;
    flex-shrink: 0;
}

.msc-item-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2px;
    width: 100%;
}

.msc-item-name {
    font-size: 11px;
    color: #333333;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-weight: 500;
}

.msc-item-name a         { color: inherit; text-decoration: none; }
.msc-item-name a:hover   { color: #111111; text-decoration: underline; }
.msc-item-qty            { font-size: 10px; color: #888888; }
.msc-item-price          { font-size: 12px; font-weight: 700; color: #1a1a1a; }

/* Quantity controls */
.msc-qty-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    border: 1px solid #dddddd;
    border-radius: 4px;
    overflow: hidden;
    margin: 3px 0;
}

.msc-qty-btn {
    width: 24px;
    height: 24px;
    background: #f5f5f5;
    border: none !important;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    color: #333333;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msc-qty-btn:hover {
    background: #111111;
    color: #ffffff;
}

.msc-qty-num {
    min-width: 28px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #111111;
    border-left: 1px solid #dddddd;
    border-right: 1px solid #dddddd;
    padding: 2px 4px;
    line-height: 20px;
}

.msc-item-remove {
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #bbbbbb;
    font-size: 14px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 3px;
    transition: color 0.15s ease, background 0.15s ease;
}

.msc-item-remove:hover {
    color: #e74c3c;
    background: #ffeaea;
}

/* ------------------------------------------------------------------
   Empty message
------------------------------------------------------------------ */
.msc-empty-msg {
    font-size: 11px;
    color: #999999;
    text-align: center;
    padding: 10px 0;
    margin: 0;
}

/* ------------------------------------------------------------------
   Toggle tab
------------------------------------------------------------------ */
.msc-toggle {
    position: absolute;
    left: -34px;
    top: 50%;
    transform: translateY(-50%);
    background-color: #ffffff !important;
    background-image: none !important;
    border: 1px solid #e0e0e0 !important;
    border-right: none !important;
    border-radius: 6px 0 0 6px !important;
    color: #111111 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 7px;
    box-shadow: none;
    transition: background-color 0.2s ease;
    outline: none !important;
}

.msc-toggle:hover,
.msc-toggle:focus,
.msc-toggle:active {
    background-color: #f0f0f0 !important;
    background-image: none !important;
    color: #111111 !important;
    outline: none !important;
}

/* Cart icon — only visible when collapsed */
.msc-cart-icon {
    display: none;
    fill: #111111 !important;
    color: #111111 !important;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

#msc-side-cart.msc-is-collapsed .msc-cart-icon {
    display: block;
}

.msc-toggle-icon {
    font-size: 16px;
    line-height: 1;
    display: block;
    font-weight: 700;
}

/* ------------------------------------------------------------------
   Badge counter — red pulse animation
------------------------------------------------------------------ */
.msc-toggle-count {
    font-size: 10px;
    font-weight: 700;
    background: #e00000;
    color: #ffffff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    animation: mscPulse 1.4s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(224, 0, 0, 0.9);
}

@keyframes mscPulse {
    0%   { box-shadow: 0 0 0 0   rgba(224, 0, 0, 0.9); transform: scale(1);    }
    45%  { box-shadow: 0 0 0 8px rgba(224, 0, 0, 0.35); transform: scale(1.18); }
    70%  { box-shadow: 0 0 0 14px rgba(224, 0, 0, 0);   transform: scale(1.05); }
    100% { box-shadow: 0 0 0 0   rgba(224, 0, 0, 0);    transform: scale(1);    }
}

.msc-toggle-count[data-count="0"],
.msc-toggle-count:empty {
    display: none;
}

/* ------------------------------------------------------------------
   Style 2 — product count badge inside the panel header
------------------------------------------------------------------ */
.msc-style2-count {
    display: none !important; /* hidden in style 1 and when cart is empty */
}

#msc-side-cart.msc-style2 .msc-style2-count {
    display: flex !important;
    order: -1;            /* float to the top of the header column     */
    align-self: center;
    width: 26px;
    height: 26px;
    font-size: 12px;
    font-weight: 700;
    background: #e00000;
    color: #ffffff;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin-bottom: 6px;
    animation: mscPulse 1.4s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(224, 0, 0, 0.9);
    flex-shrink: 0;
}

#msc-side-cart.msc-style2 .msc-style2-count[data-count="0"],
#msc-side-cart.msc-style2 .msc-style2-count:empty {
    display: none !important;
}

/* ------------------------------------------------------------------
   Loading / utility
------------------------------------------------------------------ */
.msc-panel.msc-loading {
    opacity: 0.6;
    pointer-events: none;
}

.msc-hidden {
    display: none !important;
}

/* ------------------------------------------------------------------
   Auto-hide when cart is empty
------------------------------------------------------------------ */

/* Style 2: hide entire cart (no toggle tab) when empty */
#msc-side-cart.msc-cart-empty {
    display: none !important;
}

/* Style 1: hide panel server-side when collapsed — prevents flash on page load */
#msc-side-cart.msc-is-collapsed .msc-panel {
    display: none;
}
