/**
 * ADVEIE Cart Styles
 * Premium cart styling with animations and micro-interactions
 */

/* Cart Icon Styles */
.cart-icon-wrapper {
    position: relative;
    display: inline-block;
}

.cart-icon-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dark, #333);
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    border: none;
    cursor: pointer;
}

.cart-icon-link:hover {
    background: rgba(21, 101, 192, 0.08);
    transform: scale(1.05);
}

.cart-icon-link:active {
    transform: scale(0.95);
}

.cart-icon-link i {
    font-size: 1.3rem;
    transition: all 0.3s ease;
    color: var(--dark, #333);
}

.cart-icon-link:hover i {
    color: var(--primary, #1565C0);
}

/* Cart Badge with Glow Effect */
.cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger, #dc3545);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 12px rgba(220, 53, 69, 0.5);
    animation: cartPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.cart-badge:empty {
    display: none;
}

/* Cart Icon Glow Animation when items exist */
.cart-icon-link.has-items {
    animation: cartGlow 2.5s ease-in-out infinite;
}

/* Cart Hover Preview */
.cart-preview {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    max-height: 400px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.98);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow-y: auto;
}

.cart-icon-wrapper:hover .cart-preview {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.cart-preview-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.cart-preview-item:last-child {
    border-bottom: none;
}

.cart-preview-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--dark);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-preview-price {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.85rem;
    white-space: nowrap;
}

.cart-preview-empty {
    text-align: center;
    padding: 1.5rem 0;
    color: #aaa;
    font-size: 0.85rem;
}

/* Cart Page Animations */
.cart-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    background: #fff;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cart-item:hover {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.cart-item-removing {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideOut {
    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

/* Quantity Selector */
.quantity-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quantity-selector button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #e9ecef;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--dark);
}

.quantity-selector button:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: scale(1.05);
}

.quantity-selector button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.quantity-selector button:active:not(:disabled) {
    transform: scale(0.95);
}

.quantity-selector input {
    width: 48px;
    text-align: center;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 0.25rem;
    font-weight: 600;
    font-size: 0.9rem;
    -moz-appearance: textfield;
}

.quantity-selector input::-webkit-outer-spin-button,
.quantity-selector input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Cart Item Type Badges */
.cart-item-type {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    display: inline-block;
}

.cart-item-type.article { background: #EEF4FF; color: #1565C0; }
.cart-item-type.subscription { background: #E8F5E9; color: #2E7D32; }
.cart-item-type.certificate { background: #FFF8E1; color: #F57F17; }
.cart-item-type.apc { background: #F3E5F5; color: #9C27B0; }
.cart-item-type.publication { background: #FCE4EC; color: #C62828; }
.cart-item-type.event { background: #E0F7FA; color: #00838F; }

/* Cart Summary */
.cart-summary {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1.5rem;
    position: sticky;
    top: 80px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.cart-summary-item {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.9rem;
}

.cart-summary-item:last-child {
    border-bottom: none;
}

.cart-summary-total {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
}

/* Empty Cart */
.cart-empty {
    text-align: center;
    padding: 4rem 2rem;
}

.cart-empty-icon {
    font-size: 5rem;
    color: #ddd;
    margin-bottom: 1.5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Keyframe Animations */
@keyframes cartPop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.3); opacity: 1; }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes cartGlow {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(21, 101, 192, 0.1);
    }
    50% { 
        box-shadow: 0 0 24px 6px rgba(21, 101, 192, 0.15);
    }
}

/* Cart Badge Pulse */
.cart-badge.pulse {
    animation: cartPulse 1s ease-in-out 3;
}

@keyframes cartPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Responsive */
@media (max-width: 768px) {
    .cart-preview {
        width: 280px;
        right: -50px;
    }
    
    .cart-item {
        padding: 0.75rem;
    }
    
    .quantity-selector input {
        width: 40px;
    }
    
    .cart-summary {
        position: relative;
        top: 0;
        margin-top: 1.5rem;
    }
    
    .cart-item-image {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .cart-item,
    .cart-badge,
    .cart-icon-link,
    .quantity-selector button {
        animation: none !important;
        transition: none !important;
    }
    
    .cart-preview {
        transition: none !important;
    }
}

/* Dark Mode Support (if applicable) */
@media (prefers-color-scheme: dark) {
    .cart-item {
        background: #1a1a2e;
        border-color: #2a2a4a;
    }
    
    .cart-summary {
        background: #1a1a2e;
        border-color: #2a2a4a;
    }
    
    .cart-summary-item {
        border-color: #2a2a4a;
    }
    
    .cart-item:hover {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
    
    .quantity-selector input {
        background: #1a1a2e;
        color: #fff;
        border-color: #2a2a4a;
    }
    
    .quantity-selector button {
        background: #1a1a2e;
        border-color: #2a2a4a;
        color: #fff;
    }
}