/* Modern Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #0ea5e9;
    --primary-dark: #0369a1;
    --secondary: #10b981;
    --accent: #f43f5e;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --radius: 12px;
    --sidebar-width: 260px;
    --header-height: 64px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top left, #1e293b, #0f172a);
    color: var(--text-main);
    margin: 0;
    min-height: 100vh;
}

/* ===========================
   HEADER
=========================== */
header {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0 1.5rem;
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 900;
}

header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Desktop nav (hidden on mobile) */
nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    padding: 0.5rem 0;
    position: relative;
    white-space: nowrap;
}

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

nav a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

nav a#logout-btn {
    color: #fca5a5;
    border: 1px solid rgba(248, 113, 113, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: rgba(248, 113, 113, 0.05);
}

nav a#logout-btn:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: #f87171;
}

/* ===========================
   HAMBURGER BUTTON
=========================== */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.hamburger-btn:hover {
    background: rgba(14, 165, 233, 0.15);
    border-color: rgba(14, 165, 233, 0.3);
}

.hamburger-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-main);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Animated X when sidebar is open */
.hamburger-btn.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.hamburger-btn.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ===========================
   SIDEBAR OVERLAY
=========================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ===========================
   SIDEBAR
=========================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand {
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.3;
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.sidebar-close:hover {
    color: var(--text-main);
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.25s ease;
    position: relative;
    border-left: 3px solid transparent;
}

.sidebar-nav a .nav-icon {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav a:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
    border-left-color: rgba(14, 165, 233, 0.4);
}

.sidebar-nav a.active {
    color: var(--primary);
    background: rgba(14, 165, 233, 0.1);
    border-left-color: var(--primary);
}

.sidebar-nav .divider {
    height: 1px;
    background: var(--border);
    margin: 0.75rem 1.5rem;
}

.sidebar-nav .logout-link {
    color: #fca5a5;
}

.sidebar-nav .logout-link:hover {
    background: rgba(248, 113, 113, 0.08);
    border-left-color: rgba(248, 113, 113, 0.5);
    color: #f87171;
}

/* ===========================
   CONTAINERS & GRID
=========================== */
.container {
    padding: 1.5rem 5%;
    max-width: 1400px;
    margin: 0 auto;
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* ===========================
   CARDS & GLASSMORPHISM
=========================== */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.2);
}

.card h3 {
    margin-top: 0;
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
}

.card p {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
    color: var(--text-main);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-top: 2rem;
}

/* ===========================
   FORM ELEMENTS
=========================== */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

select option {
    background-color: var(--bg-dark);
    color: var(--text-main);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

/* ===========================
   BUTTONS
=========================== */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===========================
   TABLES
=========================== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th {
    text-align: left;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

/* ===========================
   UTILITIES
=========================== */
.text-right {
    text-align: right;
}

.mt-2 {
    margin-top: 2rem;
}

.mb-1 {
    margin-bottom: 1rem;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-low {
    background: rgba(244, 63, 94, 0.1);
    color: #fb7185;
}

/* ===========================
   RESPONSIVE - TABLET
=========================== */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

/* ===========================
   RESPONSIVE - MOBILE (<=768px)
=========================== */
@media (max-width: 768px) {
    /* Show hamburger, hide desktop nav */
    .hamburger-btn {
        display: flex;
    }

    header nav {
        display: none;
    }

    header {
        padding: 0 1rem;
    }

    header h1 {
        font-size: 1.05rem;
    }

    .container {
        padding: 1rem;
    }

    .dashboard-cards {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    /* Billing grid stacks vertically */
    .billing-grid {
        grid-template-columns: 1fr !important;
    }

    /* Make tables scrollable on small screens */
    .inventory-list,
    .customer-list,
    .detailed-report {
        overflow-x: auto;
    }

    /* Action bar stacks */
    .action-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem;
    }

    .action-bar input,
    .action-bar button {
        width: 100% !important;
    }

    /* Report filters wrap nicely */
    .filters {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .filters button,
    .filters .form-group {
        width: 100%;
    }

    td, th {
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }

    .btn {
        font-size: 0.9rem;
        padding: 0.65rem 1.1rem;
    }
}