/**
 * Aksespedia Main Theme Styles
 * Strictly adhering to Aksespedia Design System Guidelines
 */

@import url('tokens.css');
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700&family=Roboto:wght@400;500;700;900&display=swap');

/* Base Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-surface-page);
    color: var(--color-text-primary);
    font-family: var(--font-family-primary);
    font-size: var(--font-size-md);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--motion-duration-base) ease, color var(--motion-duration-base) ease;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   3. LAYOUT & STRUCTURE
   ========================================================================== */

.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.site-main-container {
    display: flex;
    padding-top: var(--header-height);
    padding-bottom: calc(var(--magic-nav-height) + 30px);
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .site-main-container {
        padding-bottom: var(--space-7);
    }
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: var(--space-6);
}

/* ==========================================================================
   4.2 HEADER (Fixed, 64px)
   ========================================================================== */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--color-surface-card);
    border-bottom: 1px solid var(--color-border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    z-index: 50;
    transition: background-color var(--motion-duration-base) ease, border-color var(--motion-duration-base) ease;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.header-logo {
    max-width: 160px;
    height: 28px;
    object-fit: contain;
}

.header-brand-text {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-brand);
    letter-spacing: -0.5px;
}

.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

@media (min-width: 768px) {
    .sidebar-toggle-btn {
        display: none;
    }
}

.header-search-form {
    flex: 1;
    max-width: 480px;
    margin: 0 var(--space-6);
    position: relative;
}

@media (max-width: 639px) {
    .header-search-form {
        display: none;
    }
}

.header-search-input {
    width: 100%;
    height: 40px;
    background-color: var(--color-surface-raised);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-full);
    padding: 0 16px 0 42px;
    color: var(--color-text-primary);
    transition: all var(--motion-duration-fast) ease;
}

.header-search-input:focus {
    outline: none;
    border-color: var(--color-brand-500);
    background-color: var(--color-surface-card);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.search-icon-inside {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
    pointer-events: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.theme-toggle-btn, .user-avatar-link {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-full);
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all var(--motion-duration-fast) ease;
}

.theme-toggle-btn:hover, .user-avatar-link:hover {
    background-color: var(--color-surface-raised);
}

.user-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    object-fit: cover;
}

/* ==========================================================================
   4.3 SIDEBAR KATEGORI (240px on md+)
   ========================================================================== */

.site-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background-color: var(--color-surface-card);
    border-right: 1px solid var(--color-border-default);
    padding: var(--space-6) var(--space-4);
    height: calc(100vh - var(--header-height));
    position: sticky;
    top: var(--header-height);
    overflow-y: auto;
    display: none;
}

@media (min-width: 768px) {
    .site-sidebar {
        display: block;
    }
}

.sidebar-title {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-3);
    padding: 0 var(--space-3);
    letter-spacing: 0.5px;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.sidebar-menu-item a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    transition: all var(--motion-duration-fast) ease;
}

.sidebar-menu-item a:hover {
    background-color: var(--color-surface-raised);
}

.sidebar-menu-item.active a {
    background-color: var(--color-brand-50);
    color: var(--color-brand-600);
    font-weight: var(--font-weight-bold);
}

/* Mobile Drawer Overlay */
.sidebar-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 90;
}

.sidebar-drawer-backdrop.active {
    display: block;
}

/* ==========================================================================
   4.4 FILTER CHIPS (Mobile Horizontal Scroll)
   ========================================================================== */

.filter-chips-container {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-6);
    scrollbar-width: none;
}

.filter-chips-container::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: var(--space-2) var(--space-5);
    background-color: var(--color-surface-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    cursor: pointer;
    min-height: 38px;
    transition: all var(--motion-duration-fast) ease;
}

.filter-chip:hover {
    border-color: var(--color-brand-500);
    color: var(--color-text-primary);
}

.filter-chip.chip-active {
    background-color: var(--color-brand-500);
    border-color: var(--color-brand-500);
    color: #ffffff;
    font-weight: var(--font-weight-semibold);
}

/* ==========================================================================
   4.6 COMMISSION BANNER (5s interval ticker)
   ========================================================================== */

.commission-banner {
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-6);
    margin-bottom: var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--motion-duration-base) ease;
}

.commission-banner.state-emerald {
    background-color: var(--color-brand-50);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.commission-banner.state-sky {
    background-color: rgba(14, 165, 233, 0.1);
    border: 1px solid rgba(14, 165, 233, 0.3);
}

.commission-banner-content {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.commission-banner-badge {
    padding: var(--space-1) var(--space-3);
    background-color: var(--color-brand-500);
    color: #ffffff;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    border-radius: var(--radius-xs);
    text-transform: uppercase;
}

.commission-banner-title {
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    font-weight: var(--font-weight-medium);
}

.commission-banner-amount {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-black);
    color: var(--color-text-brand);
}

/* ==========================================================================
   3.3 PRODUCT GRID (2 col mobile, 3-5 col desktop)
   ========================================================================== */

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-6);
}

@media (min-width: 640px) {
    .product-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .product-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

/* ==========================================================================
   4.1 PRODUCT CARD (4:3 Thumbnail, Badge Komisi, Vendor Avatar)
   ========================================================================== */

/* Dark mode: Badge Komisi di dalam product card */
html.dark .product-card .commission-badge-inline,
html.dark .product-card span.bg-emerald-50,
html.dark .product-card .sjc-share-btn {
    background-color: rgba(6, 78, 59, 0.25) !important;
    color: #ffffff !important;
}

html.dark .product-card span.bg-emerald-50:hover,
html.dark .product-card .commission-badge-inline:hover {
    background-color: rgba(6, 78, 59, 0.45) !important;
}

/* Fallback: target badge komisi via attribute selector jika class tidak eksak */
html.dark .product-card span[class~="bg-emerald-50"][class~="text-emerald-700"] {
    background-color: rgba(6, 78, 59, 0.25) !important;
    color: #ffffff !important;
}

.product-card {
    background-color: var(--color-surface-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: transform var(--motion-duration-base) var(--motion-ease-spring), box-shadow var(--motion-duration-base) ease;
    position: relative;
}

/* Modal Social Icons (Bypass Tailwind JIT for robustness) */
.modal-social-wa { color: #25D366; }
.modal-social-fb { color: #1877F2; }
.modal-social-tg { color: #229ED9; }
html.dark .modal-social-wa,
html.dark .modal-social-fb,
html.dark .modal-social-tg { color: #ffffff !important; }

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--color-brand-500);
}

.product-card-thumbnail-wrap {
    position: relative;
    width: 100%;
    padding-top: 75%; /* 4:3 Aspect Ratio */
    background-color: var(--color-surface-raised);
    overflow: hidden;
}

.product-card-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--motion-duration-base) ease;
}

.product-card:hover .product-card-thumbnail {
    transform: scale(1.04);
}

.product-card-commission-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: var(--color-brand-500);
    color: #ffffff;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-xs);
    box-shadow: var(--shadow-sm);
    z-index: 2;
}

.product-card-vendor-avatar {
    position: absolute;
    bottom: -16px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    border: 2px solid var(--color-surface-card);
    background-color: var(--color-surface-card);
    object-fit: cover;
    box-shadow: var(--shadow-md);
    z-index: 3;
}

.product-card-body {
    padding: calc(var(--space-6) + 4px) var(--space-4) var(--space-4) var(--space-4);
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-card-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    margin-bottom: var(--space-2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 38px;
    line-height: 1.4;
}

.product-card-price-row {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    margin-top: auto;
}

.product-card-price {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-brand);
}

.product-card-original-price {
    font-size: var(--font-size-xs);
    color: var(--color-danger-500);
    text-decoration: line-through;
}

.product-card-cta-btn {
    width: 100%;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-brand-500);
    color: #ffffff;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: background-color var(--motion-duration-fast) ease;
}

.product-card-cta-btn:hover {
    background-color: var(--color-brand-600);
}

/* ==========================================================================
   4.7 BUTTONS
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 0 var(--space-6);
    border-radius: var(--radius-sm);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-md);
    cursor: pointer;
    transition: all var(--motion-duration-fast) ease;
    border: none;
}

.btn-primary {
    background-color: var(--color-brand-500);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--color-brand-600);
}

.btn-secondary {
    background-color: transparent;
    color: var(--color-text-brand);
    border: 1px solid var(--color-brand-500);
}

.btn-secondary:hover {
    background-color: var(--color-brand-50);
}

.btn-ghost {
    background-color: var(--color-surface-raised);
    color: var(--color-text-primary);
}

.btn-ghost:hover {
    background-color: var(--color-border-default);
}

/* ==========================================================================
   4.8 MAGIC NAVIGATION (Mobile Bottom Bar, 55px)
   ========================================================================== */

.magic-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--magic-nav-height);
    background-color: var(--color-surface-card);
    border-top: 1px solid var(--color-border-default);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 60;
    box-shadow: var(--shadow-lg);
}

@media (min-width: 768px) {
    .magic-nav {
        display: none;
    }
}

.magic-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: var(--color-text-secondary);
    font-family: var(--font-family-nav);
    font-size: 10.5px;
    font-weight: var(--font-weight-medium);
    gap: 3px;
    transition: color var(--motion-duration-fast) ease;
    position: relative;
}

.magic-nav-item.active {
    color: var(--color-brand-500);
    font-weight: var(--font-weight-bold);
}

.magic-nav-item svg {
    width: 20px;
    height: 20px;
}

.magic-nav-item.elevated {
    margin-top: -16px;
}

.magic-nav-item.elevated .magic-nav-icon-wrap {
    width: 44px;
    height: 44px;
    background-color: var(--color-brand-500);
    color: #ffffff;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    border: 3px solid var(--color-surface-card);
}

/* ==========================================================================
   4.5 PRODUCT QUICKVIEW / DETAIL MODAL
   ========================================================================== */
/* Note: Modal display logic is handled by Tailwind utilities (hidden/flex) via JS.
   No override needed here to avoid conflicts. */

/* Dark mode: Section "Bagikan" & Komisi Afiliasi di modal produk */
html.dark #modal-share-container {
    background: linear-gradient(to bottom right, rgba(6, 78, 59, 0.25), rgba(17, 94, 89, 0.2)) !important;
    border-color: rgba(6, 95, 70, 0.4) !important;
}

html.dark #modal-share-container .text-emerald-800 {
    color: #6ee7b7 !important;
}

html.dark #modal-share-container .text-emerald-600 {
    color: #34d399 !important;
}

html.dark #modal-share-container p.text-emerald-700\/80 {
    color: rgba(110, 231, 183, 0.85) !important;
}

/* Fallback broader selector for Bagikan label & icon */
html.dark #modal-share-container p[class*="text-emerald-7"] {
    color: rgba(110, 231, 183, 0.85) !important;
}

html.dark #modal-share-container div[class*="text-emerald-8"] {
    color: #6ee7b7 !important;
}

html.dark #modal-share-container div[class*="text-emerald-6"] {
    color: #34d399 !important;
}

html.dark #modal-share-container [class*="border-emerald-2"] {
    border-color: rgba(4, 120, 87, 0.4) !important;
}

/* Dark mode: Tombol sosial media (WhatsApp, Facebook, Telegram) */
html.dark #share-whatsapp,
html.dark #share-facebook,
html.dark #share-telegram {
    background-color: #1E232D !important;
    border-color: #2D3440 !important;
    box-shadow: none !important;
}

html.dark #share-whatsapp:hover,
html.dark #share-facebook:hover,
html.dark #share-telegram:hover {
    background-color: #262D38 !important;
    border-color: #374151 !important;
}
html.dark #header-avatar-placeholder {
    background-color: #262D38 !important;
}
#header-avatar-placeholder {
    border-color: transparent !important;
}
html.dark #nav-profile-btn:hover {
    background-color: #262D38 !important;
}

/* Category Nav Menu Styling */
.storefront-top-nav .menu-item a {
    display: inline-block;
    padding: 8px 16px;
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.storefront-top-nav .menu-item a:hover,
.storefront-top-nav .current-menu-item > a {
    background-color: var(--primary-color, #10b981);
    border-color: var(--primary-color, #10b981);
    color: #ffffff;
}

.dark .storefront-top-nav .menu-item a {
    background-color: #1E232D;
    border-color: #2D3440;
    color: #94a3b8;
}

.dark .storefront-top-nav .menu-item a:hover,
.dark .storefront-top-nav .current-menu-item > a {
    background-color: var(--primary-color, #10b981);
    color: #ffffff;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Dropdown Sub-menu Styling for storefront-top-nav */
.storefront-top-nav .menu-item.menu-item-has-children {
    position: relative;
}
.storefront-top-nav .menu-item.menu-item-has-children > a::after {
    content: " \25BC"; /* downward triangle */
    font-size: 10px;
    margin-left: 6px;
    vertical-align: middle;
}
.storefront-top-nav .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 0;
    margin-top: 8px; /* Slightly lower */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 50;
    flex-direction: column;
}
/* Bridge agar hover tidak hilang saat kursor melintasi margin */
.storefront-top-nav .sub-menu::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
}
.dark .storefront-top-nav .sub-menu {
    background-color: #1E232D;
    border-color: #2D3440;
}
.storefront-top-nav .menu-item.menu-item-has-children:hover > .sub-menu {
    display: flex;
}
/* Sub-menu item styling (override pill styles) */
.storefront-top-nav .sub-menu .menu-item {
    width: 100%;
}
.storefront-top-nav .sub-menu .menu-item a {
    display: block;
    width: 100%;
    padding: 8px 16px;
    background-color: transparent !important;
    border: none;
    border-radius: 0;
    color: #475569;
    font-size: 14px;
    font-weight: 500;
}
.storefront-top-nav .sub-menu .menu-item a::after {
    content: none;
}
.storefront-top-nav .sub-menu .menu-item a:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}
.dark .storefront-top-nav .sub-menu .menu-item a {
    color: #94a3b8;
}
.dark .storefront-top-nav .sub-menu .menu-item a:hover {
    background-color: #262D38 !important;
    color: #f8fafc !important;
}
/* Nested sub-menus inside sub-menus */
.storefront-top-nav .sub-menu .sub-menu {
    top: 0;
    left: 100%;
    margin-top: 0;
    margin-left: 2px;
}

/* Optimization for Mobile Horizontal Scroll Menu */
@media (max-width: 768px) {
    .storefront-top-nav .menu-item a {
        padding: 4px 12px;
        font-size: 12px;
        font-weight: 500;
    }
    
    /* Detach Submenu from the scrollable list item to prevent clipping by overflow-x */
    .storefront-top-nav .menu-item.menu-item-has-children {
        position: static !important; 
    }
    /* Disable default hover on mobile to prevent sticky states */
    .storefront-top-nav .menu-item.menu-item-has-children:hover > .sub-menu {
        display: none;
    }
    /* Open via JS class */
    .storefront-top-nav .menu-item.menu-item-has-children.mobile-menu-open > .sub-menu {
        display: flex !important;
    }
    /* Highlight parent when open */
    .storefront-top-nav .menu-item.menu-item-has-children.mobile-menu-open > a {
        background-color: var(--primary-color, #10b981) !important;
        border-color: var(--primary-color, #10b981) !important;
        color: #ffffff !important;
    }
    .storefront-top-nav .sub-menu {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%; /* Dropdown spans full width of the nav on mobile */
        margin-top: 8px;
        box-sizing: border-box;
    }
}

/* Content Fallback Styling for Pages & Posts */
.entry-content h2 { font-size: 1.5rem; font-weight: 700; margin-top: 2rem; margin-bottom: 1rem; color: #111827; }
.entry-content h3 { font-size: 1.25rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.75rem; color: #1f2937; }
.entry-content p { margin-bottom: 1.25rem; }
.entry-content ul { list-style-type: disc; padding-left: 1.5rem; margin-bottom: 1.25rem; }
.entry-content ol { list-style-type: decimal; padding-left: 1.5rem; margin-bottom: 1.25rem; }
.entry-content a { color: var(--primary-color, #10b981); text-decoration: underline; }
.dark .entry-content h2, .dark .entry-content h3 { color: #f9fafb; }
