/* Optimized Global Cart Styles */

#simple-cart {
    transition: opacity 0.3s ease;
}

#simple-cart.hidden {
    opacity: 0;
    pointer-events: none;
}

#simple-cart:not(.hidden) {
    opacity: 1;
}

/* Ensure proper flexbox layout */
#simple-cart .flex {
    display: flex !important;
}

#simple-cart .flex-col {
    flex-direction: column !important;
}

#simple-cart .flex-1 {
    flex: 1 1 0% !important;
}

#simple-cart .flex-shrink-0 {
    flex-shrink: 0 !important;
}

/* Content area scrolling */
#cart-content {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Ensure footer is always visible */
#cart-footer {
    position: relative !important;
    bottom: auto !important;
    background: #f9fafb !important;
    border-top: 1px solid #e5e7eb !important;
    z-index: 20;
}

/* Mobile Responsiveness - Enhanced */
@media (max-width: 640px) {
    #simple-cart .w-full {
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    #simple-cart .h-full {
        height: 100vh !important;
        max-height: 100vh !important;
    }
    
    .cart-item {
        padding: 0.75rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .cart-item h3 {
        font-size: 0.875rem !important;
        line-height: 1.25rem !important;
        max-width: 100% !important;
        word-wrap: break-word !important;
    }
    
    .cart-item p {
        font-size: 0.75rem !important;
    }
    
    .qty-btn {
        min-width: 1.5rem !important;
        height: 1.5rem !important;
        font-size: 0.75rem !important;
    }
    
    #cart-footer {
        padding: 0.75rem !important;
        position: sticky !important;
        bottom: 0 !important;
    }
    
    #checkout-btn {
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem !important;
        min-height: 2.75rem !important;
    }
    
    /* Ensure proper spacing on mobile */
    #cart-content {
        padding: 0.5rem !important;
        padding-bottom: 1rem !important;
    }
    
    /* Optimize image sizes for mobile */
    .cart-item img,
    .cart-item .bg-gray-200 {
        width: 3.5rem !important;
        height: 4.5rem !important;
    }
}

/* Tablet Responsiveness */
@media (min-width: 641px) and (max-width: 768px) {
    #simple-cart .sm\:w-96 {
        width: 24rem !important;
        max-width: 90vw !important;
    }
    
    .cart-item {
        padding: 1rem !important;
    }
    
    #cart-footer {
        padding: 1rem !important;
    }
    
    #checkout-btn {
        padding: 0.875rem 1.5rem !important;
    }
}

/* Desktop Responsiveness */
@media (min-width: 769px) {
    #simple-cart .md\:w-80 {
        width: 20rem !important;
    }
    
    #simple-cart .lg\:w-96 {
        width: 24rem !important;
    }
}

/* Cart item styles with improved spacing */
.cart-item {
    transition: all 0.2s ease;
    border: 1px solid #e5e7eb !important;
    background: white !important;
}

.cart-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: #d1d5db !important;
}

/* Button styles with better touch targets */
.qty-btn, .remove-btn {
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.qty-btn:hover {
    background-color: #f3f4f6;
    transform: scale(1.05);
}

.qty-btn:active {
    transform: scale(0.95);
}

.remove-btn:hover {
    color: #dc2626;
    transform: scale(1.1);
}

.remove-btn:active {
    transform: scale(0.9);
}

/* Checkout button enhancements */
#checkout-btn {
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#checkout-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

#checkout-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Loading animation */
.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Text truncation for long product names */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ensure proper z-index stacking */
#simple-cart {
    z-index: 9999 !important;
}

#cart-footer {
    z-index: 10000 !important;
}

/* Smooth transitions for all interactive elements */
.cart-item,
.qty-btn,
.remove-btn,
#checkout-btn {
    will-change: transform, opacity;
}

/* Focus states for accessibility */
.qty-btn:focus,
.remove-btn:focus,
#checkout-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .cart-item {
        border-width: 2px !important;
    }
    
    #checkout-btn {
        border: 2px solid #1e40af !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .cart-item,
    .qty-btn,
    .remove-btn,
    #checkout-btn {
        transition: none !important;
        animation: none !important;
    }
    
    #checkout-btn:hover {
        transform: none !important;
    }
}

/* Published Year Field Styles */

/* Admin area styling */
.woocommerce_options_panel .published-year-field {
    background: #f8f9fa;
    border-left: 4px solid #3b82f6;
    padding: 15px;
    margin: 10px 0;
}

.woocommerce_options_panel .published-year-field input[type="number"] {
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.woocommerce_options_panel .published-year-field input[type="number"]:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Frontend Published Year display */
.published-year {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 16px 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.published-year::before {
    content: "📅";
    font-size: 18px;
}

.published-year .label {
    color: #64748b;
    font-weight: 500;
    font-size: 14px;
}

.published-year .value {
    color: #1e40af;
    font-weight: 700;
    font-size: 18px;
}

/* Archive page Published Year */
.published-year-archive {
    background: #f1f5f9;
    border-radius: 6px;
    padding: 6px 10px;
    display: inline-block;
    font-size: 12px;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.published-year-archive::before {
    content: "📚";
    margin-right: 4px;
}

/* Admin products list column */
.column-published_year {
    width: 120px;
}

.published-year-value {
    background: #dbeafe;
    color: #1e40af;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
}

.published-year-empty {
    color: #9ca3af;
    font-style: italic;
}

/* Responsive Published Year */
@media (max-width: 640px) {
    .published-year {
        padding: 10px 12px;
        margin: 12px 0;
    }
    
    .published-year .label {
        font-size: 13px;
    }
    
    .published-year .value {
        font-size: 16px;
    }
    
    .published-year-archive {
        padding: 4px 8px;
        font-size: 11px;
    }
}

/* Hover effects for Published Year */
.published-year:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.published-year-archive:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    transition: all 0.2s ease;
}
