:root {
    --primary-color: #3b82f6; /* Lighter blue like the image */
    --primary-hover: #2563eb;
    --sidebar-bg: #f0f9ff; /* Very light blue for sidebar background if needed, or white */
    --sidebar-active: #dbeafe;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --sidebar-width: 260px;
}

body.dark-mode {
    --background-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --sidebar-bg: #1e293b;
    --sidebar-active: #334155;
    --input-bg: #0f172a;
}

body.dark-mode .form-control {
    background-color: var(--input-bg);
    color: var(--text-main);
}

body.dark-mode .bill-preview {
    filter: invert(0); /* Keep bill white or maybe invert? Usually bills are white paper. */
    /* Actually, let's keep the bill preview white because it simulates paper */
    color: black;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden; /* For dashboard layout */
}

/* Login Page Specifics */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5 0%, #818cf8 100%);
    overflow: auto;
}

.login-card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.brand-logo {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.brand-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.875rem;
}

.form-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    transition: border-color 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: transform 0.3s ease;
}

.sidebar-header {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-menu {
    list-style: none;
    flex: 1;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
    background-color: #eff6ff;
    color: var(--primary-color);
}

.nav-link i {
    width: 20px;
    text-align: center;
}

.user-profile {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Cards & Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-trend {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.trend-up { color: var(--success-color); }
.trend-down { color: var(--danger-color); }

/* Charts Section */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    height: 400px;
}

/* Tables */
.table-container {
    background: var(--card-bg);
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    overflow-x: auto;
}

.table-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #f9fafb;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

td {
    font-size: 0.875rem;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-in-stock { background-color: #d1fae5; color: #065f46; }
.status-low-stock { background-color: #fef3c7; color: #92400e; }
.status-out-of-stock { background-color: #fee2e2; color: #991b1b; }

/* Utilities */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-card, .chart-card, .table-container {
    animation: fadeIn 0.5s ease-out forwards;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

/* Dropdown Menu */
.action-menu {
    position: relative;
    display: inline-block;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-muted);
    font-size: 1.1rem;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.action-btn:hover {
    background-color: #f3f4f6;
    color: var(--text-main);
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: white;
    min-width: 160px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    z-index: 10;
    overflow: hidden;
}

.dropdown-content.show {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

.dropdown-item {
    color: var(--text-main);
    padding: 0.75rem 1rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background-color: #f9fafb;
}

.dropdown-item.danger {
    color: var(--danger-color);
}

.dropdown-item.danger:hover {
    background-color: #fef2f2;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.status-in-stock { background-color: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.status-low-stock { background-color: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.status-out-of-stock { background-color: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.status-hold { background-color: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Responsive & Conjusted Mobile Layout */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    .dashboard-container {
        flex-direction: column;
        height: auto;
        overflow-x: hidden;
    }

    body {
        overflow-y: auto;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease-in-out;
        box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        width: 100%;
        margin-left: 0;
        padding: 1rem 0.75rem; /* Compact padding */
        height: auto;
        overflow: visible;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .header > div {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .header > div > * {
        flex: 1 1 auto;
    }

    .page-title {
        font-size: 1.25rem;
        display: flex;
        align-items: center;
        width: 100%;
    }

    .mobile-menu-btn {
        display: block !important;
        margin-right: 0.75rem;
        font-size: 1.25rem;
        padding: 0.25rem;
        background: none;
        border: none;
        color: var(--text-main);
        cursor: pointer;
    }

    /* Conjusted Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr); /* Force 2 columns for compact view */
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    /* Charts */
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .chart-card {
        height: 300px;
        padding: 1rem;
    }

    /* Tables */
    .table-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
        padding: 1rem;
    }

    .table-header .btn {
        width: 100%;
    }

    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
        white-space: nowrap; /* Prevent wrapping in tight cells */
    }
    
    /* Form controls */
    .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    /* Custom Orders Mobile */
    .header input[type="text"] {
        width: 100% !important;
    }
    
    #ordersGrid, #makersGrid {
        grid-template-columns: 1fr !important;
    }

    /* Bill Layout */
    .bill-layout {
        grid-template-columns: 1fr;
    }
    
    .bill-preview {
        width: 100% !important;
        min-height: auto !important;
        padding: 1rem !important;
        overflow-x: auto;
    }

    /* Settings Mobile */
    .card {
        padding: 1rem !important;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    /* On very small screens, maybe 1 column stats if they break, 
       but let's try to keep 2 for "conjusted" feel unless it breaks layout */
    .stats-grid {
        gap: 0.5rem;
    }
    
    .stat-card {
        padding: 0.75rem;
    }
}
