/*
 * DT Shop - Main Stylesheet (Final Full Version 2.2)
 * Includes: Grid Layout, Cards, Buttons, Top Bar, Quick Links, and Mobile Drawer
 */

/* ==================================================================
   1. LAYOUT: The 2-Column Container (Sidebar | Grid)
   ================================================================== */

/* Force the grid layout with high specificity */
.dt-shop-container {
    display: grid !important;
    grid-template-columns: 260px 1fr !important; /* Sidebar | Main Content */
    gap: 2.5rem !important;
    width: 100%;
    box-sizing: border-box;
    align-items: start; /* Align sidebar and grid to top */
}

/* Ensure the sidebar and main content are treated as grid items */
.dt-filter-sidebar,
.dt-shop-main-content {
    min-width: 0; /* Prevents grid blowout */
    width: auto !important; /* Reset any theme widths */
    max-width: 100% !important;
}


/* ==================================================================
   2. SIDEBAR: Filter Styles
   ================================================================== */
.dt-filter-sidebar h3 {
    font-size: 1.2rem;
    color: #111827; /* Dark text */
    margin-top: 0;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb; /* Light border */
}

.dt-filter-sidebar .dt-filter-list {
    list-style: none;
    margin: 0 0 1.5rem 0;
    padding: 0;
}

.dt-filter-sidebar .dt-filter-list li {
    margin-bottom: 0.5rem;
}

.dt-filter-sidebar .dt-filter-list label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: #4b5563;
}


/* ==================================================================
   3. GRID: The Product Showroom
   ================================================================== */
.dt-product-grid {
    display: grid;
    /* Responsive columns inside the main content area */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}


/* ==================================================================
   4. CARDS: Perfect Alignment & Content Stacking
   ================================================================== */
   
.dt-shop-product.dt-lms-course-card {
    display: flex !important;
    flex-direction: column !important;
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
    overflow: hidden;
    height: 100%; /* Equal height cards */
}

.dt-shop-product img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-bottom: 1px solid #e2e4e7;
    display: block;
}

/* Force Product Titles and Filter Labels to Black */
.dt-shop-product h4 a,
.dt-filter-list label {
    color: #111111 !important;
    text-decoration: none !important;
}

.dt-shop-product h4 a:hover {
    color: #6a4c89 !important; /* Brand Purple */
    text-decoration: underline !important;
}

/* The Content Container */
.dt-shop-container .dt-lms-course-details {
    display: flex !important;
    flex-direction: column !important;
    flex-grow: 1 !important; /* Fill remaining height */
    padding: 20px !important;
    box-sizing: border-box !important;
    align-items: flex-start !important; /* Left-align text */
}

/* Title Styling */
.dt-shop-container .dt-lms-course-details h4 {
    margin: 0 0 8px 0 !important;
    font-size: 1.2em !important;
    line-height: 1.3 !important;
    flex-grow: 0 !important; /* Do not stretch */
    width: 100%;
}

/* Star Rating (If present) */
.dt-shop-container .dt-star-rating-display {
    margin-bottom: 12px !important;
}

/* Category Badge Alignment */
.dt-shop-container .dt-hub-product-type-badge {
    margin-top: 0 !important;
    margin-bottom: 15px !important;
    align-self: flex-start !important;
    
    display: inline-block;
    background-color: #D8BFD8; 
    color: #4B0082;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
/* Prevent Footer Overlap */
.dt-shop-container {
    margin-bottom: 80px !important; /* Extra clearance for footer */
    padding-bottom: 40px;
}

/* Ensure the main content area expands correctly */
.dt-shop-main-content {
    display: flex;
    flex-direction: column;
    min-height: 400px; /* Ensures space even if few products exist */
}

/* ==================================================================
   5. FOOTER: Price + Buttons (Push to Bottom)
   ================================================================== */

.dt-shop-container .dt-lms-course-actions {
    margin-top: auto !important; 
    width: 100% !important;
    padding-top: 15px !important;
    border-top: 1px solid #f3f4f6 !important;
    
    display: flex !important;
    flex-direction: column !important; /* STACK VERTICALLY */
    align-items: stretch !important;   /* Full width buttons */
    gap: 10px !important;
}

/* Price Wrapper */
.dt-shop-container .dt-shop-price-wrapper {
    display: flex;
    flex-direction: column; 
    align-items: flex-start;
    line-height: 1.2;
    margin-bottom: 5px !important;
}

/* HIDE Price if User Owns Product */
.dt-shop-product.dt-owned .dt-shop-price-wrapper {
    display: none !important;
}

/* Button Group Stacking */
.dt-product-grid .dt-shop-button-group {
    display: flex;
    flex-direction: column !important; /* STACK VERTICALLY */
    gap: 8px;
    width: 100%;
}

.dt-product-grid .dt-hub-button,
.dt-product-grid .dt-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    
    /* Force smaller size to fit card */
    padding: 8px 16px !important; 
    font-size: 14px !important;
    line-height: 1.2 !important;
    width: auto !important;
    min-width: 100px !important;
    max-width: 100% !important;
    
    background-color: #a987c2 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 6px !important; 
    font-weight: 600 !important;
    text-decoration: none !important;
    cursor: pointer !important;
    
    margin-top: 0 !important;
    box-shadow: none !important;
}

/* Unified Card Buttons */
.dt-hub-button {
    border-radius: 50px !important; /* Round pill style */
    padding: 12px 24px !important;
    font-weight: 700 !important;
}

/* Secondary Button Reset */
.dt-hub-button--secondary {
    background-color: #f3f4f6 !important;
    border: 1px solid #d1d5db !important;
    color: #4b5563 !important;
}
.dt-product-grid .dt-hub-button:hover,
.dt-product-grid .dt-btn:hover {
    background-color: #936fad !important;
    transform: translateY(-1px);
}

/* Secondary "View" Button */
.dt-product-grid .dt-hub-button--secondary {
    background-color: #f3f4f6 !important;
    color: #4b5563 !important;
    border: 1px solid #d1d5db !important;
    
    /* Force compact size */
    padding: 8px 16px !important;
    width: auto !important; 
    min-width: 0 !important;
    
    /* Reset font styling to remove weird theme artifacts */
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    text-transform: none !important; /* Stop ALL CAPS if theme does it */
    text-decoration: none !important;
}

.dt-product-grid .dt-hub-button--secondary:hover {
    background-color: #e5e7eb !important;
    color: #111827 !important;
    border-color: #9ca3af !important;
}

/* Remove any pseudo-elements (arrows/icons) injected by the theme */
.dt-product-grid .dt-hub-button--secondary::after,
.dt-product-grid .dt-hub-button--secondary::before {
    content: none !important;
    display: none !important;
}

/* ==================================================================
   6. MOBILE RESPONSIVENESS
   ================================================================== */
@media (max-width: 900px) {
    /* Switch to single column on small screens */
    .dt-shop-container {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    /* Hide sidebar, show toggle (handled in HTML) */
    .dt-filter-sidebar {
        display: none;
    }
    
    /* Make grid 1 column on very small screens */
    .dt-product-grid {
        grid-template-columns: 1fr;
    }
    
    /* Mobile Filter Toggle Button */
    .dt-shop-mobile-filter-toggle {
        display: inline-block;
        padding: 0.75rem 1.5rem;
        font-weight: 600;
        background: #f1f5f9;
        color: #111827;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        cursor: pointer;
        margin-bottom: 1.5rem;
    }
}

/* ==================================================================
   7. TOP BAR & QUICK LINKS (THE MISSING PIECE)
   ================================================================== */

.dt-shop-top-bar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap; 
    gap: 1rem;
    width: 100%; /* Ensure it spans the grid width */
}

/* Style Top Bar and Filter Toggle */
.dt-shop-top-bar {
    background: #f9fafb;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    margin-bottom: 2rem;
}

/* Specific Style for "Filters" button */
.dt-shop-mobile-filter-toggle {
    background-color: #6a4c89 !important; /* Brand Purple */
    color: #ffffff !important;
    border: none !important;
    padding: 10px 20px !important;
    border-radius: 50px !important; /* Match brand roundness */
    font-weight: 700 !important;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dt-shop-mobile-filter-toggle:hover {
    background-color: #553b70 !important;
    transform: translateY(-1px);
}

/* Style the native select dropdown */
#dt_shop_sort_by {
    border: 1px solid #cbd5e1;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 600;
    color: #334155;
}
.dt-shop-sort-by select {
    padding: 0.5rem 0.75rem; 
    border: 1px solid #e5e7eb;
    border-radius: 8px; 
    font-weight: 600;
}

/* Quick Links (Cart / Checkout) */
.dt-shop-quick-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto; /* Push to the right */
}

.dt-shop-quick-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
    font-weight: 600;
    color: #333;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.dt-shop-quick-link:hover {
    background-color: #f1f5f9;
}

/* --- THIS FIXES THE GIANT ICONS --- */
/* Without this, SVGs fill 100% width and break the layout */
.dt-shop-quick-link svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
    display: block; 
}

@media (max-width: 480px) {
    .dt-shop-quick-link span {
        display: none; /* Hide text on very small screens */
    }
}

/* ==================================================================
   8. LOADING SPINNER
   ================================================================== */
.dt-shop-grid-wrapper {
    position: relative;
    min-height: 200px;
}

.dt-shop-loader {
    display: none; 
    position: absolute; 
    top: 0; left: 0;
    width: 100%; height: 100%; 
    background: rgba(255, 255, 255, 0.8);
    z-index: 10; 
    align-items: center; 
    justify-content: center;
    text-align: center; 
    padding-top: 100px; 
    font-weight: 600;
}

.dt-shop-loader::after {
    content: ''; 
    display: block; 
    width: 40px; height: 40px;
    margin: 1rem auto; 
    border-radius: 50%;
    border: 4px solid #ccc; 
    border-top-color: #a987c2; /* Primary Purple */
    animation: dt-shop-spin 1s linear infinite;
}

@keyframes dt-shop-spin {
    to { transform: rotate(360deg); }
}

/* ==================================================================
   9. MOBILE DRAWER (For Filters)
   ================================================================== */
.dt-shop-drawer-backdrop {
    display: none; 
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%; 
    background: rgba(0,0,0,0.5); 
    z-index: 99998;
}

.dt-shop-drawer {
    position: fixed; top: 0; left: -320px;
    width: 300px; height: 100%; 
    background: #fff; 
    z-index: 99999;
    transition: transform 0.3s ease-in-out;
    display: flex; flex-direction: column;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.dt-shop-drawer-header {
    padding: 1rem; 
    display: flex; justify-content: space-between;
    align-items: center; 
    border-bottom: 1px solid #e5e7eb;
}

.dt-shop-drawer-header h3 { margin: 0; font-size: 1.2rem; }

.dt-shop-drawer-close {
    font-size: 1.5rem; font-weight: bold; line-height: 1;
    cursor: pointer; background: none; border: none;
}

.dt-shop-drawer-content {
    padding: 1rem; overflow-y: auto; flex-grow: 1;
}

.dt-shop-drawer-footer {
    padding: 1rem; border-top: 1px solid #e5e7eb;
}

.dt-shop-drawer-apply {
    width: 100%; padding: 0.75rem; font-weight: 600;
    color: #fff; background: #111827; border: none;
    border-radius: 8px; cursor: pointer;
}

/* Drawer Open State */
body.dt-shop-drawer-open .dt-shop-drawer {
    transform: translateX(320px);
}
body.dt-shop-drawer-open .dt-shop-drawer-backdrop {
    display: block;
}

/* --- CRITICAL ICON FIX --- */
.dt-shop-quick-link svg {
    width: 20px !important;
    height: 20px !important;
    display: block;
}