/**
 * Catalog Categories Grid - Modern Style
 * WebDirect Romania - 2025
 */

/* =========================
   MAIN SECTION
   ========================= */
.catalog-categories-section {
    background: #f8f9fa;
    min-height: 60vh;
}

.catalog-categories-title {
    font-size: 32px;
    font-weight: 700;
    color: #333;
    line-height: 1.4;
    margin-bottom: 40px;
}

/* =========================
   CATEGORIES GRID
   ========================= */
.categories-grid-modern {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 30px;
    position: relative;
}

.category-card-modern {
    position: relative;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    z-index: 1;
}

.category-card-modern:hover {
    border-color: #0066ff;
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.15);
    transform: translateY(-4px);
    z-index: 1001;
}

.category-link-modern {
    text-decoration: none;
    color: inherit;
    display: block;
}

.category-image-wrapper {
    width: 100%;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    overflow: hidden;
}

.category-image-modern {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.category-card-modern:hover .category-image-modern {
    transform: scale(1.05);
}

.category-title-modern {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
    line-height: 1.4;
    word-wrap: break-word;
}

.category-card-modern:hover .category-title-modern {
    color: #0066ff;
}

/* =========================
   SUBCATEGORIES POPUP/DROPDOWN
   ========================= */
/* Overlay pentru popup */
.subcategories-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999998 !important;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

.subcategories-popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

.subcategories-popup-modern,
.subcategories-dropdown-modern {
    position: fixed;
    top: 10vh;
    left: 10vw;
    transform: none;
    background: #fff;
    border: 2px solid #0066ff;
    border-radius: 12px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
    padding: 40px 50px;
    z-index: 9999999 !important;
    transition: all 0.3s ease;
    width: 80vw;
    max-width: 80vw;
    min-width: 80vw;
    max-height: 80vh;
    overflow-y: auto;
}

/* Desktop hover - only for dropdown-modern (legacy) */
.category-card-modern:hover .subcategories-dropdown-modern {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* Close button - hidden on desktop */
.subcategories-close-btn {
    display: flex;
    position: absolute;
    top: 20px;
    right: 20px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s ease;
    padding: 0;
}

.subcategories-close-btn:hover {
    background: #e0e0e0;
    border-color: #999;
    transform: scale(1.1);
}

.subcategories-close-btn:hover {
    background: #e0e0e0;
}

.subcategories-close-btn i {
    color: #666;
    font-size: 20px;
    font-weight: bold;
}

.subcategories-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    align-items: start;
}

.subcategory-column {
    min-width: 0;
}

.subcategory-header {
    font-size: 24px;
    font-weight: 700;
    color: #ff6b00;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 3px solid #ff6b00;
    white-space: nowrap;
}

.subcategory-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.subcategory-list li {
    margin-bottom: 6px;
}

.subcategory-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    color: #333;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-height: 48px;
}

.subcategory-link:hover {
    background: #f0f7ff;
    color: #0066ff;
    padding-left: 16px;
}

.subcategory-link i {
    font-size: 10px;
    margin-left: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.subcategory-link:hover i {
    opacity: 1;
}

/* =========================
   SEARCH BOX
   ========================= */
.category-search-wrapper {
    max-width: 600px;
    margin: 0 auto 40px;
}

.search-box-container {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    z-index: 10;
}

.category-search-input {
    padding-left: 45px;
    padding-right: 40px;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    font-size: 16px;
    height: 50px;
}

.category-search-input:focus {
    border-color: #0066ff;
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.clear-search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    color: #999;
    padding: 5px;
}

.clear-search-btn:hover {
    color: #333;
}

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 1200px) {
    .subcategories-dropdown-modern {
        min-width: 500px;
        max-width: 700px;
    }
    
    .subcategories-columns {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .catalog-categories-title {
        font-size: 24px;
    }
    
    .categories-grid-modern {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .category-image-wrapper {
        height: 120px;
    }
    
    .category-title-modern {
        font-size: 14px;
    }
    
        /* Allow clicks on mobile - removed pointer-events: none */
    
    .subcategories-popup-modern,
    .subcategories-dropdown-modern {
        width: 90vw !important;
        min-width: 90vw !important;
        max-width: 90vw !important;
        left: 5vw !important; /* Center it: (100vw - 90vw) / 2 = 5vw */
        right: auto !important;
        transform: none !important;
        position: fixed !important;
        top: 5vh !important;
        bottom: auto !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 30px 25px !important;
    }
    
    .subcategories-close-btn {
        display: flex !important; /* Show close button on mobile */
    }
    
    /* Mobile styles are handled by Alpine.js x-show */
    
    .subcategories-columns {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (max-width: 576px) {
    .catalog-categories-title {
        font-size: 20px;
        margin-bottom: 30px;
    }
    
    .categories-grid-modern {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .category-image-wrapper {
        height: 100px;
    }
    
    .category-title-modern {
        font-size: 13px;
    }
}

