:root {
    /* Base Themes: Dark (Default) */
    --bg-main: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass: rgba(255, 255, 255, 0.05);
    
    /* Semantic Colors */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #10b981;
    --danger: #ef4444;
}

/* Light Theme Overrides */
[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: rgba(0, 0, 0, 0.1);
    --glass: rgba(0, 0, 0, 0.03);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 1.5rem;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-links li {
    margin-bottom: 0.5rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
}

.nav-links a:hover, .nav-links a.active {
    background-color: var(--primary);
    color: white;
}

/* Main Content */
.main-content {
    margin-left: 260px;
    flex-grow: 1;
    padding: 2rem;
    width: calc(100% - 260px);
    transition: padding 0.3s ease, margin-left 0.3s ease;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

/* Theme & Menu Toggles */
.icon-btn {
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--primary);
    color: white;
}

.sidebar-toggle {
    display: none; /* Desktop hidden */
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-card.profit .value { color: var(--secondary); }
.stat-card.stock .value { color: var(--primary); }

/* Table Container */
.content-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow-x: auto; /* Responsive tables */
}

/* DataTables themed */
.dataTables_wrapper { color: var(--text-main); }
.dataTables_length select { background: var(--bg-input); color: var(--text-main); border: 1px solid var(--border); border-radius: 0.25rem; }

table.dataTable {
    margin: 1rem 0 !important;
    font-size: 0.8125rem;
}

table.dataTable thead th {
    background-color: var(--glass);
    color: var(--text-muted);
    border-bottom: 1px solid var(--border) !important;
    padding: 0.75rem !important;
}

table.dataTable tbody td {
    padding: 0.75rem !important;
    border-bottom: 1px solid var(--border) !important;
    color: var(--text-main);
}

.dataTables_filter input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-main);
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background: var(--glass); color: var(--text-main); border: 1px solid var(--border); }

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 600px;
    border: 1px solid var(--border);
    max-height: 90vh;
    overflow-y: auto;
}

.form-control {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--text-main);
    outline: none;
}

.form-control:focus { border-color: var(--primary); }

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1rem;
    }
    
    .sidebar-toggle {
        display: flex;
    }
    
    .header-top {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 1rem;
    }
    
    .user-info {
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    h1 { font-size: 1.5rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .content-card { padding: 1rem; }
}
