/* Icono del carrito flotante */
#custom-cart-icon {
    position: fixed;
    top: 60px;
    right: 20px;
    background: #2c3e50;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

#custom-cart-icon:hover {
    background: #34495e;
    transform: scale(1.1);
}

#custom-cart-icon svg {
    width: 24px;
    height: 24px;
}

#cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
}

/* Modal del carrito */
#custom-cart-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-modal-content {
    background: white;
    padding: 0;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cart-header {
    background: #2c3e50;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-header h3 {
    margin: 0;
    font-size: 20px;
}

#close-cart-modal {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.3s ease;
}

#close-cart-modal:hover {
    background: rgba(255, 255, 255, 0.2);
}

#cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    max-height: 400px;
}

.cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

.cart-item:last-child {
    border-bottom: none;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-info h4 {
    margin: 0 0 5px 0;
    font-size: 16px;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-price {
    margin: 0;
    color: #7f8c8d;
    font-size: 14px;
}

.item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 15px;
}

.item-controls button {
    background: #ecf0f1;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    transition: background 0.3s ease;
}

.item-controls button:hover {
    background: #bdc3c7;
}

.remove-item {
    background: #e74c3c !important;
    color: white !important;
}

.remove-item:hover {
    background: #c0392b !important;
}

.quantity {
    min-width: 20px;
    text-align: center;
    font-weight: bold;
}

.item-subtotal {
    font-weight: bold;
    color: #2c3e50;
    min-width: 60px;
    text-align: right;
}

.cart-total {
    background: #ecf0f1;
    padding: 20px;
    text-align: right;
    font-size: 18px;
    border-top: 1px solid #bdc3c7;
}

.checkout-button {
    background: #27ae60;
    color: white;
    border: none;
    padding: 15px 30px;
    margin: 20px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s ease;
    width: calc(100% - 40px);
}

.checkout-button:hover {
    background: #229954;
}

.checkout-button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.empty-cart-message {
    text-align: center;
    color: #7f8c8d;
    padding: 40px 20px;
    font-style: italic;
}

/* Modal de checkout */
#checkout-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkout-modal-content {
    background: white;
    padding: 0;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.checkout-header {
    background: #27ae60;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.checkout-header h3 {
    margin: 0;
    font-size: 20px;
}

#close-checkout-modal {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.3s ease;
}

#close-checkout-modal:hover {
    background: rgba(255, 255, 255, 0.2);
}

#checkout-form {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #2c3e50;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ecf0f1;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #27ae60;
}

.form-group input.error {
    border-color: #e74c3c;
}

#checkout-cart-summary {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    margin: 20px 0;
    border: 1px solid #e9ecef;
}

#checkout-cart-summary h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
}

.checkout-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.checkout-item:last-of-type {
    border-bottom: none;
}

.checkout-total {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #27ae60;
    text-align: right;
    font-size: 18px;
}

.submit-order-button {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s ease;
    width: 100%;
    margin-top: 20px;
}

.submit-order-button:hover {
    background: #c0392b;
}

.submit-order-button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* Mensajes de notificación */
.custom-cart-message {
    position: fixed;
    top: 100px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 6px;
    z-index: 10002;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: slideInRight 0.3s ease;
}

.custom-cart-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.custom-cart-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    #custom-cart-icon {
        width: 50px;
        height: 50px;
        top: 15px;
        right: 15px;
    }
    
    #custom-cart-icon svg {
        width: 20px;
        height: 20px;
    }
    
    #cart-count {
        width: 20px;
        height: 20px;
        font-size: 11px;
        top: -6px;
        right: -6px;
    }
    
    .cart-modal-content,
    .checkout-modal-content {
        width: 95%;
        margin: 20px;
        max-height: calc(100vh - 40px);
    }
    
    .cart-header,
    .checkout-header {
        padding: 15px;
    }
    
    .cart-header h3,
    .checkout-header h3 {
        font-size: 18px;
    }
    
    #cart-items {
        padding: 15px;
    }
    
    .cart-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .item-controls {
        margin: 0;
        align-self: flex-end;
    }
    
    .item-subtotal {
        align-self: flex-end;
        margin-top: 5px;
    }
    
    .cart-total {
        padding: 15px;
        font-size: 16px;
    }
    
    .checkout-button,
    .submit-order-button {
        margin: 15px;
        width: calc(100% - 30px);
        padding: 12px 20px;
    }
    
    #checkout-form {
        padding: 15px;
    }
    
    .form-group input {
        padding: 10px;
        font-size: 16px; /* Evita zoom en iOS */
    }
    
    .custom-cart-message {
        right: 15px;
        top: 80px;
        max-width: calc(100% - 30px);
    }
}

@media (max-width: 480px) {
    .cart-modal-content,
    .checkout-modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
        margin: 0;
        max-height: 100vh;
    }
    
    .item-info h4 {
        font-size: 14px;
    }
    
    .item-price {
        font-size: 12px;
    }
    
    .item-controls button {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

#custom-cart-modal.show,
#checkout-modal.show {
    animation: fadeIn 0.3s ease;
}

.cart-modal-content,
.checkout-modal-content {
    animation: slideIn 0.3s ease;
}

/* Mejoras de accesibilidad */
button:focus,
input:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Ocultar scrollbar pero mantener funcionalidad */
#cart-items::-webkit-scrollbar,
#checkout-form::-webkit-scrollbar {
    width: 6px;
}

#cart-items::-webkit-scrollbar-track,
#checkout-form::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#cart-items::-webkit-scrollbar-thumb,
#checkout-form::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 3px;
}

#cart-items::-webkit-scrollbar-thumb:hover,
#checkout-form::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}