/* ═══════════════════════════════════════════════════════════
   GroceryStore Management System — Master Stylesheet
   Design: Dark Green Premium Theme
════════════════════════════════════════════════════════════ */

/* ── CSS Variables ──────────────────────────────────────── */
:root {
    --bg-dark:        #0d1117;
    --bg-sidebar:     #111827;
    --bg-card:        #1a2235;
    --bg-card-hover:  #1e2a40;
    --bg-input:       #0d1117;
    --border:         #2a3a52;
    --text-primary:   #e2e8f0;
    --text-muted:     #8899aa;
    --text-white:     #ffffff;
    --primary:        #16a34a;
    --primary-dark:   #15803d;
    --primary-light:  #22c55e;
    --accent:         #f59e0b;
    --accent-red:     #ef4444;
    --accent-blue:    #3b82f6;
    --accent-purple:  #8b5cf6;
    --accent-teal:    #14b8a6;
    --accent-rose:    #f43f5e;
    --sidebar-w:      260px;
    --topbar-h:       64px;
    --radius:         12px;
    --radius-sm:      8px;
    --shadow:         0 4px 20px rgba(0,0,0,0.4);
    --transition:     0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body.dark-theme {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 14px;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ── App Layout ──────────────────────────────────────────── */
.app-wrapper { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    transition: width var(--transition);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px;
    border-bottom: 1px solid var(--border);
}
.brand-icon {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(22,163,74,0.3);
}
.brand-name { font-size: 16px; font-weight: 700; color: var(--text-white); display: block; }
.brand-sub  { font-size: 10px; color: var(--text-muted); font-weight: 400; display: block; }

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.user-avatar { font-size: 28px; color: var(--primary-light); }
.user-name  { font-size: 13px; font-weight: 600; color: var(--text-white); display: block; }
.user-role  { font-size: 10px; background: rgba(22,163,74,0.2); color: var(--primary-light); padding: 2px 8px; border-radius: 10px; }

/* Nav Menu */
.nav-menu { list-style: none; padding: 8px 0; flex: 1; }
.nav-section-title {
    padding: 12px 20px 4px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    text-transform: uppercase;
}
.nav-item a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0;
    font-size: 13px; font-weight: 400;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}
.nav-item a:hover {
    background: rgba(255,255,255,0.04);
    color: var(--text-primary);
}
.nav-item.active a, .nav-item a.active {
    background: rgba(22,163,74,0.1);
    color: var(--primary-light);
    border-left-color: var(--primary-light);
    font-weight: 500;
}
.nav-item a i { width: 18px; text-align: center; font-size: 14px; }

.sidebar-footer {
    padding: 16px 0;
    border-top: 1px solid var(--border);
}
.logout-btn {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px;
    color: var(--accent-red);
    text-decoration: none;
    font-size: 13px; font-weight: 500;
    transition: background var(--transition);
}
.logout-btn:hover { background: rgba(239,68,68,0.08); }
.logout-btn i { width: 18px; text-align: center; }

/* ── Main Content ────────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Top Bar ─────────────────────────────────────────────── */
.top-bar {
    height: var(--topbar-h);
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    flex-shrink: 0;
}
.sidebar-toggle {
    background: none; border: none; color: var(--text-muted);
    font-size: 18px; cursor: pointer; padding: 8px;
    border-radius: 8px; transition: all var(--transition);
}
.sidebar-toggle:hover { background: var(--bg-card); color: var(--text-primary); }
.page-title { font-size: 17px; font-weight: 600; color: var(--text-white); flex: 1; }
.top-bar-right { display: flex; align-items: center; }
.date-time { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ── Content Area ────────────────────────────────────────── */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--text-white); margin: 0; }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }
.mb-3 { margin-bottom: 16px; }
.mt-4 { margin-top: 24px; }

/* ── Tables ──────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.2);
}
.table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: middle;
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: rgba(255,255,255,0.03); }
.table tbody tr.row-warning { background: rgba(245,158,11,0.05); }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.stat-card {
    border-radius: var(--radius);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
    position: relative; overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(0,0,0,0.4); }
.stat-card::after {
    content: ''; position: absolute;
    width: 80px; height: 80px; border-radius: 50%;
    top: -20px; right: -20px;
    background: rgba(255,255,255,0.06);
}
.stat-icon { font-size: 28px; opacity: 0.85; }
.stat-label { font-size: 11px; font-weight: 500; opacity: 0.75; display: block; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 22px; font-weight: 700; display: block; margin-top: 2px; }

.gradient-green  { background: linear-gradient(135deg,#15803d,#22c55e); color:#fff; }
.gradient-blue   { background: linear-gradient(135deg,#1d4ed8,#60a5fa); color:#fff; }
.gradient-orange { background: linear-gradient(135deg,#b45309,#f59e0b); color:#fff; }
.gradient-purple { background: linear-gradient(135deg,#6d28d9,#a78bfa); color:#fff; }
.gradient-teal   { background: linear-gradient(135deg,#0f766e,#2dd4bf); color:#fff; }
.gradient-rose   { background: linear-gradient(135deg,#be123c,#fb7185); color:#fff; }

/* ── Row-2col layout ────────────────────────────────────── */
.row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .row-2col { grid-template-columns: 1fr; } }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 18px;
    border: none; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    font-family: inherit;
}
.btn-primary {
    background: var(--primary); color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(22,163,74,0.3); }
.btn-outline {
    background: transparent; color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-card-hover); border-color: var(--primary); }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-generate { padding: 14px; font-size: 16px; font-weight: 600; border-radius: var(--radius); }

/* ── Forms ───────────────────────────────────────────────── */
.form-card { max-width: 800px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-bottom: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    width: 100%;
    font-family: inherit;
    transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,163,74,0.15); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
.form-actions { display: flex; gap: 12px; margin-top: 8px; }
.text-danger { color: var(--accent-red); font-size: 11px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-primary); }
.d-flex-col { display: flex; flex-direction: column; gap: 10px; justify-content: center; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: flex; align-items: center; gap: 10px;
    font-size: 13px; font-weight: 500;
}
.alert-success { background: rgba(22,163,74,0.12); color: #4ade80; border: 1px solid rgba(22,163,74,0.3); }
.alert-danger  { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }

/* ── Badges ──────────────────────────────────────────────── */
.badge { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-active   { background: rgba(22,163,74,0.15); color: #4ade80; }
.badge-inactive { background: rgba(239,68,68,0.12); color: #f87171; }
.badge-bill { font-family: monospace; font-size: 11px; background: rgba(59,130,246,0.15); color: #60a5fa; padding: 3px 8px; border-radius: 4px; }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--accent); padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-count { background: rgba(139,92,246,0.15); color: #a78bfa; padding: 3px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.badge-shift { background: rgba(20,184,166,0.15); color: #2dd4bf; padding: 3px 10px; border-radius: 10px; font-size: 11px; }
.gst-badge { background: rgba(245,158,11,0.12); color: var(--accent); padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.cat-pill { background: rgba(139,92,246,0.12); color: #a78bfa; padding: 3px 10px; border-radius: 10px; font-size: 11px; }
.badge-pay { padding: 4px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-pay.cash { background: rgba(22,163,74,0.15); color: #4ade80; }
.badge-pay.card { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-pay.upi  { background: rgba(139,92,246,0.15); color: #a78bfa; }
.badge-stock { padding: 4px 10px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.badge-stock.out { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-stock.low { background: rgba(245,158,11,0.15); color: var(--accent); }
.badge-stock.ok  { background: rgba(22,163,74,0.15); color: #4ade80; }
.role-badge { padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.role-badge.admin        { background: rgba(239,68,68,0.12); color: #f87171; }
.role-badge.cashier      { background: rgba(59,130,246,0.12); color: #60a5fa; }
.role-badge.stockmanager { background: rgba(245,158,11,0.12); color: var(--accent); }
.att-status { padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.att-status.present { background: rgba(22,163,74,0.15); color: #4ade80; }
.att-status.late    { background: rgba(245,158,11,0.15); color: var(--accent); }
.att-status.absent  { background: rgba(239,68,68,0.15); color: #f87171; }
.att-status.halfday { background: rgba(59,130,246,0.15); color: #60a5fa; }

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.page-header h2 { font-size: 20px; font-weight: 700; color: var(--text-white); display: flex; align-items: center; gap: 10px; }
.page-header h2 i { color: var(--primary-light); }

/* ── Filter Row ──────────────────────────────────────────── */
.filter-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.filter-row .form-group { margin-bottom: 0; min-width: 150px; }

/* ── Typography Helpers ──────────────────────────────────── */
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.text-success { color: #4ade80; }
.text-danger  { color: #f87171; }
.text-warning { color: var(--accent); }
.text-muted   { color: var(--text-muted); }
.text-center  { text-align: center; }
.d-inline { display: inline; }
.d-flex { display: flex; }
.ml-2 { margin-left: 8px; }
.mt-2 { margin-top: 8px; }
.text-primary { color: var(--primary-light); }

/* ── Input Group ─────────────────────────────────────────── */
.input-group { display: flex; gap: 8px; }
.input-group .form-control { flex: 1; }

/* ── Billing Layout ──────────────────────────────────────── */
.billing-wrapper {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
    height: calc(100vh - var(--topbar-h) - 48px);
}
.billing-left { overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.billing-right { overflow-y: auto; display: flex; flex-direction: column; gap: 0; }

/* Search dropdown */
.search-box { position: relative; }
.search-dropdown {
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--bg-card);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    display: none;
}
.search-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border);
}
.search-item:hover { background: rgba(22,163,74,0.1); }
.search-item:last-child { border-bottom: none; }
.search-item-name { font-weight: 600; font-size: 13px; }
.search-item-meta { font-size: 11px; color: var(--text-muted); }

/* Cart */
#emptyCart { text-align: center; padding: 40px; color: var(--text-muted); }
#emptyCart i { font-size: 40px; margin-bottom: 12px; }

.cart-qty-input {
    width: 60px; background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-primary); padding: 4px 8px; border-radius: 6px; font-size: 12px; text-align: center;
}
.cart-remove { background: none; border: none; color: var(--accent-red); cursor: pointer; font-size: 14px; padding: 4px 8px; border-radius: 4px; transition: background var(--transition); }
.cart-remove:hover { background: rgba(239,68,68,0.1); }

/* Summary */
.summary-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 13px;
}
.summary-row:last-child { border: none; }
.grand-total {
    padding: 12px 0 0; margin-top: 8px;
    border-top: 2px solid var(--primary);
    font-size: 18px; font-weight: 700; color: var(--primary-light);
}
.discount-row { border-radius: 6px; }
.discount-input {
    width: 90px; background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-primary); padding: 4px 10px; border-radius: 6px; font-size: 13px; text-align: right;
}
.round-off { color: var(--text-muted); font-size: 12px; }

/* Payment Methods */
.payment-methods { display: flex; gap: 8px; }
.pay-option {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer; font-size: 12px; font-weight: 500;
    transition: all var(--transition);
    color: var(--text-muted);
}
.pay-option input { display: none; }
.pay-option.active { border-color: var(--primary); background: rgba(22,163,74,0.12); color: var(--primary-light); }

/* Customer info */
.cust-found {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px;
    background: rgba(22,163,74,0.08);
    border: 1px solid rgba(22,163,74,0.25);
    border-radius: var(--radius-sm);
    font-size: 13px;
}
.cust-found i { font-size: 16px; }

/* ── Login Page ──────────────────────────────────────────── */
body.login-page { background: var(--bg-dark); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrapper {
    display: flex;
    width: 900px;
    max-width: 95vw;
    min-height: 520px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0,0,0,0.6);
}
.login-left {
    width: 45%;
    background: linear-gradient(160deg, #0a3a20, #1a6b3c, #15803d);
    padding: 40px;
    display: flex; flex-direction: column; justify-content: center;
}
.login-right {
    width: 55%;
    background: var(--bg-card);
    padding: 50px 40px;
    display: flex; align-items: center;
}
.login-card { width: 100%; }
.login-logo {
    width: 68px; height: 68px;
    background: rgba(255,255,255,0.15);
    border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; color: #fff; margin-bottom: 20px;
}
.login-left h1 { color: #fff; font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.login-left p  { color: rgba(255,255,255,0.65); font-size: 14px; margin-bottom: 32px; }
.feature-item  { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,0.8); font-size: 13px; margin-bottom: 12px; }
.feature-item i { font-size: 16px; color: #a7f3c0; width: 20px; }
.login-card h2 { font-size: 26px; font-weight: 800; color: var(--text-white); margin-bottom: 6px; }
.login-subtitle { color: var(--text-muted); margin-bottom: 28px; font-size: 13px; }
.login-card .form-group { margin-bottom: 20px; }
.login-card .form-group label { color: var(--text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.btn-login { width: 100%; padding: 12px; font-size: 15px; font-weight: 600; border-radius: var(--radius); margin-top: 8px; justify-content: center; }
.login-hint { margin-top: 16px; font-size: 12px; color: var(--text-muted); text-align: center; }
.login-hint strong { color: var(--primary-light); }
.input-password { position: relative; }
.input-password .form-control { padding-right: 44px; }
.toggle-pw {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px;
}

/* ── Stock Purchase (multi-line) ─────────────────────────── */
.purchase-lines-table td input { background: var(--bg-input); border: 1px solid var(--border); color: var(--text-primary); padding: 6px 10px; border-radius: 6px; font-size: 13px; width: 100%; }

/* ── Performance Report ──────────────────────────────────── */
.report-table th, .report-table td { padding: 10px 14px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { position: fixed; left: -260px; height: 100%; z-index: 999; }
    .sidebar.open { left: 0; }
    .billing-wrapper { grid-template-columns: 1fr; }
    .login-left { display: none; }
    .login-right { width: 100%; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a4a62; }

/* ── Utility ─────────────────────────────────────────────── */
.flex-2 { flex: 2; }
.flex-3 { flex: 3; }
.d-flex.align-items-end { display: flex; align-items: flex-end; gap: 8px; }
