/* ----------------------------------------------------------------------
   CSS Variables (Theme Colors from Reference Image)
---------------------------------------------------------------------- */
:root {
    /* Primary Colors */
    --primary-color: #4318FF;       /* Deep Purple/Blue */
    --secondary-color: #f4f7fe;     /* App Background */
    
    /* Card Colors */
    --card-purple: #613afa;         /* Today Sales */
    --card-blue: #39b8ff;           /* Monthly Sales */
    --card-green: #01b574;          /* Today Profit */
    --card-orange: #ffb547;         /* Stock Alerts */
    
    /* Text Colors */
    --text-dark: #2b3674;           /* Headings, Main text */
    --text-gray: #a3aed1;           /* Subtitles, muted text */
    --text-light: #ffffff;
    
    /* Layout & Borders */
    --sidebar-width: 250px;
    --header-height: 70px;
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-color: #e0e5f2;
    --shadow-soft: 0 10px 20px rgba(0, 0, 0, 0.05);
}

/* ----------------------------------------------------------------------
   Reset & Global Styles
---------------------------------------------------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--secondary-color);
    color: var(--text-dark);
    font-size: 14px;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* ----------------------------------------------------------------------
   Layout Shell
---------------------------------------------------------------------- */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    height: var(--header-height);
    background-color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-dark);
    cursor: pointer;
    display: none; /* Hidden on desktop */
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
    width: calc(var(--sidebar-width) - 44px); /* Align with sidebar */
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    text-align: right;
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    color: var(--text-gray);
}

.user-avatar {
    width: 40px;
    height: 40px;
    background-color: var(--secondary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 20px;
}

/* App Body (Container for Sidebar + Main Content) */
.app-body {
    display: flex;
    flex: 1;
    margin-top: var(--header-height);
}

/* ----------------------------------------------------------------------
   Sidebar Navigation
---------------------------------------------------------------------- */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--text-light);
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 999;
}

.sidebar-menu {
    padding: 20px 15px;
}

.menu-header {
    padding: 15px 15px 5px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-gray);
    letter-spacing: 1px;
}

.menu-item {
    margin-bottom: 5px;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-radius: 8px;
    color: var(--text-gray);
    font-weight: 500;
    transition: all 0.3s ease;
}

.menu-link i {
    font-size: 20px;
    margin-right: 12px;
}

.menu-link:hover {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

.menu-link.active {
    background-color: rgba(67, 24, 255, 0.05);
    color: var(--primary-color);
    border-right: 4px solid var(--primary-color);
    border-radius: 8px 0 0 8px;
}

/* ----------------------------------------------------------------------
   Main Content Area
---------------------------------------------------------------------- */
.main-content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-gray);
    margin-top: 4px;
}

/* ----------------------------------------------------------------------
   Dashboard UI Cards
---------------------------------------------------------------------- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    border-radius: var(--border-radius-lg);
    padding: 20px;
    color: var(--text-light);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

/* Gradient Backgrounds based on Image */
.stat-card.bg-purple { background: linear-gradient(135deg, #613afa 0%, #4318ff 100%); }
.stat-card.bg-blue   { background: linear-gradient(135deg, #39b8ff 0%, #0088ff 100%); }
.stat-card.bg-green  { background: linear-gradient(135deg, #01b574 0%, #00995f 100%); }
.stat-card.bg-orange { background: linear-gradient(135deg, #ffb547 0%, #ff9800 100%); }

.stat-card-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    opacity: 0.9;
    margin-bottom: 10px;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-card-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.stat-card-icon {
    position: absolute;
    right: 15px;
    bottom: 15px;
    font-size: 60px;
    opacity: 0.15;
}

/* ----------------------------------------------------------------------
   Panels, Tables & Forms
---------------------------------------------------------------------- */
.panel {
    background: var(--text-light);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 24px;
}

.panel-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 20px;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 12px 15px;
    font-size: 12px;
    color: var(--text-gray);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 15px;
    font-size: 14px;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border-color);
}

.table tr:last-child td {
    border-bottom: none;
}

.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-unpaid { background: #ffe5e5; color: #d8000c; }
.badge-paid { background: #e5ffe5; color: #01b574; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

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

.btn-primary:hover {
    background-color: #3311cc;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
}

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

/* Flash Messages */
.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success { background-color: #e5f9e5; color: #01b574; }
.alert-danger { background-color: #ffe5e5; color: #d8000c; }
.alert-warning { background-color: #fff4e5; color: #ff9800; }

/* ----------------------------------------------------------------------
   Responsive Design
---------------------------------------------------------------------- */
@media (max-width: 992px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .menu-toggle { display: block; }
    .brand { width: auto; }
    
    .app-sidebar {
        transform: translateX(-100%);
    }
    
    .app-sidebar.active {
        transform: translateX(0);
    }
    
    .main-content-wrapper {
        margin-left: 0;
        width: 100%;
    }
    
    .dashboard-grid { grid-template-columns: 1fr; }
}