/* ============================================
   THEME VARIABLES
   Default / [data-theme="dark"] = dark red theme
   [data-theme="light"]          = white red theme
   ============================================ */

:root,
:root[data-theme="dark"] {
    /* Brand */
    --red:           #e74c3c;
    --bright-red:    #c0392b;
    --red-glow:      rgba(231, 76, 60, 0.18);
    --red-glow-lg:   rgba(231, 76, 60, 0.12);

    /* Backgrounds */
    --bg-body:       #111111;
    --bg-sidebar:    #1a1a1a;
    --bg-header:     #1a1a1a;
    --bg-footer:     #1a1a1a;
    --bg-card:       #222222;
    --bg-input:      #2a2a2a;
    --bg-btn:        #2c2c2c;
    --bg-hover:      rgba(231, 76, 60, 0.10);
    --bg-active:     rgba(231, 76, 60, 0.16);
    --bg-overlay:    rgba(0, 0, 0, 0.30);

    /* Borders */
    --border:        #2c2c2c;
    --border-input:  #3a3a3a;

    /* Text */
    --text-primary:  #f0f0f0;
    --text-secondary:#aaaaaa;
    --text-muted:    #666666;
    --text-heading:  #ffffff;
    --text-nav:      #999999;
    --text-nav-cat:  #444444;

    /* Misc */
    --avatar-bg:     #333333;
    --shadow:        0 4px 24px rgba(0, 0, 0, 0.45);
    --sidebar-logo-bg: #000000;
}

:root[data-theme="light"] {
    /* Brand */
    --red:           #d32f2f;
    --bright-red:    #b71c1c;
    --red-glow:      rgba(211, 47, 47, 0.12);
    --red-glow-lg:   rgba(211, 47, 47, 0.07);

    /* Backgrounds */
    --bg-body:       #f4f6f8;
    --bg-sidebar:    #ffffff;
    --bg-header:     #ffffff;
    --bg-footer:     #ffffff;
    --bg-card:       #ffffff;
    --bg-input:      #f9f9f9;
    --bg-btn:        #f0f0f0;
    --bg-hover:      rgba(211, 47, 47, 0.07);
    --bg-active:     rgba(211, 47, 47, 0.12);
    --bg-overlay:    rgba(0, 0, 0, 0.04);

    /* Borders */
    --border:        #e0e0e0;
    --border-input:  #cccccc;

    /* Text */
    --text-primary:  #1a1a1a;
    --text-secondary:#555555;
    --text-muted:    #888888;
    --text-heading:  #111111;
    --text-nav:      #555555;
    --text-nav-cat:  #aaaaaa;

    /* Misc */
    --avatar-bg:     #f0f0f0;
    --shadow:        0 4px 24px rgba(0, 0, 0, 0.10);
    --sidebar-logo-bg: #ffffff;

    
}

/* Default state (Light Mode) */
.logo-dark-mode { display: none; }
.logo-light-mode { display: block; }

/* Dark Mode state */
[data-theme="dark"] .logo-dark-mode { display: block; }
[data-theme="dark"] .logo-light-mode { display: none; }

/* ============================================
   RESET
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ============================================
   BODY
   ============================================ */
body {
    font-family: 'Segoe UI', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    align-items: flex-start;
    overflow-y: auto;
    transition: background 0.25s ease, color 0.25s ease;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: 260px;
    height: 100vh;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    transition: background 0.25s ease, border-color 0.25s ease;
}

.sidebar-logo {
    padding: 24px; /* Slightly increased for better breathing room */
    display: flex;
    justify-content: center; /* Centers horizontally */
    align-items: center;     /* Centers vertically */
    background-color: var(--sidebar-logo-bg);
    border-bottom: 1px solid var(--border);
    min-height: 80px;        /* Ensures consistent header height */
}
.sidebar-logo img { max-width: 130px; height: auto; }

.nav-links { list-style: none; padding: 10px 0; flex: 1; }
.nav-links li { margin: 2px 0; }

.nav-links a, .collapsible-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 20px;
    color: var(--text-nav);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    width: 100%;
    background: none;
    border-top: none;
    border-right: none;
    border-bottom: none;
    cursor: pointer;
}

.nav-links a:hover, .collapsible-btn:hover {
    background: var(--bg-hover);
    color: var(--red);
    border-left-color: var(--red);
}

.nav-links a.active {
    background: var(--bg-active);
    color: var(--red);
    border-left-color: var(--red);
    font-weight: 600;
}

.active-category > .collapsible-btn {
    color: var(--red);
    border-left-color: var(--red);
}

.nav-category {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-nav-cat);
    padding: 16px 20px 6px;
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
    background: var(--bg-overlay);
}
.collapsible-content.show { max-height: 400px; }
.collapsible-content a {
    padding: 9px 20px 9px 44px;
    font-size: 13px;
}

.arrow { font-size: 10px; transition: transform 0.3s; color: var(--text-muted); }
.rotate { transform: rotate(180deg); }

/* ============================================
   MAIN WRAPPER
   ============================================ */
.main-wrapper {
    margin-left: 260px;
    width: calc(100% - 260px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   TOP HEADER
   ============================================ */
.top-header {
    height: 64px;
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 98;
    transition: background 0.25s ease, border-color 0.25s ease;
}

.header-title { display: flex; align-items: center; gap: 12px; }
.header-title h2 { font-size: 16px; font-weight: 600; color: var(--text-heading); }

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-heading);
    font-size: 22px;
    cursor: pointer;
}

.account-menu { display: flex; align-items: center; gap: 12px; }

.account-info {
    display: flex;
    flex-direction: column;
    text-align: right;
}
.account-name { font-size: 13px; font-weight: 600; color: var(--text-heading); }
.account-role { font-size: 11px; color: var(--text-muted); }

.avatar-link { text-decoration: none; }
.avatar-container {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 2px solid var(--red);
    background: var(--avatar-bg);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.avatar-img { width: 100%; height: 100%; object-fit: cover; }
.avatar-text { color: var(--text-heading); font-weight: 700; font-size: 15px; }

.logout-btn-header {
    padding: 7px 14px;
    border-radius: 8px;
    background: var(--bg-btn);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    transition: 0.2s;
}
.logout-btn-header:hover { border-color: var(--red); color: var(--red); }

.header-cart-link {
    display: flex; align-items: center; gap: 6px;
    background: var(--bg-btn);
    color: var(--text-primary);
    text-decoration: none;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--border);
    transition: 0.2s;
}
.header-cart-link:hover { border-color: var(--red); color: var(--red); }

.cart-count-pill {
    background: var(--red); color: #fff;
    font-size: 10px; padding: 2px 6px;
    border-radius: 10px; font-weight: 800;
}

.header-credit-pill {
    background: var(--red-glow);
    border: 1px solid var(--red);
    color: var(--red);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
}

/* ============================================
   THEME TOGGLE BUTTON
   ============================================ */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    border-radius: 20px;
    background: var(--bg-btn);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.theme-toggle:hover {
    border-color: var(--red);
    color: var(--red);
}
.theme-label { font-size: 12px; }

/* ============================================
   SIDEBAR OVERLAY (mobile)
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100vh;
    background: rgba(0,0,0,0.7);
    z-index: 99;
}

/* ============================================
   CONTENT + FOOTER
   ============================================ */
.content-area { flex: 1; }

.dashboard-footer {
    padding: 16px 24px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--bg-footer);
    text-align: center;
    transition: background 0.25s ease, border-color 0.25s ease;
}

/* ============================================
   FILTER PANEL
   ============================================ */
.filter-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.filter-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px;
    transition: transform 0.3s;
}

/* ============================================
   MOBILE
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease, background 0.25s ease;
    }
    .sidebar.active { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .main-wrapper { margin-left: 0; width: 100%; }
    .top-header { padding: 0 16px; }
    .menu-toggle { display: block; }
    .account-info { display: none; }
    .theme-label { display: none; }

    .filter-panel-body {
        display: none;
        margin-top: 14px;
    }
    .filter-panel-body.open { display: block; }
    .filter-toggle-btn.open { transform: rotate(180deg); }
}

@media (min-width: 769px) {
    .filter-panel-body { display: block !important; }
    .filter-toggle-btn { display: none; }
    .filter-panel-header { cursor: default; }
}

/* ProductsStyle */
.products-layout {
        display: flex;
        gap: 24px;
        padding: 24px;
        align-items: flex-start;
    }

    /* Filter sidebar */
    .filter-panel {
        flex: 0 0 240px;
        background: var(--bg-sidebar);
        border-radius: 12px;
        border: 1px solid var(--border);
        padding: 20px;
        position: sticky;
        top: 84px;
    }

    .filter-panel h3 {
        font-size: 13px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 1px;
        color: var(--text-primary);
        margin-bottom: 16px;
        padding-bottom: 10px;
        border-bottom: 1px solid #f0f0f0;
    }

    .filter-section {
        margin-bottom: 20px;
    }

    .filter-label {
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.8px;
        color: #999;
        display: block;
        margin-bottom: 10px;
    }

    .filter-search {
        width: 100%;
        padding: 10px 12px;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        font-size: 14px;
        outline: none;
        transition: border-color 0.2s;
    }

    .filter-search:focus {
        border-color: var(--red, #e74c3c);
    }

    .checkbox-list {
        max-height: 180px;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 6px;
        scrollbar-width: thin;
    }

    .checkbox-item {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 13px;
        color: #555;
        cursor: pointer;
        padding: 3px 0;
    }

    .checkbox-item input {
        accent-color: var(--red, #e74c3c);
        width: 15px;
        height: 15px;
    }

    .checkbox-item:hover {
        color: var(--text-muted);
    }

    .price-inputs {
        display: flex;
        gap: 8px;
    }

    .price-inputs input {
        width: 100%;
        padding: 8px 10px;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        font-size: 13px;
        outline: none;
    }

    .price-inputs input:focus {
        border-color: var(--red, #e74c3c);
    }

    .btn-clear {
        width: 100%;
        padding: 10px;
        background: var(--red);
        color: var(--text-primary);
        border: 1px solid var(--border);
        border-radius: 8px;
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
        transition: 0.2s;
        margin-top: 4px;
    }

    .btn-clear:hover {
        background: #eee;
        color: #333;
    }

    /* Main content */
    .products-main {
        flex: 1;
        min-width: 0;
    }

    .action-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
    }

    .action-header h3 {
        font-size: 18px;
        font-weight: 600;
    }

    .item-count {
        font-size: 13px;
        color: #999;
        margin-top: 2px;
    }

    .header-actions {
        display: flex;
        gap: 10px;
        align-items: center;
    }

    .add-btn {
        background: var(--red, #e74c3c);
        color: #fff;
        padding: 9px 18px;
        border-radius: 8px;
        text-decoration: none;
        font-size: 13px;
        font-weight: 600;
        transition: 0.2s;
        white-space: nowrap;
    }

    .add-btn:hover {
        background: #c0392b;
    }

    .toggle-deleted-btn {
        padding: 9px 16px;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
        border: 1px solid #ddd;
        background: #fff;
        color: #666;
        transition: 0.2s;
        white-space: nowrap;
    }

    .toggle-deleted-btn.active {
        background: rgba(255, 77, 77, 0.08);
        color: #ff4d4d;
        border-color: #ff4d4d;
    }

    /* Product grid */
    .products-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 20px;
        position: relative;
        min-height: 300px;
    }

    .product-card {
        background: var(--bg-card);
        border-radius: 12px;
        overflow: hidden;
        border: 1px solid #2c2c2c;
        cursor: pointer;
        transition: transform 0.2s, box-shadow 0.2s;
        display: flex;
        flex-direction: column;
        position: relative;
    }

    .product-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
        border-color: var(--red, #e74c3c);
    }

    .deleted-badge {
        position: absolute;
        top: 10px;
        right: 10px;
        background: #ff4d4d;
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        padding: 3px 8px;
        border-radius: 4px;
        z-index: 2;
        text-transform: uppercase;
    }

    .card-image-wrapper {
        height: 200px;
        background: #111;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .card-image-wrapper img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.3s;
    }

    .product-card:hover .card-image-wrapper img {
        transform: scale(1.04);
    }

    .card-info {
        padding: 16px;
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .product-category {
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: 1px;
        color: var(--red, #e74c3c);
        font-weight: 700;
        margin-bottom: 6px;
    }

    .product-title {
        font-size: 14px;
        font-weight: 600;
        color: var(--text-primary);
        margin-bottom: 10px;
        line-height: 1.4;
        min-height: 40px;
    }

    .product-meta {
        display: flex;
        justify-content: space-between;
        font-size: 11px;
        color: #666;
        margin-bottom: 12px;
        padding-bottom: 12px;
        border-bottom: 1px solid #2c2c2c;
    }

    .price-section {
        margin-top: auto;
    }

    .price-label {
        font-size: 11px;
        color: #666;
        display: block;
        margin-bottom: 2px;
    }

    .main-price {
        font-size: 20px;
        font-weight: 800;
        color: var(--red);
    }

    .admin-prices {
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
        padding: 8px 10px;
        margin-top: 8px;
    }

    .admin-price-row {
        display: flex;
        justify-content: space-between;
        font-size: 11px;
        color: #888;
        margin-bottom: 4px;
    }

    .admin-price-row:last-child {
        margin-bottom: 0;
    }

    .admin-price-row .val {
        color: #ccc;
        font-weight: 600;
    }

    /* Loading spinner */
    .loading-state {
        grid-column: 1/-1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 80px 0;
    }

    .spinner {
        width: 36px;
        height: 36px;
        border: 3px solid rgba(231, 76, 60, 0.2);
        border-top-color: var(--red, #e74c3c);
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
    }

    @keyframes spin {
        to {
            transform: rotate(360deg);
        }
    }

    /* Empty state */
    .empty-state {
        grid-column: 1/-1;
        text-align: center;
        padding: 60px 20px;
        background: #fff;
        border-radius: 12px;
        border: 2px dashed #eee;
    }

    .empty-state h3 {
        font-size: 18px;
        color: #333;
        margin-bottom: 8px;
    }

    .empty-state p {
        color: #999;
        font-size: 14px;
        margin-bottom: 20px;
    }

    .wa-btn {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        background: #25D366;
        color: #fff;
        padding: 10px 22px;
        border-radius: 8px;
        text-decoration: none;
        font-weight: 700;
        font-size: 14px;
    }

    /* Pagination */
    .pagination-container {
        display: flex;
        justify-content: center;
        margin-top: 24px;
        padding-bottom: 20px;
    }

    .pagination {
        display: flex;
        gap: 6px;
    }

    .page-btn {
        min-width: 38px;
        height: 38px;
        padding: 0 12px;
        background: #252525;
        color: #aaa;
        border: 1px solid #3d3d3d;
        border-radius: 6px;
        cursor: pointer;
        font-size: 13px;
        font-weight: 600;
        transition: 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .page-btn:hover:not(:disabled):not(.active) {
        background: #333;
        color: #fff;
    }

    .page-btn.active {
        background: var(--red, #e74c3c);
        border-color: var(--red, #e74c3c);
        color: #fff;
        cursor: default;
    }

    .page-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

    /* Mobile */
    @media (max-width: 768px) {
        .products-layout {
            flex-direction: column;
            padding: 16px;
            gap: 16px;
        }

        .filter-panel {
            flex: none;
            width: 100%;
            position: static;
        }

        .products-grid {
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
        }

        .card-image-wrapper {
            height: 150px;
        }

        .product-title {
            font-size: 13px;
            min-height: 36px;
        }

        .main-price {
            font-size: 16px;
        }

        .action-header {
            flex-direction: column;
            align-items: flex-start;
            gap: 10px;
        }

        .header-actions {
            width: 100%;
            display: grid;
            grid-template-columns: 1fr 1fr;
        }

        .add-btn,
        .toggle-deleted-btn {
            text-align: center;
        }
    }
/* EndProductsStyle */