/**
 * WC Category Menu - Styles
 * 
 * Mobile-first responsive design matching the provided screenshots
 */

/* ========================================
   Base Styles (Mobile First)
   ======================================== */

.wc-category-menu-wrapper {
    padding: 15px;
    max-width: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Header */
.wc-category-menu-wrapper .menu-header {
    color: #0499d5;
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 20px 0;
    line-height: 1.3;
}

/* ========================================
   Category Tabs
   ======================================== */

.tabs-navigation-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 40px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-nav-button {
    display: none; /* Hidden by default, shown via JS when needed */
    position: sticky;
    z-index: 10;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    padding: 0;
    color: #1a1a1a;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    opacity: 0;
}

.tab-nav-button svg {
    width: 20px;
    height: 20px;
    display: block;
    margin: 0 auto;
}

.tab-nav-button:hover:not(:disabled) {
    background: #0095D8;
    border-color: #0095D8;
    color: #fff;
    transform: scale(1.1);
}

.tab-nav-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.tab-nav-button.visible {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.tab-nav-prev {
    left: 0;
}

.tab-nav-next {
    right: 0;
}

.category-tabs {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0px;
    padding-bottom: 0;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    white-space: nowrap;
    scroll-behavior: smooth;
    margin-bottom: -2px; /* Align with nav buttons */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.category-tabs::-webkit-scrollbar {
    display: none;
}

.tab-button {
    text-transform: uppercase;
    padding: 20px 12px;
    min-width: max-content;
    font-size: 13px;
    font-weight: 500;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    color: #1a1a1a !important;
    letter-spacing: 0.5px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.tab-button:hover,
.tab-button:active {
    background: rgba(0, 149, 216, 0.05);
}

.tab-button.active {
    border-bottom-color: #0499d5;
    font-weight: 700;
}


/* ========================================
   Products Container
   ======================================== */

.products-container {
    position: relative;
    min-height: 300px;
}

.products-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: 30px;
    margin-top: 20px;
    transition: opacity 0.3s ease;
}

/* ========================================
   Product Item
   ======================================== */

.product-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 30px;
}

.product-item:last-child {
    border-bottom: none;
}

/* Product Header (Title + Price) */
.product-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    position: relative;
    border-bottom: 2px dotted #d0d0d0;
    padding-bottom: 2px;
}

.product-title {
    font-weight: 700;
    font-size: 18px;
    line-height: 1.3;
    margin: 0;
    color: #1a1a1a !important;
    background: #fff;
    padding-right: 10px;
    position: relative;
    z-index: 1;
    flex-shrink: 1;
    min-width: 0;
}

.product-price {
    color: #0095D8;
    font-weight: 700;
    white-space: nowrap;
    font-size: 18px;
    flex-shrink: 0;
    background: #fff;
    padding-left: 10px;
    position: relative;
    z-index: 1;
}

/* Product Content (Description + Cart Button inline) */
.product-content {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 15px;
    margin-top: 8px;
}

/* Product Description */
.product-description {
    color: #666 !important;
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 1;
}

.product-description p {
    margin: 0 0 5px 0;
    color: #666 !important;
}

.product-description:empty {
    display: none;
}

/* Product Footer (Cart Button) */
.product-footer {
    display: flex;
    align-items: flex-start;
    flex-shrink: 0;
}

/* ========================================
   Cart Button
   ======================================== */

.cart-button {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    border-radius: 50%;
    background: #4D4184;
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.cart-button svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: white;
    transition: transform 0.2s ease;
}

.cart-button:hover,
.cart-button:active {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(92, 77, 125, 0.3);
    background: #6B5A8D;
}

.cart-button:focus {
    outline: 2px solid #4D4184;
    outline-offset: 2px;
}

.cart-button.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.cart-button.loading svg {
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.cart-button.added {
    background: #0499d5 !important;
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

.cart-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   Loading Spinner
   ======================================== */

.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0095D8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   Messages
   ======================================== */

.no-products-message,
.error-message {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
}

.error-message {
    color: #d32f2f;
}

/* ========================================
   Tablet Styles (640px and up)
   ======================================== */

@media (min-width: 640px) {
    .wc-category-menu-wrapper .menu-header {
        font-size: 22px;
    }
    
    .tab-button {
        font-size: 14px;
        padding: 20px 12px;
    }
    
    .tab-nav-button {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }
    
    .tab-nav-button svg {
        width: 22px;
        height: 22px;
    }
    
    .products-grid {
        grid-template-columns: 1fr 1fr; /* Two columns */
        gap: 30px 25px;
    }
    
    .product-title {
        font-size: 19px;
    }
    
    .product-price {
        font-size: 19px;
    }
}

/* ========================================
   Desktop Styles (1024px and up)
   ======================================== */

@media (min-width: 1024px) {
    .wc-category-menu-wrapper {
        max-width: 1200px;
        margin: 0 auto;
        padding: 20px;
    }
    
    .wc-category-menu-wrapper .menu-header {
        font-size: 24px;
        margin-bottom: 25px;
    }
    
    .tab-button {
        font-size: 15px;
        padding: 12px 20px;
    }
    
    .products-grid {
        gap: 40px 30px;
    }
    
    .product-title {
        font-size: 20px;
    }
    
    .product-price {
        font-size: 20px;
    }
    
    .product-description {
        font-size: 15px;
    }
}

/* ========================================
   Large Desktop (1440px and up)
   ======================================== */

@media (min-width: 1440px) {
    .wc-category-menu-wrapper {
        max-width: 1400px;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .cart-button,
    .loading-spinner {
        display: none;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .product-item {
        page-break-inside: avoid;
    }
}

/* ========================================
   Accessibility & Motion Preferences
   ======================================== */

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .tab-button.active {
        border-bottom-width: 4px;
    }
    
    .cart-button {
        border: 2px solid #fff;
    }
}

/* ========================================
   RTL Support
   ======================================== */

.rtl .product-header {
    flex-direction: row-reverse;
}

.rtl .product-title::after {
    left: auto;
    right: 100%;
    margin-left: 0;
    margin-right: 10px;
}

.rtl .product-price {
    margin-left: 0;
    margin-right: auto;
    padding-left: 0;
    padding-right: 10px;
}

/* ========================================
   Dark Mode Support (Optional)
   ======================================== */

@media (prefers-color-scheme: dark) {
    .wc-category-menu-wrapper {
        color: #e0e0e0;
    }
    
    .product-title {
        color: #f5f5f5;
    }
    
    .product-description {
        color: #b0b0b0;
    }
    
    
    .tab-button {
        color: #b0b0b0;
    }
    
    .tab-button:hover {
        color: #e0e0e0;
        background: rgba(0, 149, 216, 0.15);
    }
    
    .tab-button.active {
        color: #f5f5f5;
    }
    
    
    .product-title::after {
        border-bottom-color: #444;
    }
}
