/**
 * Layout Styles
 * 
 * Hybrid Layout: Full-width header/footer, boxed content
 * Dark Mode: Admin-controlled site-wide setting
 * 
 * @package Commerce_Elite
 */

/* ============================================
   DARK MODE SUPPORT
   Admin controls site-wide - no user toggle
   ============================================ */

/* Dark mode color overrides */
body.dark-mode {
    --color-background: #0a0a0a;
    --color-surface: #1a1a1a;
    --color-surface-dark: #2a2a2a;
    
    --color-text: #e5e5e5;
    --color-text-light: #b5b5b5;
    --color-text-muted: #8a8a8a;
    
    --color-border: #333333;
    --color-border-light: #2a2a2a;
    
    /* Adjust primary colors for dark mode visibility */
    --color-primary: #4f94d4;
    --color-primary-dark: #72aee6;
    --color-primary-light: #2271b1;
    
    /* Keep success/error/warning visible */
    --color-success: #4ade80;
    --color-error: #f87171;
    --color-warning: #fbbf24;
    
    /* Adjust shadows for dark mode */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5), 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6), 0 8px 10px rgba(0, 0, 0, 0.4);
    --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.7);
}

/* Dark mode images - slight opacity reduction */
body.dark-mode img:not(.no-dark-filter) {
    opacity: 0.9;
}

body.dark-mode img:hover {
    opacity: 1;
}

/* ============================================
   BASE LAYOUT STRUCTURE
   ============================================ */

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--color-background);
    transition: background-color 0.3s ease;
}

/* Main site wrapper */
#page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================
   HEADER (Full Width)
   ============================================ */

.site-header {
    width: 100%;
    background: var(--color-background);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    transition: all 0.3s ease;
}

/* Header scrolled state - add shadow */
.site-header.scrolled {
    box-shadow: var(--shadow-md);
}

/* Top bar (optional - for announcements, social links) */
.top-bar {
    width: 100%;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    font-size: var(--font-size-sm);
    padding: 0.5rem 0;
}

.top-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar-left,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.top-bar-left p,
.top-bar-right p {
    margin: 0;
    color: var(--color-text-light);
}

.top-bar-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 1.5rem;
}

.top-bar-menu li a {
    color: var(--color-text-light);
    font-size: var(--font-size-sm);
}

.top-bar-menu li a:hover {
    color: var(--color-primary);
}

/* Main header */
.main-header {
    padding: 1rem 0;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

/* Logo area */
.site-branding {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.custom-logo-link {
    display: block;
    line-height: 0;
}

.custom-logo {
    height: 50px;
    width: auto;
    max-width: 200px;
}

.site-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    margin: 0;
    line-height: 1;
}

.site-title a {
    color: var(--color-text);
}

/* Navigation area - grows to take space */
.main-navigation {
    flex-grow: 1;
    display: flex;
    justify-content: center;
}

/* Header actions (cart, account, mobile toggle) */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.woo-header-icons {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-icon-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--color-text);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.header-icon-link:hover {
    background: var(--color-surface);
    color: var(--color-primary);
}

.header-icon-link .icon {
    width: 24px;
    height: 24px;
}

.cart-count {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--color-accent);
    color: #ffffff;
    font-size: 11px;
    font-weight: var(--font-weight-bold);
    border-radius: var(--radius-full);
    line-height: 1;
}

/* ============================================
   MAIN CONTENT (Boxed)
   ============================================ */

#main {
    flex: 1;
    width: 100%;
    padding: 3rem 0;
}

/* Content wrapper - boxed */
.site-content {
    max-width: var(--container-lg);
    margin: 0 auto;
    padding: 0 var(--space-sm);
}


/* Full-width sections within content */
.full-width-section {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: calc(50vw - 50%);
    padding-right: calc(50vw - 50%);
}

/* Hero section (full width) */
.hero-section {
    width: 100%;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding: 4rem calc(50vw - 50%);
    background: var(--color-surface);
}

/* ============================================
   SIDEBAR LAYOUT (if needed)
   ============================================ */

.content-area-with-sidebar {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 3rem;
}

.content-area {
    min-width: 0; /* Prevent overflow */
}

.widget-area {
    position: sticky;
    top: calc(var(--header-height, 80px) + 2rem);
    height: fit-content;
}

@media (max-width: 1024px) {
    .content-area-with-sidebar {
        grid-template-columns: 1fr;
    }
    
    .widget-area {
        position: static;
    }
}

/* ============================================
   FOOTER (Full Width)
   ============================================ */

/* Override theme footer when using custom footer */
.footer-widgets .container {
    max-width: none !important;
    padding: 0 !important;
    display: block !important; /* Remove grid layout */
    grid-template-columns: none !important;
    gap: 0 !important;
}

.footer-widget-area {
    width: 100% !important;
}

/* Hide theme's copyright section (since you have your own footer) */
.footer-bottom {
    display: none !important;
}

/* ============================================
   WOOCOMMERCE SHOP LAYOUT
   ============================================ */

/* Shop header (category H1, intro, breadcrumbs) */
.woocommerce-products-header {
    margin-bottom: 2rem;
}

/* Category header section (Custom H1 + Intro) */
.category-header-section,
.brand-header-section {
    margin-bottom: 2rem;
}

/* Shop controls (result count + sorting) */
.shop-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--color-surface);
    border-radius: var(--radius-md);
}

/* Products grid - responsive */
.products {
    display: grid;
    gap: 2rem;
    margin: 2rem 0;
}

/* Desktop: 4 products per row */
@media (min-width: 1024px) {
    .products {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Tablet: 3 products per row */
@media (min-width: 768px) and (max-width: 1023px) {
    .products {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile: 2 products per row */
@media (max-width: 767px) {
    .products {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* Long-form content after products */
.category-long-content,
.brand-long-content {
    max-width: var(--container-md);
    margin: 4rem auto 0;
}

/* ============================================
   SINGLE PRODUCT LAYOUT
   ============================================ */

.single-product-wrapper {
    max-width: var(--container-lg);
    margin: 0 auto;
}

/* Product main content (images + summary) */
.product-main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    margin-bottom: 3rem;
}

.product-images-wrapper {
    position: sticky;
    top: calc(var(--header-height, 80px) + 2rem);
    height: fit-content;
}

@media (max-width: 1024px) {
    .product-main-content {
        grid-template-columns: 1fr;
    }
    
    .product-images-wrapper {
        position: static;
    }
}

/* ============================================
   CART & CHECKOUT LAYOUT
   ============================================ */

/* Removed duplicate max-width - already handled by .container wrapper */
.woocommerce-cart,
.woocommerce-checkout {
    /* Container wrapper already provides max-width and centering */
}

/* DISABLED - /* Cart layout - table + sidebar */


/* Checkout layout - 2 columns */
.checkout-details-wrapper {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 3rem;
}

@media (max-width: 1024px) {
    .checkout-details-wrapper {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   BLOG LAYOUT
   ============================================ */

/* Blog archive */
.blog-posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

/* Single post */
.single-post .site-content {
    max-width: var(--container-md);
}

/* ============================================
   RESPONSIVE LAYOUT
   ============================================ */

@media (max-width: 768px) {
    /* Header */
    .main-header {
        padding: 0.75rem 0;
    }
    
    .custom-logo {
        height: 40px;
    }
    
    /* Main content */
    #main {
        padding: 2rem 0;
    }
    
    /* Footer */
    .footer-widgets .container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .footer-bottom .container {
        flex-direction: column;
        text-align: center;
    }
    
    /* Blog grid */
    .blog-posts-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Spacing utilities */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--space-xs) !important; }
.mt-2 { margin-top: var(--space-sm) !important; }
.mt-3 { margin-top: var(--space-md) !important; }
.mt-4 { margin-top: var(--space-lg) !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--space-xs) !important; }
.mb-2 { margin-bottom: var(--space-sm) !important; }
.mb-3 { margin-bottom: var(--space-md) !important; }
.mb-4 { margin-bottom: var(--space-lg) !important; }

.pt-0 { padding-top: 0 !important; }
.pt-1 { padding-top: var(--space-xs) !important; }
.pt-2 { padding-top: var(--space-sm) !important; }
.pt-3 { padding-top: var(--space-md) !important; }
.pt-4 { padding-top: var(--space-lg) !important; }

.pb-0 { padding-bottom: 0 !important; }
.pb-1 { padding-bottom: var(--space-xs) !important; }
.pb-2 { padding-bottom: var(--space-sm) !important; }
.pb-3 { padding-bottom: var(--space-md) !important; }
.pb-4 { padding-bottom: var(--space-lg) !important; }

/* Display utilities */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }

/* Responsive display */
@media (max-width: 768px) {
    .d-mobile-none { display: none !important; }
    .d-mobile-block { display: block !important; }
}

@media (min-width: 769px) {
    .d-desktop-none { display: none !important; }
    .d-desktop-block { display: block !important; }
}