/* ============================================================
   Sales & Inventory Management System - Application CSS
   ============================================================ */

/* ---- Variables ---- */
:root {
    --primary: #1a1f36;
    --primary-light: #2d3352;
    --primary-dark: #111425;
    --secondary: #6366f1;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 250px;
    --sidebar-collapsed: 60px;
    --header-height: 56px;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --radius: 6px;
    --radius-lg: 8px;
}

/* ---- Reset & Base ---- */
* { box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--gray-100); color: var(--gray-800); font-size: 0.875rem; line-height: 1.5; margin: 0; }
a { color: var(--secondary); text-decoration: none; }
a:hover { color: #4f46e5; }

/* ---- Layout ---- */
.app-wrapper { display: flex; min-height: 100vh; }
.app-sidebar { width: var(--sidebar-width); background: var(--primary); color: #fff; position: fixed; top: 0; left: 0; bottom: 0; z-index: 1000; transition: width 0.2s ease; overflow-y: auto; overflow-x: hidden; }
.app-sidebar.collapsed { width: var(--sidebar-collapsed); }
.app-main { margin-left: var(--sidebar-width); flex: 1; display: flex; flex-direction: column; min-height: 100vh; transition: margin-left 0.2s ease; }
.app-main.expanded { margin-left: var(--sidebar-collapsed); }

/* ---- Sidebar ---- */
.sidebar-header { padding: 1rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; gap: 0.75rem; min-height: var(--header-height); }
.sidebar-brand { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; }
.sidebar-brand small { display: block; font-weight: 400; font-size: 0.7rem; opacity: 0.7; }
.sidebar-toggle { background: none; border: none; color: #fff; cursor: pointer; padding: 0.25rem; font-size: 1.1rem; opacity: 0.8; }
.sidebar-toggle:hover { opacity: 1; }

.sidebar-nav { padding: 0.5rem 0; }
.sidebar-section { padding: 0.5rem 1.25rem 0.25rem; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.4); font-weight: 600; white-space: nowrap; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 1.25rem; color: rgba(255,255,255,0.7); font-size: 0.85rem; transition: all 0.15s; white-space: nowrap; border-radius: 0; }
.sidebar-nav .nav-link:hover { color: #fff; background: rgba(255,255,255,0.08); }
.sidebar-nav .nav-link.active { color: #fff; background: var(--secondary); }
.sidebar-nav .nav-link i { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-nav .nav-link .badge { margin-left: auto; font-size: 0.65rem; }
.sidebar-nav.collapsed .nav-link span,
.sidebar-nav.collapsed .sidebar-section,
.sidebar-nav.collapsed .nav-link .badge { display: none; }

/* ---- Top Header ---- */
.app-header { background: #fff; border-bottom: 1px solid var(--border-color); padding: 0 1.5rem; display: flex; align-items: center; justify-content: space-between; height: var(--header-height); position: sticky; top: 0; z-index: 999; }
.header-left { display: flex; align-items: center; gap: 1rem; }
.header-right { display: flex; align-items: center; gap: 0.75rem; }

.page-title { font-size: 1rem; font-weight: 600; color: var(--gray-800); margin: 0; }
.breadcrumb { font-size: 0.75rem; margin: 0; background: none; padding: 0; }
.breadcrumb-item a { color: var(--gray-500); }
.breadcrumb-item.active { color: var(--gray-400); }

/* ---- Content ---- */
.app-content { padding: 1.25rem 1.5rem; flex: 1; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 0.75rem; }

/* ---- Cards ---- */
.card { border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); background: #fff; }
.card-header { background: #fff; border-bottom: 1px solid var(--border-color); padding: 0.75rem 1rem; font-weight: 600; font-size: 0.875rem; }
.card-body { padding: 1rem; }
.card-footer { background: #fff; border-top: 1px solid var(--border-color); padding: 0.75rem 1rem; }

/* ---- KPI Cards ---- */
.kpi-card { border: 1px solid var(--border-color); border-radius: var(--radius-lg); background: #fff; padding: 1rem 1.25rem; box-shadow: var(--shadow-sm); }
.kpi-card .kpi-icon { width: 40px; height: 40px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.kpi-card .kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.kpi-card .kpi-label { font-size: 0.75rem; color: var(--gray-500); margin-top: 0.15rem; }

/* ---- Tables ---- */
.table-container { background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; }
.table-actions { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-color); flex-wrap: wrap; gap: 0.5rem; }
.table-responsive { overflow-x: auto; }
.table { margin: 0; font-size: 0.8125rem; }
.table th { background: var(--gray-50); font-weight: 600; color: var(--gray-600); border-bottom: 2px solid var(--border-color); padding: 0.6rem 0.75rem; white-space: nowrap; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
.table td { padding: 0.6rem 0.75rem; vertical-align: middle; border-bottom: 1px solid var(--border-color); }
.table tbody tr:hover { background: var(--gray-50); }
.table .actions { white-space: nowrap; }
.table .actions .btn { padding: 0.2rem 0.5rem; font-size: 0.75rem; }

/* ---- Badges ---- */
.badge-status { font-size: 0.7rem; padding: 0.25em 0.6em; font-weight: 500; border-radius: 4px; }
.badge-available { background: #dcfce7; color: #166534; }
.badge-low_stock { background: #fef3c7; color: #92400e; }
.badge-out_of_stock { background: #fecaca; color: #991b1b; }
.badge-inactive { background: #e5e7eb; color: #374151; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-draft { background: #e5e7eb; color: #374151; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fecaca; color: #991b1b; }
.badge-refunded { background: #e0e7ff; color: #3730a3; }
.badge-returned { background: #fef3c7; color: #92400e; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-partial { background: #fef3c7; color: #92400e; }
.badge-unpaid { background: #fecaca; color: #991b1b; }
.badge-overpaid { background: #dbeafe; color: #1e40af; }

/* ---- Buttons ---- */
.btn { font-size: 0.8125rem; border-radius: var(--radius); padding: 0.4rem 0.8rem; font-weight: 500; }
.btn-primary { background: var(--secondary); border-color: var(--secondary); }
.btn-primary:hover { background: #4f46e5; border-color: #4f46e5; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.75rem; }
.btn-icon { display: inline-flex; align-items: center; gap: 0.35rem; }

/* ---- Forms ---- */
.form-label { font-size: 0.8125rem; font-weight: 500; color: var(--gray-700); margin-bottom: 0.25rem; }
.form-control, .form-select { font-size: 0.8125rem; border-radius: var(--radius); border-color: var(--gray-300); }
.form-control:focus, .form-select:focus { border-color: var(--secondary); box-shadow: 0 0 0 2px rgba(99,102,241,0.15); }
.input-group-text { font-size: 0.8125rem; }

/* ---- Summary Box ---- */
.summary-box { background: var(--gray-50); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 1rem; }
.summary-row { display: flex; justify-content: space-between; padding: 0.35rem 0; font-size: 0.85rem; }
.summary-row.total { font-weight: 700; font-size: 1.05rem; border-top: 2px solid var(--gray-800); padding-top: 0.5rem; margin-top: 0.25rem; }
.summary-row .label { color: var(--gray-600); }
.summary-row .value { font-weight: 600; }

/* ---- Notification Dropdown ---- */
.notification-badge { position: relative; }
.notification-badge .badge { position: absolute; top: -4px; right: -4px; font-size: 0.6rem; padding: 0.15em 0.4em; }
.notification-list { max-height: 300px; overflow-y: auto; }
.notification-item { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border-color); font-size: 0.8rem; }
.notification-item.unread { background: #f0f4ff; }
.notification-item .title { font-weight: 600; }
.notification-item .time { font-size: 0.7rem; color: var(--gray-500); }

/* ---- POS Specific ---- */
.pos-wrapper { display: flex; gap: 1rem; height: calc(100vh - var(--header-height) - 2rem); }
.pos-products { flex: 1; display: flex; flex-direction: column; }
.pos-cart { width: 380px; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; }
.pos-cart-header { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-color); font-weight: 600; }
.pos-cart-items { flex: 1; overflow-y: auto; padding: 0.5rem; }
.pos-cart-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem; border-radius: var(--radius); margin-bottom: 0.25rem; background: var(--gray-50); }
.pos-cart-item .item-name { font-size: 0.8rem; font-weight: 500; flex: 1; }
.pos-cart-item .item-price { font-size: 0.75rem; color: var(--gray-600); }
.pos-cart-footer { border-top: 1px solid var(--border-color); padding: 0.75rem 1rem; }

/* ---- Login ---- */
.login-bg { background: var(--gray-100); min-height: 100vh; display: flex; align-items: center; justify-content: center; }

/* ---- Responsive ---- */
@media (max-width: 992px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.show { transform: translateX(0); }
    .app-main { margin-left: 0 !important; }
    .pos-cart { width: 100%; }
    .pos-wrapper { flex-direction: column; height: auto; }
}

@media (max-width: 576px) {
    .app-content { padding: 0.75rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .kpi-card .kpi-value { font-size: 1.25rem; }
}

/* ---- Print Styles ---- */
@media print {
    .app-sidebar, .app-header, .no-print { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .app-content { padding: 0; }
    .card { border: none; box-shadow: none; }
}

/* ---- Utilities ---- */
.text-success-dark { color: #166534 !important; }
.text-danger-dark { color: #991b1b !important; }
.text-warning-dark { color: #92400e !important; }
.bg-primary-light { background: rgba(99,102,241,0.1); color: var(--secondary); }
.border-start-primary { border-left: 3px solid var(--secondary) !important; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--gray-50); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
