:root {
    /* Color Palette - Modern & Professional */
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #10B981;
    --accent: #F59E0B;
    --danger: #EF4444;

    --bg-body: #F1F5F9;
    --bg-surface: #FFFFFF;
    --bg-sidebar: #1E293B;

    --text-main: #0F172A;
    --text-muted: #64748B;
    --text-light: #F8FAFC;

    --border: #E2E8F0;

    /* Spacing & Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll, use container scroll */
}

/* Layout Structure */
.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    background-color: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    height: 100vh;
    overflow-y: auto;
    /* Enable scroll for long menus */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--bg-surface);
}

.brand i {
    color: var(--primary);
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #94A3B8;
    font-weight: 500;
    font-size: 0.9rem;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 0 15px rgba(79, 70, 229, 0.4);
}

.sidebar-category {
    font-size: 0.65rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1rem 0 0.4rem 0.5rem;
    opacity: 0.8;
}

/* Main Content */
.main-content {
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.top-bar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.content-area {
    padding: 2rem;
}

/* Components */
.card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    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);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.kpi-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.kpi-trend {
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.trend-up {
    color: var(--secondary);
}

.trend-down {
    color: var(--danger);
}

/* Utilities */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading-state {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--bg-surface);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: #f8fafc;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Action Buttons in Tables */
.action-btn {
    padding: 6px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    margin-right: 0.25rem;
    transition: all 0.2s;
}

.btn-edit {
    background: #E0E7FF;
    color: var(--primary);
}

.btn-edit:hover {
    background: #C7D2FE;
}

.btn-delete {
    background: #FEE2E2;
    color: var(--danger);
}

.btn-delete:hover {
    background: #FECACA;
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: #f1f5f9;
}

/* Stable Responsive Adjustments */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 80px 1fr;
        /* Mini sidebar on mobile */
    }

    .sidebar {
        padding: 1rem 0.5rem;
    }

    .brand span,
    .nav-item span,
    .sidebar-category {
        display: none;
        /* Hide text on mobile */
    }

    .nav-item {
        justify-content: center;
        padding: 1rem;
    }

    .nav-item i {
        font-size: 1.5rem;
        margin: 0;
    }

    .content-area {
        padding: 1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* POS Mobile Fix */
    #content-area>div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* Important: Allow the internal columns to expand and scroll */
    #content-area>div[style*="grid-template-columns"]>div {
        height: auto !important;
        overflow: visible !important;
        margin-bottom: 2rem;
    }

    /* Adjust main content for mobile scrolling */
    .main-content {
        height: auto !important;
        overflow-y: visible !important;
    }

    body,
    .app-container {
        height: auto !important;
        overflow-y: auto !important;
    }
}

/* Menu Toggle Button */
.menu-toggle {
    display: none;
    background: #f1f5f9;
    border: none;
    padding: 8px;
    border-radius: 8px;
    color: var(--primary);
    cursor: pointer;
    font-size: 1.25rem;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }
}