/* Category Page Styles - Fully Responsive */

/* ========================================
   Card Hover Effect
   ======================================== */
.card-hover {
    transition: all 0.3s ease;
}

@media (hover: hover) {
    .card-hover:hover {
        transform: translateY(-4px);
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
    }
}

@media (hover: none) {
    .card-hover:active {
        transform: scale(0.98);
    }
}

/* ========================================
   Description Content Styling
   ======================================== */
.description-content p {
    margin-bottom: 1rem;
}

.description-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #0f172a;
}

.description-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: #0f172a;
}

.description-content ul {
    list-style-type: disc;
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.description-content ol {
    list-style-type: decimal;
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.description-content li {
    margin-bottom: 0.5rem;
}

.description-content strong {
    font-weight: 600;
    color: #1e293b;
}

/* ========================================
   Description Content - Link Styling (FIX)
   ======================================== */
.description-content a {
    color: #6366f1;
    text-decoration: underline;
    text-decoration-color: rgba(99, 102, 241, 0.4);
    text-underline-offset: 2px;
    transition: all 0.2s ease;
}

.description-content a:hover {
    color: #4f46e5;
    text-decoration-color: #4f46e5;
}

/* ========================================
   Description Content - First Element Fix
   Remove top margin from first element so
   H2/H3 at start doesn't eat up the 85px
   ======================================== */
.description-content > *:first-child {
    margin-top: 0 !important;
}

/* ========================================
   Show More/Less - Mobile Compatible
   ======================================== */
.desc-wrap {
    position: relative;
}

.desc-inner {
    overflow: hidden;
    height: 85px;
}

.desc-inner.open {
    height: auto;
}

.desc-grad {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
    pointer-events: none;
}

.desc-grad.hide {
    display: none;
}

.desc-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    padding: 8px 0;
    border: none;
    background: none;
    color: #6366f1;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}

.desc-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}

.desc-btn.open svg {
    transform: rotate(180deg);
}

.category-summary-content a {
    color: #6366f1;
    text-decoration: none;
}

.category-summary-content a:hover {
    text-decoration: underline;
}

/* ========================================
   Most Popular Section - Title
   ======================================== */
.popular-title {
    color: #252530;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 6px;
}

@media (min-width: 480px) {
    .popular-title {
        font-size: 20px;
    }
}

@media (min-width: 640px) {
    .popular-title {
        font-size: 22px;
    }
}

.popular-title-category {
    color: #6366f1;
}

/* Header Info Icon - Parent container */
.popular-info-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

/* Header Tooltip - Mobile first (right-aligned) */
.popular-header-tooltip {
    position: absolute;
    right: 0;
    left: auto;
    top: calc(100% + 8px);
    width: 180px;
    padding: 10px 12px;
    background-color: #0f172a;
    color: white;
    font-size: 12px;
    line-height: 1.4;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 50;
}

.popular-header-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    right: 6px;
    left: auto;
    border: 6px solid transparent;
    border-bottom-color: #0f172a;
}

.popular-info-icon:hover .popular-header-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Desktop: position tooltip from left */
@media (min-width: 640px) {
    .popular-header-tooltip {
        left: 0;
        right: auto;
        width: 200px;
    }
    
    .popular-header-tooltip::before {
        left: 12px;
        right: auto;
    }
}

/* ========================================
   Most Popular Card
   ======================================== */
.popular-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.2s ease;
}

@media (hover: hover) {
    .popular-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }
}

@media (min-width: 640px) {
    .popular-card {
        padding: 16px 14px;
    }
}

@media (min-width: 768px) {
    .popular-card {
        padding: 18px 16px;
    }
}

/* Name */
.popular-name-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 6px;
    width: 100%;
}

.popular-name {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100px;
}

@media (min-width: 360px) {
    .popular-name {
        max-width: 110px;
    }
}

@media (min-width: 480px) {
    .popular-name {
        font-size: 14px;
        max-width: 120px;
    }
}

@media (min-width: 640px) {
    .popular-name {
        max-width: none;
    }
}

.popular-name:hover {
    color: #6366f1;
}

/* Info icon */
.popular-info {
    position: relative;
    flex-shrink: 0;
}

.popular-info-svg {
    width: 12px;
    height: 12px;
    color: #9ca3af;
    cursor: help;
}

.popular-tooltip {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% + 8px);
    width: max-content;
    max-width: 160px;
    padding: 8px 10px;
    background-color: #0f172a;
    color: white;
    font-size: 11px;
    line-height: 1.4;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 50;
    text-align: center;
    white-space: normal;
}

.popular-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #0f172a;
}

.popular-info:hover .popular-tooltip,
.group:hover .popular-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Price */
.popular-price {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 10px;
    min-height: 18px;
}

@media (min-width: 480px) {
    .popular-price {
        font-size: 13px;
    }
}

.popular-price-free {
    color: #10b981;
    font-weight: 500;
}

.popular-price-amount {
    color: #374151;
}

.popular-price-unit {
    color: #9ca3af;
    font-size: 11px;
}

.popular-price-request {
    color: #6366f1;
    text-decoration: none;
    font-size: 11px;
}

.popular-price-request:hover {
    text-decoration: underline;
}

/* CTA Button */
.popular-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 12px;
    background-color: #6366f1;
    color: white;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    text-decoration: none;
    transition: background-color 0.2s ease;
    gap: 4px;
    min-height: 36px;
}

@media (min-width: 480px) {
    .popular-btn {
        padding: 9px 14px;
        font-size: 13px;
        min-height: 40px;
    }
}

.popular-btn:hover {
    background-color: #4f46e5;
}

.popular-btn-text {
    white-space: nowrap;
}

.popular-btn-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* ========================================
   Category Header Responsive
   ======================================== */
.category-header-title {
    font-size: 24px;
    font-weight: 900;
    color: #0f172a;
    line-height: 1.2;
}

@media (min-width: 480px) {
    .category-header-title {
        font-size: 28px;
    }
}

@media (min-width: 640px) {
    .category-header-title {
        font-size: 32px;
    }
}

@media (min-width: 768px) {
    .category-header-title {
        font-size: 36px;
    }
}

/* ========================================
   Sort Controls Responsive
   ======================================== */
.sort-controls-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sort-select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
}

@media (min-width: 480px) {
    .sort-controls-wrap {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .sort-select {
        width: auto;
        min-width: 180px;
    }
}

/* ========================================
   Touch Device Optimizations
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    /* Disable hover effects on touch devices */
    .popular-card:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* Make tooltips work on tap */
    .popular-info {
        cursor: pointer;
    }
    
    .popular-tooltip {
        left: auto;
        right: -8px;
        transform: none;
    }
    
    .popular-tooltip::after {
        left: auto;
        right: 12px;
        transform: none;
    }
}

/* ========================================
   Sidebar Filter Responsive
   ======================================== */
#filter-sidebar {
    transition: transform 0.3s ease;
}

@media (max-width: 1023px) {
    #filter-sidebar.fixed {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: white !important;
        z-index: 50 !important;
        overflow-y: auto !important;
        padding: 16px !important;
        transform: translateX(0) !important;
    }
    
    #filter-sidebar.hidden {
        display: none;
    }
}

/* Filter overlay */
#filter-overlay {
    transition: opacity 0.3s ease;
}

/* ========================================
   Product Cards Grid Responsive
   ======================================== */
.products-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 640px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .products-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Mobile Filter Toggle Button
   ======================================== */
#mobile-filter-toggle {
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
}

/* ========================================
   Breadcrumb Responsive
   ======================================== */
@media (max-width: 400px) {
    nav.flex.items-center span.font-medium {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ========================================
   Stats Section Responsive
   ======================================== */
@media (max-width: 400px) {
    .flex.flex-wrap.items-center.gap-4 {
        gap: 8px 16px;
    }
}

/* ========================================
   Pagination Responsive
   ======================================== */
.pagination-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
}

@media (max-width: 480px) {
    .pagination-container a,
    .pagination-container span {
        min-width: 36px;
        min-height: 36px;
        padding: 6px 10px;
        font-size: 13px;
    }
}

/* ========================================
   Safe Areas (for notched phones)
   ======================================== */
@supports (padding: max(0px)) {
    #filter-sidebar.fixed {
        padding-top: max(16px, env(safe-area-inset-top)) !important;
        padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
        padding-left: max(16px, env(safe-area-inset-left)) !important;
        padding-right: max(16px, env(safe-area-inset-right)) !important;
    }
}

/* ========================================
   Reduced Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .popular-card,
    .card-hover,
    #filter-sidebar,
    #filter-overlay,
    .desc-btn svg,
    .popular-tooltip,
    .popular-header-tooltip {
        transition: none !important;
    }
}