/**
 * Layout CSS - Core layout and component styles
 * Path: public_html/css/layout.css
 * Version: 1.4.0
 * 
 * This file contains shared layout styles used across multiple pages:
 * - Core layout and alignment (.main, .content)
 * - Sidebar layout (.main-content-with-sidebar, .filter-sidebar)
 * - Search input styles
 * - Top bar (counter, sort)
 * - Show more button
 * - Responsive styles for all above
 * 
 * Used on: homepage, all_tools, category, listing_type, new_tools, tag
 */

/* ====================================================================
   CORE LAYOUT AND ALIGNMENT
   ==================================================================== */
.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.content {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* ====================================================================
   MAIN LAYOUT STRUCTURE (Sidebar + Content)
   ==================================================================== */
.main-content-with-sidebar {
    display: flex;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.filter-sidebar {
    width: 330px;
    flex-shrink: 0;
}

.content-area {
    flex: 1;
    min-width: 0;
}

/* ====================================================================
   HOMEPAGE CONTENT PANEL - Distinct background for search/filter area
   ==================================================================== */
.page-home .main-content-with-sidebar {
    background: #f7f8fa;
    border-radius: 16px;
    padding: 24px;
    box-sizing: border-box;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

/* ====================================================================
   FILTER SIDEBAR HEADINGS
   ==================================================================== */
.filter-sidebar .filter-column h2 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    color: #333;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 8px;
    font-weight: normal;
}

/* ====================================================================
   SEARCH BOX - Updated for content area alignment
   ==================================================================== */
.content-area .search-input {
    width: 100%;
    max-width: 600px;
    padding: 12px 20px;
    margin: 0 0 20px 0;
    display: block;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    color: #333;
    transition: border-color 0.3s ease;
    text-align: left;
    box-sizing: border-box;
}

.content-area .search-input::placeholder {
    color: #888;
}

.content-area .search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* Legacy search input (in case it's used elsewhere) */
.search-input {
    width: 100%;
    max-width: 600px;
    padding: 12px 20px;
    margin: 20px auto;
    display: block;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    color: #333;
    transition: border-color 0.3s ease;
    text-align: left;
    box-sizing: border-box;
}

.search-input::placeholder {
    color: #888;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* ====================================================================
   SIDEBAR SEARCH - Search input in filter sidebar (homepage)
   ==================================================================== */
.sidebar-search {
    margin-bottom: 16px;
}

.sidebar-search .search-input {
    width: 100%;
    max-width: none;
    padding: 10px 14px;
    margin: 0;
}

/* ====================================================================
   QUICK FILTER BUTTONS - Content area (light background overrides)
   ==================================================================== */
.content-area .hero-quick-filters {
    margin-bottom: 20px;
}

.content-area .hero-filter-btn {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
    backdrop-filter: none;
}

.content-area .hero-filter-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
    transform: none;
}

.content-area .hero-filter-btn.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.content-area .hero-filter-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25);
}

/* ====================================================================
   QUICK FILTER BUTTONS - All Tools page (.quick-filter-btn)
   ==================================================================== */
.quick-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-filter-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.quick-filter-btn.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

.quick-filter-btn .filter-icon {
    display: inline-flex;
    align-items: center;
}

[data-theme="dark"] .quick-filter-btn {
    background: #333;
    color: #e4e4e4;
    border-color: #444;
}

[data-theme="dark"] .quick-filter-btn:hover {
    background: #3d3d3d;
}

[data-theme="dark"] .quick-filter-btn.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

/* ====================================================================
   DARK MODE - Sidebar search & quick filters
   ==================================================================== */
[data-theme="dark"] .page-home .main-content-with-sidebar {
    background: #1a1a1e;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .sidebar-search .search-input {
    background: #2d2d2d;
    border-color: #444;
    color: #e4e4e4;
}

[data-theme="dark"] .sidebar-search .search-input::placeholder {
    color: #777;
}

[data-theme="dark"] .content-area .hero-filter-btn {
    background: #333;
    color: #e4e4e4;
    border-color: #444;
}

[data-theme="dark"] .content-area .hero-filter-btn:hover {
    background: #3d3d3d;
    color: #ffffff;
}

[data-theme="dark"] .content-area .hero-filter-btn.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

/* ====================================================================
   HIGH CONTRAST - Quick filters
   ==================================================================== */
@media (prefers-contrast: high) {
    .content-area .hero-filter-btn {
        border: 2px solid #000;
    }

    .content-area .hero-filter-btn.active {
        border-color: #1d4ed8;
    }

    [data-theme="dark"] .content-area .hero-filter-btn {
        border-color: #fff;
    }
}

/* ====================================================================
   TOP BAR (Counter and Sort)
   ==================================================================== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.counter-container {
    font-size: 1rem;
    color: #666;
}

.sort-container select {
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: #333;
    cursor: pointer;
}

/* ====================================================================
   TOP BAR LAYOUT - Single line with proper order
   ==================================================================== */
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    min-width: 0;
}

.top-bar-left .reset-button {
    width: auto;
    flex-shrink: 0;
    white-space: nowrap;
}

.counter-container {
    white-space: nowrap;
}

/* ====================================================================
   SHOW MORE BUTTON - WCAG AA COMPLIANT
   ==================================================================== */
#showMoreBtn {
    display: none;
    margin: 20px auto;
    padding: 12px 40px;
    background: #0056b3;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    align-items: center;
    justify-content: center;
}

#showMoreBtn:not(.hidden) {
    display: flex;
}

#showMoreBtn:hover {
    background: #004085;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 86, 179, 0.2);
}

#showMoreBtn:focus {
    outline: 2px solid #0056b3;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(0, 86, 179, 0.2);
}

#showMoreBtn:disabled {
    background: #495057;
    cursor: not-allowed;
    opacity: 1;
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#showMoreBtn.hidden {
    display: none !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #showMoreBtn {
        background: #003d73;
        border: 2px solid #002752;
    }
    
    #showMoreBtn:hover {
        background: #002752;
        border-color: #001a3d;
    }
    
    #showMoreBtn:disabled {
        background: #343a40;
        border: 2px solid #1d2124;
    }
}

/* ====================================================================
   MOBILE RESPONSIVE DESIGN
   ==================================================================== */

/* Tablet responsive */
@media (min-width: 769px) and (max-width: 1024px) {
    .top-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .sort-container select {
        width: 100%;
    }
}

/* Mobile screens */
@media (max-width: 768px) {
    /* Stack layout on mobile */
    .main-content-with-sidebar {
        flex-direction: column;
        gap: 20px;
    }

    .page-home .main-content-with-sidebar {
        border-radius: 12px;
        padding: 16px;
    }
    
    .filter-sidebar {
        width: 100%;
        order: 2;
    }

    /* Homepage: sidebar (with search) appears first on mobile */
    .page-home .filter-sidebar {
        order: 0;
    }

    .content-area {
        order: 1;
    }

    /* Mobile search input styling */
    .content-area .search-input,
    .search-input {
        max-width: 100%;
        margin: 0 0 20px 0;
    }

    /* Sidebar search on mobile */
    .sidebar-search {
        padding: 0 15px;
    }

    .sidebar-search .search-input {
        max-width: 600px;
        margin: 0 auto;
    }
    
    .top-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .top-bar-left {
        flex-direction: column;
        gap: 10px;
        align-items: center;
        white-space: normal;
    }
    
    .sort-container select {
        width: 100%;
    }
    
    /* Show More Button mobile improvements */
    #showMoreBtn {
        width: 100%;
        max-width: 300px;
        margin: 20px auto;
        padding: 14px 20px;
        min-height: 44px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #showMoreBtn {
        transition: none;
    }
    
    #showMoreBtn:hover {
        transform: none;
    }
}