:root {
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --card-bg: rgba(30, 41, 59, 0.4);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top right, #1e293b, var(--bg-darker));
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(15, 23, 42, 0.95);
    /* More opaque for contrast */
    border-right: 1px solid var(--glass-border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    padding: 1.5rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
    overflow-y: auto;
    /* Allow vertical scrolling */
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    padding: 1.5rem 1rem;
}

/* Sidebar Toggle Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2.5rem;
    white-space: nowrap;
}

.sidebar-title-logo-link {
    display: block;
    width: 100%;
    margin-right: 1rem;
}

.sidebar-logo {
    width: 100%;
    height: auto;
    max-width: 180px;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.sidebar-logo:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.3));
}

.sidebar.collapsed .sidebar-logo {
    opacity: 0;
    width: 0;
    display: none;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Nav Items */
.brand-group {
    margin-bottom: 2rem;
}

.brand-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #475569;
    font-weight: 700;
    margin-bottom: 1rem;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
}

.sidebar.collapsed .brand-section-title {
    display: none;
}

.brand-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.brand-link {
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
    margin-bottom: 4px;
    border-radius: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.2s;
    height: 32px;
    /* Super Compact */
    box-sizing: border-box;
    overflow: hidden;
}

.brand-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.brand-link.active {
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.15), transparent);
    color: var(--accent);
    box-shadow: inset 2px 0 0 0 var(--accent);
}

.sidebar-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    margin-right: 0.5rem;
    object-fit: contain;
    border-radius: 4px;
    filter: grayscale(100%);
    transition: filter 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-link:hover .sidebar-icon,
.brand-link.active .sidebar-icon {
    filter: grayscale(0%);
}

.link-text {
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
}

.sidebar.collapsed .link-text {
    opacity: 0;
    width: 0;
    display: none;
}

.sidebar.collapsed .sidebar-icon {
    margin-right: 0;
}

.sidebar.collapsed .brand-link {
    justify-content: center;
}

/* Main Content Adjustment */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 3rem;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* Rest of styles (Tables, Cards) kept same but ensured compatibility */

.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 3rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-logo-hero {
    height: 80px;
    width: auto;
    max-width: 250px;
    background: #1e293b;
    padding: 0.75rem 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    object-fit: contain;
    transition: transform 0.3s ease;
}

.brand-logo-hero:hover {
    transform: scale(1.05);
}

.controls {
    margin-bottom: 2rem;
}

.search-input {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 0.875rem 1.5rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* Ensure padding doesn't overflow */
}

/* Custom Select Styling */
select.search-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23f8fafc'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
    cursor: pointer;
}

select.search-input option {
    background-color: #1e293b;
    /* Dark background for dropdown items */
    color: #f8fafc;
}

/* Table */
.table-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.product-table {
    width: 100%;
    border-collapse: collapse;
}

.product-table th {
    background: rgba(15, 23, 42, 0.5);
    padding: 1.25rem 1.5rem;
    text-align: left;
    color: #64748b;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
}

.product-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.product-img {
    width: 96px;
    height: 96px;
    border-radius: 0.5rem;
    object-fit: cover;
}

.product-name {
    font-weight: 600;
    color: #e2e8f0;
}

.action-btn {
    padding: 0.5rem 1rem;
    background: #fff;
    color: #0f172a;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 2rem;
}

.product-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    overflow: hidden;
    position: relative;
    transition: transform 0.2s;
}

.product-card:hover {
    box-shadow: 0 0 0 2px var(--accent);
}

.card-img-container {
    height: 220px;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

.card-body {
    padding: 1.5rem;
}

.card-brand {
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.card-title {
    font-size: 1.1rem;
    color: #f1f5f9;
    margin: 0;
}

.card-price {
    margin-top: 1rem;
    font-size: 1.25rem;
    color: #94a3b8;
}

/* Mobile */
.hamburger-mobile {
    display: none;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        width: 100%;
        padding: 1rem;
        box-sizing: border-box;
        /* Ensure padding doesn't add to width */
        overflow-x: hidden;
    }

    .hamburger-mobile {
        display: flex;
        position: fixed;
        bottom: 1.5rem;
        right: 1.5rem;
        background: var(--accent);
        color: #0f172a;
        width: 3.5rem;
        height: 3.5rem;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        z-index: 200;
        border: none;
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.3);
    }

    .toggle-desktop {
        display: none;
    }

    /* Hide desktop collapse button on mobile */
}

/* Image Magnifier */
.image-magnifier-overlay {
    position: fixed;
    z-index: 9999;
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--accent);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    object-fit: cover;
    /* Start with cover to match thumb, JS can switch to contain if needed, or keep cover for effect */
    background: #1e293b;
}

/* Mobile specific fixes */
@media (max-width: 768px) {

    /* Header adjustments */
    .header-flex {
        flex-direction: column-reverse;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 2rem;
    }

    .header-flex>div {
        width: 100%;
    }

    .brand-logo-hero {
        align-self: center;
        max-width: 120px;
        height: auto;
        margin-bottom: 0.5rem;
    }

    /* Table adjustments */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .product-table {
        min-width: 500px;
        /* Force scroll if too narrow */
    }

    .product-table th,
    .product-table td {
        padding: 0.75rem 0.75rem;
        font-size: 0.9rem;
    }

    .product-img {
        width: 64px;
        height: 64px;
    }

    /* Make page title sizing responsive */
    .page-title {
        font-size: 1.75rem;
        line-height: 1.2;
    }

    /* Search input full width */
    .search-input {
        max-width: 100%;
        width: 100%;
    }
}

/* Icon Buttons for Collection/Wishlist */
.icon-btn {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #e2e8f0;
    transition: all 0.2s;
    padding: 0;
}

.icon-btn:hover {
    background: #1e293b;
    transform: scale(1.1);
    border-color: #38bdf8;
}

.icon-btn.active svg {
    filter: drop-shadow(0 0 5px rgba(239, 68, 68, 0.5));
}

/* Global Scroll Reveal Animation */
.reveal-item {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.reveal-item.is-visible {
    opacity: 1;
    transform: translateY(0);
}