/* ============================================
   IMPORTACIÓN DE FUENTES
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@300..700&display=swap');

:root {
    /* ===== OFICIAL ===== */
    --primary-green: #156764;
    --light-green: #A7DBB7;
    --cream: #f9f7f1;
    --text-dark: #2c3e50;
    --white: #ffffff;

    /* ===== ACEPTADOS ===== */
    --mustard: #B7C909;
    --violet: #58256B;

    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

/* Animaciones del Carrito */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 0.3s ease-in-out;
}

/* Animación agregar al carrito */
.add-to-cart-animation {
    position: fixed;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.add-to-cart-animation img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.add-to-cart-animation span {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: var(--primary-green);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   SIDEBAR DEL CARRITO
   ======================================== */

.cart-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--white);
    box-shadow: -8px 0 30px rgba(45, 80, 22, 0.2);
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1050;
    font-family: 'Quicksand', sans-serif;
}

.cart-sidebar.open {
    right: 0;
}

/* Overlay */
.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 80, 22, 0.5);
    z-index: 1040;
    display: none;
    backdrop-filter: blur(3px);
    transition: all 0.3s ease-in-out;
}

/* ========================================
   ESTRUCTURA INTERNA DEL CARRITO
   ======================================== */

.cart-sidebar > div {
    height: 100vh;
    padding: 1.5rem;
    box-sizing: border-box;
    position: relative;
    background: var(--white);
}

/* Header del carrito */
.cart-sidebar .d-flex.justify-content-between.align-items-center.mb-4 {
    height: 60px;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--cream);
    margin-bottom: 1.5rem !important;
    position: relative;
}

/* Título con tipografía Caroni */
.cart-sidebar h4 {
    margin: 0;
    font-family: 'CARONI', serif;
    font-size: 1.5rem;
    color: var(--primary-green);
    letter-spacing: 0.5px;
}

/* Botón cerrar */
.cart-sidebar .btn-close,
#closeCart {
    position: absolute;
    top: 0;
    right: 0;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--cream);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-dark);
    transition: all 0.3s ease;
    opacity: 1;
    cursor: pointer;
    padding: 0;
}

.cart-sidebar .btn-close:hover,
#closeCart:hover {
    background: var(--mustard);
    color: white;
    transform: rotate(90deg);
}

.cart-sidebar .btn-close::before,
#closeCart::before {
    content: "×";
    font-size: 2rem;
    line-height: 1;
    font-weight: 300;
}

/* Items del carrito */
.cart-items {
    height: calc(100vh - 210px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--light-green) var(--cream);
}

.cart-items::-webkit-scrollbar {
    width: 6px;
}

.cart-items::-webkit-scrollbar-track {
    background: var(--cream);
    border-radius: 10px;
}

.cart-items::-webkit-scrollbar-thumb {
    background: var(--light-green);
    border-radius: 10px;
}

.cart-items::-webkit-scrollbar-thumb:hover {
    background: var(--primary-green);
}

/* Estilo de items */
.cart-item {
    transition: all 0.3s ease;
    background: white;
    border: 1px solid rgba(45, 80, 22, 0.1);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
    animation: slideIn 0.3s ease;
}

.cart-item:hover {
    background-color: var(--cream);
    border-color: var(--light-green) !important;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Controles de cantidad */
.quantity-controls {
    gap: 5px;
}

.quantity-input {
    text-align: center;
    font-family: 'Quicksand', sans-serif;
    border: 1px solid var(--light-green);
    border-radius: 6px;
    padding: 0.25rem;
    width: 60px;
}

.quantity-controls button {
    background: var(--primary-green);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    transition: all 0.2s ease;
}

.quantity-controls button:hover {
    background: var(--light-green);
}

/* Botón eliminar */
.remove-item {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.remove-item:hover {
    transform: scale(1.1);
    background-color: #c82333 !important;
}

/* ========================================
   ESTADOS VACÍOS
   ======================================== */

.cart-items .text-center.text-muted {
    padding: 3rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 4rem;
    font-family: 'Quicksand', sans-serif;
}

.cart-items .text-center i {
    color: var(--light-green);
    margin-bottom: 1rem;
    opacity: 0.7;
}

.cart-items .text-center p {
    color: var(--text-dark);
    font-size: 1.1rem;
    margin-bottom: 0;
    font-weight: 500;
}

.small {
    font-size: 0.9rem;
    color: #6c757d;
}

/* ========================================
   FOOTER DEL CARRITO
   ======================================== */

.cart-footer {
    border-top: 2px solid var(--cream);
    padding-top: 1.25rem;
    padding-bottom: 0.5rem;
    background: white;
}

.cart-footer .d-flex.justify-content-between.mb-3 {
    margin-bottom: 1rem !important;
    font-size: 1.15rem;
}

#cartSubtotal {
    font-family: 'CARONI', serif;
    color: var(--primary-green);
    font-size: 1.2rem;
}

/* ========================================
   MENSAJE DE COMPRA MÍNIMA
   ======================================== */

#minOrderWarning {
    font-family: 'Quicksand', sans-serif;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 1px solid #ffc107;
    border-radius: 8px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#minOrderWarning i {
    color: #856404;
}

#minOrderWarning strong {
    color: #856404;
    font-weight: 600;
}

#minOrderWarning small {
    color: #664d03;
    display: block;
    margin-top: 0.25rem;
}

/* Botón de checkout */
#checkoutBtn {
    background: linear-gradient(135deg, var(--primary-green), var(--light-green));
    border: none;
    padding: 12px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-family: 'Quicksand', sans-serif;
    color: white;
}

#checkoutBtn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--light-green), var(--primary-green));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(107, 142, 78, 0.3);
}

#checkoutBtn:disabled {
    background: linear-gradient(135deg, #ccc, #ddd);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

/* ========================================
   RESPONSIVE MÓVILES
   ======================================== */

@media (max-width: 768px) {
    .cart-sidebar {
        width: 100%;
        right: -100%;
        height: 100vh;
    }
    
    .cart-sidebar > div {
        padding: 1rem;
        height: 100vh;
    }
    
    .cart-sidebar .d-flex.justify-content-between.align-items-center.mb-4 {
        height: 50px;
        padding-bottom: 0.75rem;
        margin-bottom: 0.75rem !important;
        position: relative;
    }
    
    .cart-sidebar h4 {
        font-size: 1.25rem;
        margin-bottom: 0;
        position: relative;
        z-index: 1;
    }
    
    .cart-sidebar .btn-close,
    #closeCart {
        position: absolute;
        top: -5px;
        right: -5px;
        width: 40px;
        height: 40px;
        font-size: 1.75rem;
        background: var(--cream);
    }
    
    .cart-sidebar .btn-close::before,
    #closeCart::before {
        font-size: 2.25rem;
    }
    
    .cart-items {
        height: calc(100vh - 200px - var(--safe-area-inset-bottom));
        margin-bottom: 0.75rem;
        padding: 0.5rem 0;
    }
    
    .cart-items .text-center.text-muted {
        padding: 2rem 1rem !important;
        padding-top: 3rem !important;
    }
    
    .cart-items .text-center.text-muted i {
        font-size: 3rem;
    }
    
    .cart-items .text-center.text-muted p {
        font-size: 1rem;
    }
    
    .cart-item {
        padding: 1rem !important;
        margin-bottom: 0.75rem !important;
        border: 1px solid rgba(45, 80, 22, 0.1) !important;
        border-radius: 10px;
    }
    
    .cart-item img {
        height: 50px !important;
        width: 50px !important;
        object-fit: cover;
        border-radius: 8px;
    }
    
    .cart-item h6 {
        font-family: 'Quicksand', sans-serif;
        font-size: 0.9rem;
        margin-bottom: 0.25rem !important;
        line-height: 1.2;
        color: var(--text-dark);
    }
    
    .cart-item p,
    .cart-item small {
        font-family: 'Quicksand', sans-serif;
        font-size: 0.8rem;
        margin-bottom: 0.25rem !important;
        line-height: 1.2;
        color: #666;
    }
    
    .quantity-controls {
        justify-content: flex-start !important;
        flex-wrap: nowrap;
        margin-top: 0.5rem;
    }
    
    .quantity-controls button {
        padding: 0.35rem 0.5rem !important;
        font-size: 0.8rem;
        min-width: 35px;
    }
    
    .quantity-input {
        width: 50px !important;
        font-size: 16px !important;
        padding: 0.35rem !important;
        margin: 0 0.25rem !important;
        border: 1px solid var(--light-green);
        border-radius: 6px;
    }
    
    .cart-item .badge {
        font-family: 'Quicksand', sans-serif;
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
        background: var(--light-green);
        color: white;
    }
    
    /* Mensaje de compra mínima en móvil */
    #minOrderWarning {
        font-size: 0.85rem !important;
        padding: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    #minOrderWarning strong {
        font-size: 0.9rem;
    }
    
    #minOrderWarning small {
        font-size: 0.8rem;
    }
    
    .cart-footer {
        border-top: 2px solid var(--cream);
        padding-top: 1.25rem;
        padding-bottom: calc(1rem + var(--safe-area-inset-bottom));
        background: white;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    }
    
    .cart-footer .d-flex.justify-content-between.mb-3 {
        margin-bottom: 1rem !important;
        font-size: 1.1rem;
    }
    
    #checkoutBtn {
        padding: 1rem !important;
        font-size: 1.05rem;
        font-weight: 600;
        width: 100%;
        border: none;
        border-radius: 8px;
        margin: 0;
        height: 52px;
        line-height: 1;
    }
}

/* Pantallas muy pequeñas */
@media (max-width: 375px) {
    .cart-sidebar > div {
        padding: 0.75rem;
    }
    
    .cart-items {
        height: calc(100vh - 180px - var(--safe-area-inset-bottom));
    }
    
    .cart-item {
        padding: 0.75rem !important;
    }
    
    .cart-item img {
        height: 45px !important;
        width: 45px !important;
    }
    
    .cart-item h6 {
        font-size: 0.85rem;
    }
    
    .quantity-input {
        width: 45px !important;
        font-size: 16px !important;
    }
    
    .quantity-controls button {
        min-width: 30px;
        padding: 0.3rem 0.4rem !important;
    }
    
    #minOrderWarning {
        font-size: 0.8rem !important;
        padding: 0.65rem !important;
    }
    
    .cart-footer {
        padding-top: 1rem;
        padding-bottom: calc(1rem + var(--safe-area-inset-bottom));
    }
    
    #checkoutBtn {
        padding: 0.875rem !important;
        font-size: 1rem;
        height: 50px;
    }
}