/* cart.css */
:root {
    --cart-width-desktop: 400px;
    --header-height: 60px;
    --cart-animation-time: 0.3s;
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);
}

.cart-container {
    position: relative;
}

.cart-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-button svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 2;
    transition: stroke 0.3s;
}

.cart-button:hover svg {
    stroke: var(--accent-color);
}

.cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    transition: transform 0.2s ease;
}

.cart-count.bump {
    animation: bump 0.3s ease-out;
}

@keyframes bump {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.cart-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--cart-animation-time) ease;
}

.cart-overlay.active {
    display: block;
    opacity: 1;
}

.cart-dropdown {
    position: fixed;
    background: white;
    z-index: 1001;
    display: none;
    transition: transform var(--cart-animation-time) ease, opacity var(--cart-animation-time) ease;
    opacity: 0;
    height: 100vh;
    width: var(--cart-width-desktop);
    top: 0;
    right: 0;
    transform: translateX(100%);
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
}

.cart-dropdown.active {
    display: block;
    opacity: 1;
    transform: translateX(0);
}

.cart-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.cart-header {
    flex-shrink: 0;
    padding: 1rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.cart-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-color);
}

.cart-close {
    background: none;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--secondary-color);
    border-radius: 50%;
    transition: background-color 0.2s;
}

.cart-close:hover {
    background-color: #f5f5f5;
}

.cart-items {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}

.cart-empty {
    text-align: center;
    padding: 2rem;
    color: var(--secondary-color);
}

.cart-item {
    display: flex;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid #eee;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    margin-right: 1rem;
}

.cart-item-details {
    flex-grow: 1;
}

.cart-item-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--primary-color);
}

.cart-item-price {
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.cart-item-variant {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.25rem;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    margin-top: 0.5rem;
}

.quantity-btn {
    background: #f5f5f5;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--primary-color);
    transition: background 0.2s;
}

.quantity-btn:hover {
    background: #e0e0e0;
}

.quantity-number {
    margin: 0 0.75rem;
    min-width: 24px;
    text-align: center;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    padding: 0.5rem;
    margin-left: 0.5rem;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.cart-item-remove:hover {
    color: var(--accent-color-dark);
}

.cart-summary {
    flex-shrink: 0;
    background: white;
    padding: 1rem;
    border-top: 1px solid #eee;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-weight: bold;
    color: var(--primary-color);
}

.cart-total-amount {
    font-size: 1.2rem;
}

.cart-checkout {
    display: block;
    width: 100%;
    padding: 1rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.cart-checkout:hover:not(:disabled) {
    background: var(--accent-color-dark);
    transform: translateY(-1px);
}

.cart-checkout:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Estilos específicos para móvil */
@media (max-width: 768px) {
    .cart-dropdown {
        width: 100%;
        padding-top: env(safe-area-inset-top, 0);
        height: calc(100% - env(safe-area-inset-bottom, 0px));
    }

    .cart-content {
        height: 100%;
        padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 30px);
    }

    .cart-header {
        padding-top: max(1rem, env(safe-area-inset-top, 1rem));
        position: sticky;
        top: 0;
        z-index: 2;
    }

    .cart-items {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
        padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 120px);
    }

    .cart-summary {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 1rem;
        padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 30px);
        z-index: 1002;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }

    .cart-checkout {
        width: calc(100% - 2rem);
        margin: 0 auto;
        margin-bottom: calc(env(safe-area-inset-bottom, 20px) + 10px);
    }
}

/* Soporte específico para iOS */
@supports (-webkit-touch-callout: none) {
    .cart-summary {
        padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 30px);
    }

    .cart-content {
        padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 30px);
    }

    .cart-items {
        padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 120px);
    }

    .cart-checkout {
        margin-bottom: calc(env(safe-area-inset-bottom, 20px) + 30px);
    }
}

/* Estilos específicos para iPhone con notch */
@media only screen 
    and (device-width: 375px) 
    and (device-height: 812px) 
    and (-webkit-device-pixel-ratio: 3),
    only screen 
    and (device-width: 414px) 
    and (device-height: 896px) 
    and (-webkit-device-pixel-ratio: 2),
    only screen 
    and (device-width: 390px) 
    and (device-height: 844px) 
    and (-webkit-device-pixel-ratio: 3),
    only screen 
    and (device-width: 428px) 
    and (device-height: 926px) 
    and (-webkit-device-pixel-ratio: 3) {
        
    .cart-summary {
        padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 40px);
    }

    .cart-checkout {
        margin-bottom: calc(env(safe-area-inset-bottom, 20px) + 30px);
    }

    .cart-items {
        padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 140px);
    }
}

/* Estilos específicos para desktop */
@media (min-width: 769px) {
    .cart-overlay.active {
        display: block;
        opacity: 0.5;
    }

    .cart-dropdown {
        width: var(--cart-width-desktop);
    }

    .cart-dropdown {
        transform: translateX(100%);
    }

    .cart-dropdown.active {
        transform: translateX(0);
    }
}


.cart-button {
    -webkit-tap-highlight-color: transparent; /* Elimina el highlight en iOS */
    -webkit-appearance: none; /* Elimina el estilo por defecto en iOS */
    appearance: none; /* Elimina el estilo por defecto */
    color: inherit; /* Usa el color heredado en lugar del color de enlace por defecto */
    background: none; /* Elimina el fondo */
    border: none; /* Elimina el borde */
    padding: 0; /* Elimina el padding */
    cursor: pointer;
}

/* Asegurarse de que el SVG también mantenga el color correcto */
.cart-button svg {
    color: inherit;
}