/* =============================================
   CATEGORIES SECTION
   ============================================= */
.categories-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    min-height: 60vh;
    position: relative;
    overflow: hidden;
}

.categories-section::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(92, 69, 191, 0.05) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 0;
}

.categories-section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(92, 69, 191, 0.03) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 0;
}

.main-container {
    position: relative;
    z-index: 1;
}

/* =============================================
   CATEGORIES HEADER
   ============================================= */
.categories-header {
    margin-bottom: 50px;
    animation: fadeInDown 0.8s ease-out;
}

.section-title {
    font-size: 42px;
    font-weight: 700;
    color: #2c2c2c;
    margin-bottom: 15px;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, #5c45bf 0%, #8b7dd8 100%);
    border-radius: 2px;
}

.section-subtitle {
    font-size: 16px;
    color: #666;
    margin-top: 20px;
    font-weight: 400;
}

/* =============================================
   CATEGORIES GRID
   ============================================= */

.categories-grid.row {
    display: flex !important;
    flex-wrap: wrap;
    margin-left: 0 !important;
    margin-right: 0 !important;
    gap: 20px;
    padding: 0 20px;
}

/* Default: 4 columns */
.category-col {
    padding: 0;
    margin: 0;
    width: calc(25% - 15px);
    flex: 0 0 calc(25% - 15px);
    max-width: calc(25% - 15px);
}

/* =============================================
   CATEGORY CARD
   ============================================= */
.category-card {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    cursor: pointer;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(92, 69, 191, 0) 0%, rgba(92, 69, 191, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 1;
    pointer-events: none;
}

.category-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 35px rgba(92, 69, 191, 0.2);
}

.category-card:hover::before {
    opacity: 1;
}

/* =============================================
   CATEGORY IMAGE
   ============================================= */
.category-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    position: relative;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    flex-shrink: 0;
}

.category-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
}

.category-card:hover .category-image img {
    transform: scale(1.08);
}

.category-image::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.25), transparent);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.category-card:hover .category-image::after {
    opacity: 1;
}

/* =============================================
   CATEGORY CONTENT
   ============================================= */
.category-content {
    padding: 20px 18px;
    position: relative;
    z-index: 2;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.category-name {
    font-size: 18px;
    font-weight: 600;
    color: #2c2c2c;
    margin-bottom: 8px;
    transition: color 0.3s ease;
    line-height: 1.3;
}

.category-card:hover .category-name {
    color: #5c45bf;
}

.category-count {
    font-size: 13px;
    color: #666;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.category-count i {
    color: #5c45bf;
    font-size: 12px;
}

.category-description {
    font-size: 13px;
    color: #888;
    line-height: 1.6;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

/* =============================================
   VIEW PRODUCTS BUTTON
   ============================================= */
.view-products-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: linear-gradient(135deg, #5c45bf 0%, #7a5dd8 100%);
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    border: none;
    align-self: flex-start;
    margin-top: auto;
}

.view-products-btn i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.view-products-btn:hover {
    background: linear-gradient(135deg, #4a36a3 0%, #6249c4 100%);
    transform: translateX(4px);
    color: #fff;
}

.view-products-btn:hover i {
    transform: translateX(3px);
}

/* =============================================
   CATEGORY BADGE
   ============================================= */
.category-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff4757 100%);
    color: #fff;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 3;
    box-shadow: 0 2px 8px rgba(255, 75, 87, 0.3);
}

.category-badge.featured {
    background: linear-gradient(135deg, #5c45bf 0%, #7a5dd8 100%);
    box-shadow: 0 2px 8px rgba(92, 69, 191, 0.3);
}

/* =============================================
   SKELETON LOADER
   ============================================= */
/* OLD */
.skeleton-card {
    pointer-events: none;
    opacity: 0.7;
}

/* NEW */
.skeleton-card {
    pointer-events: none;
}

.skeleton-card .category-content {
    gap: 0;
    padding: 20px 18px;
}

.skeleton-pulse {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: pulse 1.5s infinite;
}

.skeleton-text {
    border-radius: 4px;
}

@keyframes pulse {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* =============================================
   EMPTY & ERROR STATES
   ============================================= */
.empty-state {
    padding: 80px 20px;
    animation: fadeIn 0.6s ease-out;
}
.empty-state i { opacity: 0.3; }
.empty-state h3 {
    font-size: 28px;
    color: #2c2c2c;
    margin-bottom: 15px;
    font-weight: 600;
}
.empty-state p { font-size: 16px; margin-bottom: 20px; }

.error-state {
    padding: 80px 20px;
    animation: fadeIn 0.6s ease-out;
}
.error-state i { opacity: 0.5; }
.error-state h3 {
    font-size: 28px;
    color: #2c2c2c;
    margin-bottom: 15px;
    font-weight: 600;
}
.error-state p { font-size: 16px; margin-bottom: 20px; }

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =============================================
   RESPONSIVE BREAKPOINTS
   Every breakpoint uses calc() to account for gap
   ============================================= */

/* 1400px+ → 4 columns, gap 20px
   col = calc(25% - 15px)  [20px * 3 gaps / 4 cols = 15px per col] */
@media (min-width: 1400px) {
    .categories-grid.row { gap: 20px; }
    .category-col {
        width: calc(25% - 15px);
        flex: 0 0 calc(25% - 15px);
        max-width: calc(25% - 15px);
    }
}

/* 1200px – 1399px → 4 columns, gap 20px */
@media (min-width: 1200px) and (max-width: 1399px) {
    .categories-grid.row { gap: 20px; }
    .category-col {
        width: calc(25% - 15px);
        flex: 0 0 calc(25% - 15px);
        max-width: calc(25% - 15px);
    }
}

/* 992px – 1199px → 3 columns, gap 18px
   col = calc(33.333% - 12px)  [18px * 2 gaps / 3 cols = 12px per col] */
@media (min-width: 992px) and (max-width: 1199px) {
    .categories-grid.row { gap: 18px; }
    .category-col {
        width: calc(33.333% - 12px);
        flex: 0 0 calc(33.333% - 12px);
        max-width: calc(33.333% - 12px);
    }
    .section-title    { font-size: 36px; }
    .category-image   { height: 185px; }
    .category-name    { font-size: 17px; }
    .categories-section::before,
    .categories-section::after { width: 350px; height: 350px; }
}

/* 768px – 991px → 2 columns, gap 16px
   col = calc(50% - 8px)  [16px * 1 gap / 2 cols = 8px per col] */
@media (min-width: 768px) and (max-width: 991px) {
    .categories-grid.row { gap: 16px; }
    .category-col {
        width: calc(33.333% - 11px);
        flex: 0 0 calc(33.333% - 11px);
        max-width: calc(33.333% - 11px);
    }
    .section-title    { font-size: 32px; }
    .section-subtitle { font-size: 15px; }
    .category-image   { height: 180px; }
    .category-name    { font-size: 17px; }
    .categories-section::before,
    .categories-section::after { width: 280px; height: 280px; }
}

/* 576px – 767px → 2 columns, gap 14px
   col = calc(50% - 7px)  [14px * 1 gap / 2 cols = 7px per col] */
@media (min-width: 576px) and (max-width: 767px) {
    .categories-grid.row { gap: 14px; }
    .category-col {
        width: calc(50% - 7px);
        flex: 0 0 calc(50% - 7px);
        max-width: calc(50% - 7px);
    }
    .section-title        { font-size: 28px; }
    .section-subtitle     { font-size: 14px; }
    .category-image       { height: 155px; }
    .category-content     { padding: 15px 13px; }
    .category-name        { font-size: 15px; }
    .category-count       { font-size: 12px; margin-bottom: 8px; }
    .category-description { font-size: 12px; -webkit-line-clamp: 1; margin-bottom: 10px; }
    .view-products-btn    { padding: 8px 12px; font-size: 12px; }
    .categories-section::before,
    .categories-section::after { display: none; }
}

/* up to 575px → 1 column */
@media (max-width: 575px) {
    .categories-section   { padding: 40px 0; }
    .categories-header    { margin-bottom: 30px; }
    .section-title        { font-size: 26px; }
    .section-title::after { width: 60px; height: 3px; }
    .section-subtitle     { font-size: 14px; margin-top: 15px; }

    .categories-grid.row  { gap: 16px; }
    .category-col {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }

    .category-card {
        border-radius: 12px;
        max-width: 480px;
        margin: 0 auto;
    }

    .category-image       { height: 190px; }
    .category-content     { padding: 18px 15px; }
    .category-name        { font-size: 18px; margin-bottom: 6px; }
    .category-count       { font-size: 13px; margin-bottom: 10px; }
    .category-description { font-size: 13px; margin-bottom: 12px; }

    .view-products-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
        font-size: 14px;
    }

    .category-badge {
        top: 10px;
        right: 10px;
        padding: 4px 10px;
        font-size: 10px;
    }

    .empty-state,
    .error-state            { padding: 60px 15px; }
    .empty-state h3,
    .error-state h3         { font-size: 22px; }
    .empty-state p,
    .error-state p          { font-size: 14px; }

    .categories-section::before,
    .categories-section::after { display: none; }
}

/* up to 375px → tiny phones */
@media (max-width: 375px) {
    .section-title    { font-size: 22px; }
    .category-image   { height: 165px; }
    .category-name    { font-size: 16px; }
    .category-content { padding: 14px 12px; }
    .view-products-btn { padding: 10px 14px; font-size: 12px; }
}

/* Touch devices: disable hover lift */
@media (hover: none) {
    .category-card:hover {
        transform: none;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    }
    .category-card:hover .category-image img {
        transform: none;
    }
    .category-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Print */
@media print {
    .categories-section::before,
    .categories-section::after { display: none; }
    .category-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    .view-products-btn { display: none; }
}