/* ===== BOTÓN FLOTANTE Y BADGE ===== */
.carrito-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: var(--color-primario, #d71414);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s;
}
.carrito-trigger:hover { opacity: 0.85; }
.carrito-trigger svg { width: 22px; height: 22px; }

.carrito-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #111;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    display: none;
}
.carrito-badge.visible { display: flex; }

/* ===== OVERLAY ===== */
.carrito-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
}
.carrito-overlay.visible { display: block; }

/* ===== DRAWER ===== */
.carrito-drawer {
    position: fixed;
    top: 0;
    right: -480px;
    width: 460px;
    max-width: 100vw;
    height: 100vh;
    background: #fff;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0,0,0,0.18);
    transition: right 0.3s ease;
    overflow: hidden;
}
.carrito-drawer.abierto { right: 0; }

.carrito-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0;
}
.carrito-drawer-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #111;
}
.carrito-cerrar {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #6b7280;
    padding: 0 4px;
    line-height: 1;
}
.carrito-cerrar:hover { color: #111; }

.carrito-tc-info {
    font-size: 0.78rem;
    font-weight: 700;
    color: #1d4ed8;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 3px 10px;
    border-radius: 999px;
}

/* ===== ITEMS DEL CARRITO ===== */
.carrito-items {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
}

.carrito-vacio {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    gap: 0.5rem;
    text-align: center;
}
.carrito-vacio svg { width: 48px; height: 48px; opacity: 0.4; }

.carrito-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f3f4f6;
}
.carrito-item-info { flex: 1; min-width: 0; }
.carrito-item-nombre {
    font-size: 0.85rem;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.carrito-item-sku { font-size: 0.75rem; color: #9ca3af; }
.carrito-item-precio { font-size: 0.8rem; color: #6b7280; }

.carrito-item-qty {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.qty-btn {
    width: 26px;
    height: 26px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.qty-btn:hover { background: #e5e7eb; }
.qty-input {
    width: 36px;
    height: 26px;
    text-align: center;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.85rem;
    padding: 0;
}
.carrito-item-subtotal {
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 72px;
    text-align: right;
    flex-shrink: 0;
    color: #111;
}
.carrito-item-remove {
    background: none;
    border: none;
    color: #d1d5db;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}
.carrito-item-remove:hover { color: #ef4444; }

/* ===== TOTALES Y FOOTER ===== */
.carrito-drawer-footer {
    border-top: 1px solid #e5e7eb;
    padding: 1rem 1.25rem;
    background: #f9fafb;
    flex-shrink: 0;
}
.carrito-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.carrito-total-label { font-size: 0.9rem; color: #6b7280; }
.carrito-total-valor {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--color-primario, #d71414);
}
.carrito-total-nota {
    font-size: 0.72rem;
    color: #6b7280;
    background: #f8fafc;
    border-left: 3px solid #cbd5e1;
    padding: 0.45rem 0.6rem;
    border-radius: 0 4px 4px 0;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.btn-finalizar {
    width: 100%;
    padding: 0.85rem;
    background: var(--color-primario, #d71414);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
}
.btn-finalizar:hover { opacity: 0.85; }
.btn-finalizar:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== CHECKOUT FORM ===== */
.carrito-checkout-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

.checkout-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    margin: 1rem 0 0.5rem 0;
}
.checkout-section-title:first-child { margin-top: 0; }

.form-group { margin-bottom: 0.75rem; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 3px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primario, #d71414);
}
.form-group.has-error input,
.form-group.has-error select { border-color: #ef4444; }
.form-group .error-msg {
    font-size: 0.75rem;
    color: #ef4444;
    margin-top: 2px;
    display: none;
}
.form-group.has-error .error-msg { display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

.tipo-doc-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.tipo-doc-btn {
    flex: 1;
    padding: 0.5rem;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 0.85rem;
    text-align: center;
    transition: all 0.15s;
}
.tipo-doc-btn.active {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
}

.cuit-lookup-wrap { display: flex; gap: 0.5rem; }
.cuit-lookup-wrap input { flex: 1; }
.btn-buscar-cuit {
    padding: 0.55rem 0.75rem;
    background: #374151;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-buscar-cuit:hover { background: #111; }
.btn-buscar-cuit:disabled { opacity: 0.5; }

.cliente-encontrado-alert {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    font-size: 0.8rem;
    color: #166534;
    margin-bottom: 0.75rem;
    display: none;
}
.cliente-email-mismatch-alert {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    font-size: 0.8rem;
    color: #92400e;
    margin-bottom: 0.75rem;
    display: none;
}

.direcciones-guardadas {
    display: none;
    margin-bottom: 0.5rem;
}
.direccion-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 0.4rem;
    cursor: pointer;
    font-size: 0.8rem;
}
.direccion-option:hover { border-color: var(--color-primario, #d71414); }
.nueva-dir-link {
    font-size: 0.8rem;
    color: var(--color-primario, #d71414);
    cursor: pointer;
    text-decoration: underline;
}

.checkout-footer {
    border-top: 1px solid #e5e7eb;
    padding: 1rem 1.25rem;
    background: #f9fafb;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.checkout-total-ars {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--color-primario, #d71414);
}
.btn-enviar-pedido {
    width: 100%;
    padding: 0.85rem;
    background: var(--color-primario, #d71414);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
}
.btn-enviar-pedido:hover { opacity: 0.85; }
.btn-enviar-pedido:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-volver-carrito {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 0.85rem;
    text-align: center;
}
.btn-volver-carrito:hover { color: #111; }

/* Nota: Botón de catálogo definido en cards.css (.btn-agregar-carrito-icono) */

.btn-agregar-carrito-grande {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.85rem 2rem;
    background: var(--color-primario, #d71414);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: 1rem;
}
.btn-agregar-carrito-grande:hover { opacity: 0.85; }
.btn-agregar-carrito-grande svg { width: 20px; height: 20px; }

/* ===== SPINNER ===== */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .carrito-drawer { width: 100vw; }
    .form-row { grid-template-columns: 1fr; }
}