/**
 * Hanbali LearnDash Filter - Frontend Styles
 * Main stylesheet for the LearnDash course filtering system
 * 
 * @package Hanbali LearnDash Filter
 * @version 1.0.0
 */

/* ========================================
   Base Styles
   ======================================== */

* {
    box-sizing: border-box;
}

/* ========================================
   Filter Container & Layout
   ======================================== */

.course-filter-container {
    display: flex;
    gap: 2rem;
    padding: 1rem;
    flex-wrap: wrap;
}

.filter-toggle-mobile {
    display: none;
}

.course-filter-sidebar {
    width: 300px;
    flex-shrink: 0;
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ========================================
   Filter Sections
   ======================================== */

.filter-section {
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: #1b3f40;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.category-name {
    font-size: 0.95rem;
}

.count {
    color: #666;
    font-size: 0.85rem;
}

/* Search Input */
input[name='search'] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 0.375rem;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s;
}

input[name='search']:focus {
    outline: none;
    border-color: #1b3f40;
    box-shadow: 0 0 0 3px rgba(27, 63, 64, 0.1);
}

/* ========================================
   Buttons
   ======================================== */

.apply-filters-btn {
    width: 100%;
    padding: 0.75rem;
    background: #1b3f40;
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.apply-filters-btn:hover {
    background: #2a5e60;
}

/* ========================================
   Course Grid & Results
   ======================================== */

.grouped-courses {
    flex: 1 1 0%;
    width: 100%;
}

.course-grid {
    width: 100%;
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(3, 1fr);
}

/* ========================================
   Course Cards
   ======================================== */

.course-card {
    background: white;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    padding: 1rem;
    position: relative;
    border: 1px solid #eee;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.course-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.course-image {
    padding: 1px;
}

.course-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0.5rem;
}

.course-title {
    padding: 1rem 0 0 0;
    margin: 0;
    font-size: 1.1rem;
    color: #1b3f40;
}

.course-link {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.course-price {
    margin-top: auto;
    padding-top: 0.5rem;
}

.course-status-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: #007bff;
    color: white;
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 3px;
    z-index: 10;
}

.course-status-badge.enrolled {
    background-color: #28a745;
}

.course-status-badge.not-enrolled {
    background-color: #3575dc;
}

/* ========================================
   Skeleton Loader
   ======================================== */

.skeleton-loader {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
}

.skeleton-card {
    background: white;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    border: 1px solid #eee;
}

.skeleton-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 0.5rem;
}

.skeleton-title {
    width: 80%;
    height: 20px;
    margin-top: 1rem;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-price {
    width: 40%;
    height: 16px;
    margin-top: 0.5rem;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========================================
   Animations
   ======================================== */

.fade-in {
    animation: fadeIn 0.4s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ========================================
   No Results State
   ======================================== */

.no-results-container {
    text-align: center;
    padding: 3rem 1rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.no-results-icon {
    font-size: 4rem;
    color: #ccc;
    margin-bottom: 1rem;
}

.no-results-title {
    font-size: 1.5rem;
    color: #1b3f40;
    margin-bottom: 0.5rem;
}

.no-results-message {
    color: #666;
    margin-bottom: 1.5rem;
}

.no-results-suggestions {
    text-align: left;
    max-width: 500px;
    margin: 0 auto 1.5rem;
    color: #555;
}

.no-results-suggestions ul {
    list-style-position: inside;
}

.no-results-suggestions li {
    margin-bottom: 0.5rem;
}

/* ========================================
   Responsive Design - Tablet
   ======================================== */

@media (max-width: 1024px) {
    .course-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .skeleton-loader {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========================================
   Responsive Design - Mobile
   ======================================== */

@media (max-width: 768px) {
    .course-filter-container {
        flex-direction: column;
        padding: 0.5rem;
    }

    /* Mobile Filter Button */
    .filter-toggle-mobile {
        display: block;
        margin-bottom: 1rem;
        position: sticky;
        top: 0;
        z-index: 999;
        background: white;
        padding: 0.5rem 0;
    }

    .filter-toggle-btn {
        width: 100%;
        padding: 1rem;
        background: #1b3f40;
        color: white;
        border: none;
        border-radius: 0.5rem;
        font-weight: 600;
        font-size: 1rem;
        cursor: pointer;
        transition: all 0.3s;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        min-height: 48px; /* Thumb-friendly tap target */
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .filter-toggle-btn:active {
        transform: scale(0.98);
        background: #2a5e60;
    }

    /* Bottom Sheet Drawer */
    .course-filter-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 80vh;
        background: white;
        border-radius: 1rem 1rem 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        overflow-y: auto;
        padding: 1rem;
        display: block; /* Always in DOM for animations */
    }

    .course-filter-sidebar.active {
        transform: translateY(0);
    }

    /* Drawer Handle */
    .course-filter-sidebar::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #ccc;
        border-radius: 2px;
        margin: 0 auto 1rem;
    }

    /* Backdrop Overlay */
    .filter-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
        z-index: 999;
    }

    .filter-backdrop.active {
        opacity: 1;
        visibility: visible;
    }

    /* Optimize filter sections for mobile */
    .filter-section {
        margin-bottom: 1.25rem;
    }

    .section-title {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }

    .category-item {
        padding: 0.5rem 0;
        min-height: 44px; /* Thumb-friendly */
        align-items: center;
    }

    .category-item input[type="checkbox"] {
        min-width: 20px;
        min-height: 20px;
    }

    .category-name {
        font-size: 1rem;
    }

    /* Mobile-optimized buttons */
    .apply-filters-btn {
        min-height: 48px; /* Thumb-friendly */
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    /* Prevent double-tap zoom on buttons */
    .apply-filters-btn,
    .filter-toggle-btn,
    .category-item {
        touch-action: manipulation;
    }

    /* Mobile-optimized search input */
    input[name='search'] {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 1rem;
        min-height: 48px;
    }

    /* Course cards on mobile */
    .course-card {
        padding: 0.75rem;
    }

    .course-title {
        font-size: 1rem;
        padding: 0.75rem 0 0 0;
    }

    .course-status-badge {
        font-size: 12px;
        padding: 4px 8px;
    }
}

@media (max-width: 640px) {
    .course-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .skeleton-loader {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .course-filter-container {
        padding: 0.25rem;
    }

    .no-results-container {
        padding: 2rem 1rem;
    }

    .no-results-icon {
        font-size: 3rem;
    }

    .no-results-title {
        font-size: 1.25rem;
    }
}

/* ========================================
   Accessibility - Reduced Motion
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .course-filter-sidebar,
    .filter-backdrop,
    .course-card,
    .apply-filters-btn,
    .filter-toggle-btn {
        transition: none;
    }

    .fade-in {
        animation: none;
    }

    @keyframes skeleton-loading {
        0%, 100% {
            background-position: 0 0;
        }
    }
}
