/* ==========================================================
   Cart Drawer — Estilo Shopify Premium
   Prefijo: .wcd- (WooCommerce Cart Drawer)
   ========================================================== */

/* --- Variables de marca V.Craven-Bartle --- */
:root {
    --wcd-color-accent: #C41230;
    --wcd-color-accent-hover: #A30E28;
    --wcd-color-dark: #1B2A4A;
    --wcd-color-bg: #F7F5F2;
    --wcd-color-bg-card: #FFFFFF;
    --wcd-color-text-primary: #1B2A4A;
    --wcd-color-text-muted: #6B7280;
    --wcd-color-border: #E5E7EB;
    --wcd-color-btn-close-bg: #F2F2F2;
    --wcd-color-btn-hover: #E8E8E8;
    --wcd-width: 420px;
    --wcd-radius: 10px;
    --wcd-radius-sm: 6px;
    --wcd-radius-pill: 40px;
    --wcd-transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --wcd-font: 'DM Sans', sans-serif;
    --wcd-font-serif: 'Cormorant Garamond', Georgia, serif;
}

/* === REGLA GLOBAL: centrado de botones icono === */
.wcd-close,
.wcd-qty-btn,
.wcd-upsells__arrow {
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === OVERLAY === */
.wcd-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 999999;
    /* Estado cerrado: invisible sin afectar layout */
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--wcd-transition), visibility var(--wcd-transition);
}
.wcd-overlay.wcd-open {
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
}

/* === DRAWER === */
.wcd-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--wcd-width);
    max-width: 100vw;
    height: 100%;
    background: var(--wcd-color-bg);
    z-index: 1000000;
    /* Estado cerrado: fuera de pantalla + invisible */
    transform: translateX(100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform var(--wcd-transition), visibility var(--wcd-transition);
    display: flex;
    flex-direction: column;
    font-family: var(--wcd-font);
    color: var(--wcd-color-text-primary);
    -webkit-font-smoothing: antialiased;
}
.wcd-drawer.wcd-open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
}

/* === HEADER === */
.wcd-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--wcd-color-border);
    position: relative;
    flex-shrink: 0;
}

/* PROBLEMA 1 — Botón cerrar: círculo perfecto, fondo neutro */
.wcd-close {
    position: absolute;
    left: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--wcd-color-border);
    background: var(--wcd-color-btn-close-bg);
    color: var(--wcd-color-text-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-sizing: border-box;
    transition: background 0.2s;
}
.wcd-close span {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.wcd-close:hover {
    background: var(--wcd-color-btn-hover);
}

.wcd-title {
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--wcd-color-text-primary);
}
.wcd-title__icon {
    opacity: 0.7;
}

/* === BARRA ENVÍO GRATIS === */
.wcd-shipping {
    padding: 14px 24px;
    border-bottom: 1px solid var(--wcd-color-border);
    flex-shrink: 0;
}
.wcd-shipping__text {
    margin: 0 0 8px;
    font-size: 12.5px;
    font-weight: 300;
    color: var(--wcd-color-text-muted);
    text-align: center;
}
.wcd-shipping__text strong {
    font-weight: 500;
    color: var(--wcd-color-text-primary);
}
.wcd-shipping__text--done {
    color: var(--wcd-color-accent);
    font-weight: 400;
}
.wcd-shipping__track {
    height: 3px;
    background: var(--wcd-color-border);
    border-radius: 2px;
    overflow: hidden;
}
.wcd-shipping__fill {
    height: 100%;
    background: var(--wcd-color-accent);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* === ITEMS === */
.wcd-items {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--wcd-color-border) transparent;
}
.wcd-items::-webkit-scrollbar {
    width: 4px;
}
.wcd-items::-webkit-scrollbar-thumb {
    background: var(--wcd-color-border);
    border-radius: 2px;
}

.wcd-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--wcd-color-border);
}
.wcd-item__img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: var(--wcd-radius);
    background: var(--wcd-color-bg-card);
    flex-shrink: 0;
}
.wcd-item__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.wcd-item__name {
    font-size: 14px;
    font-weight: 500;
    color: var(--wcd-color-text-primary);
    text-decoration: none;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.wcd-item__name:hover {
    text-decoration: underline;
}
.wcd-item__variant {
    font-size: 12px;
    font-weight: 300;
    color: var(--wcd-color-text-muted);
}

/* PROBLEMA 2 — Controles de cantidad: píldora unificada */
.wcd-item__qty-ctrl {
    display: flex;
    align-items: center;
    border: 1px solid var(--wcd-color-border);
    border-radius: 20px;
    overflow: hidden;
    width: fit-content;
    margin-top: 6px;
    background: transparent;
}
.wcd-qty-btn {
    width: 30px;
    height: 28px;
    min-width: 30px;
    border: none;
    background: transparent;
    font-size: 18px;
    font-weight: 300;
    color: var(--wcd-color-text-muted);
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    box-sizing: border-box;
    font-family: var(--wcd-font);
}
.wcd-qty-btn:hover {
    background: var(--wcd-color-btn-hover);
}
.wcd-qty-val {
    min-width: 24px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    line-height: 28px;
    color: var(--wcd-color-text-primary);
    padding: 0;
    user-select: none;
}

.wcd-item__price {
    font-size: 14px;
    font-weight: 500;
    color: var(--wcd-color-text-primary);
    white-space: nowrap;
    flex-shrink: 0;
    padding-top: 2px;
}

/* Estado vacío */
.wcd-empty {
    text-align: center;
    padding: 60px 20px;
}
.wcd-empty p {
    font-size: 15px;
    font-weight: 300;
    color: var(--wcd-color-text-muted);
    margin: 0 0 12px;
}
.wcd-empty__link {
    font-size: 14px;
    font-weight: 500;
    color: var(--wcd-color-accent);
    text-decoration: none;
}
.wcd-empty__link:hover {
    text-decoration: underline;
}

/* === UPSELLS === */
.wcd-upsells {
    border-top: 1px solid var(--wcd-color-border);
    padding: 16px 20px 12px;
    flex-shrink: 0;
}
.wcd-upsells__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.wcd-upsells__title {
    font-size: 13px;
    font-weight: 500;
    color: var(--wcd-color-text-primary);
    letter-spacing: 0.02em;
}
.wcd-upsells__nav {
    display: flex;
    gap: 6px;
}

/* PROBLEMA 3 — Flechas navegación: círculos con borde sutil */
.wcd-upsells__arrow {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    border: 1px solid var(--wcd-color-border);
    background: var(--wcd-color-dark);
    color: #FFFFFF;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-sizing: border-box;
    transition: background 0.15s;
}
.wcd-upsells__arrow:hover {
    background: var(--wcd-color-btn-hover);
}

.wcd-upsells__grid {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.wcd-upsells__grid::-webkit-scrollbar {
    display: none;
}

.wcd-upsell-card {
    flex: 0 0 calc(50% - 5px);
    background: var(--wcd-color-bg-card);
    border: 1px solid var(--wcd-color-border);
    border-radius: var(--wcd-radius);
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    scroll-snap-align: start;
    position: relative;
}
.wcd-upsell-card__img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--wcd-radius-sm);
    flex-shrink: 0;
}
.wcd-upsell-card__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.wcd-upsell-card__name {
    font-size: 12px;
    font-weight: 400;
    color: var(--wcd-color-text-primary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.wcd-upsell-card__price {
    font-size: 12px;
    font-weight: 500;
    color: var(--wcd-color-text-primary);
}
.wcd-upsell-card__price del {
    color: var(--wcd-color-text-muted);
    font-weight: 300;
    margin-right: 4px;
}
.wcd-upsell-card__add {
    font-size: 11px;
    font-weight: 500;
    color: var(--wcd-color-accent);
    text-decoration: none;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.wcd-upsell-card__add:hover {
    opacity: 0.7;
}

/* === FOOTER (fijo abajo) === */
.wcd-footer {
    border-top: 1px solid var(--wcd-color-border);
    padding: 16px 20px 20px;
    background: var(--wcd-color-bg);
    flex-shrink: 0;
}
.wcd-footer__total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 14px;
}
.wcd-footer__total-label {
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--wcd-color-text-muted);
}
.wcd-footer__total-amount {
    font-family: var(--wcd-font-serif);
    font-size: 22px;
    font-weight: 400;
    color: var(--wcd-color-text-primary);
}

/* Botón checkout: rojo marca */
.wcd-footer__checkout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px 24px;
    background: var(--wcd-color-accent);
    color: #FFFFFF;
    border: none;
    border-radius: var(--wcd-radius-pill);
    font-family: var(--wcd-font);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s;
}
.wcd-footer__checkout:hover {
    background: var(--wcd-color-accent-hover);
    color: #FFFFFF;
}
.wcd-footer__checkout svg {
    opacity: 0.8;
}

/* PROBLEMA 4 — Métodos de pago: badges con SVG inline */
.wcd-footer__payments {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.wcd-pay-badge {
    height: 24px;
    padding: 0 8px;
    background: var(--wcd-color-bg-card);
    border: 1px solid var(--wcd-color-border);
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
}
.wcd-pay-badge svg {
    height: 14px;
    width: auto;
}

/* Texto legal */
.wcd-footer__legal {
    text-align: center;
    font-size: 11px;
    font-weight: 300;
    color: var(--wcd-color-text-muted);
    margin: 10px 0 0;
}
.wcd-footer__legal a {
    color: var(--wcd-color-text-muted);
    text-decoration: underline;
}
.wcd-footer__legal a:hover {
    color: var(--wcd-color-text-primary);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .wcd-drawer {
        width: 100vw;
    }
}

/* === LOADING STATE === */
.wcd-qty-btn.wcd-loading {
    opacity: 0.4;
    pointer-events: none;
}
