/* ============================================================
   POS SYSTEM - PRODUCTION STYLESHEET
   ============================================================ */

:root {
  --primary:      #2563eb;
  --primary-dark: #1d4ed8;
  --secondary:    #64748b;
  --success:      #16a34a;
  --danger:       #dc2626;
  --warning:      #d97706;
  --info:         #0891b2;
  --purple:       #7c3aed;
  --white:        #ffffff;
  --bg:           #f1f5f9;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --sidebar-w:    240px;
  --topbar-h:     56px;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

[data-theme="dark"] {
  --bg:       #0f172a;
  --surface:  #1e293b;
  --border:   #334155;
  --text:     #f1f5f9;
  --text-muted: #94a3b8;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }

/* ── LAYOUT ── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w); background: #1e293b; color: #cbd5e1;
  display: flex; flex-direction: column; z-index: 100;
  transition: width .25s;
}
.sidebar.collapsed { width: 56px; }
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem; height: var(--topbar-h); border-bottom: 1px solid #334155;
  font-weight: 700; font-size: 1rem; color: #fff;
}
.sidebar-toggle { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 1.2rem; }
.sidebar-menu {
  list-style: none; overflow-y: auto; flex: 1; padding: .5rem 0;
  scrollbar-width: none;      /* Firefox */
  -ms-overflow-style: none;   /* IE / legacy Edge */
}
.sidebar-menu::-webkit-scrollbar { display: none; width: 0; height: 0; } /* Chrome, Safari, new Edge */
.sidebar-menu li a {
  display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem;
  color: #94a3b8; border-radius: 6px; margin: 1px 8px;
  transition: background .15s, color .15s;
}
.sidebar-menu li a:hover, .sidebar-menu li.active a {
  background: rgba(255,255,255,.08); color: #fff; text-decoration: none;
}
.sidebar-menu li.active a { background: var(--primary); color: #fff; }
.menu-icon { font-size: 1rem; min-width: 20px; text-align: center; }
.menu-label { white-space: nowrap; overflow: hidden; }

.main-wrapper {
  margin-left: var(--sidebar-w); display: flex; flex-direction: column;
  min-height: 100vh; transition: margin-left .25s;
}
.main-wrapper.expanded { margin-left: 56px; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; box-shadow: var(--shadow);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-toggle { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); }

.breadcrumb { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-muted); }
.breadcrumb a { color: var(--primary); }
/* .breadcrumb a:hover { text-decoration: none; } */

.page-content { padding: 1.5rem; flex: 1; }

/* ── CARDS ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.25rem;
}
.card-header {
  padding: .875rem 1.25rem; font-weight: 600; font-size: .95rem;
  border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; gap: .75rem;
}
.card-body { padding: 1.25rem; }
.card-body.p-0 { padding: 0; }
.border-danger { border-color: var(--danger); }
.bg-danger { background: var(--danger) !important; }
.text-white { color: #fff !important; }

/* ── KPI ── */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi-card {
  background: var(--surface); border-radius: var(--radius); padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem; box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}
.kpi-green  { border-left-color: var(--success); }
.kpi-blue   { border-left-color: var(--primary); }
.kpi-orange { border-left-color: var(--warning); }
.kpi-red    { border-left-color: var(--danger); }
.kpi-purple { border-left-color: var(--purple); }
.kpi-icon   { font-size: 1.75rem; }
.kpi-value  { font-size: 1.2rem; font-weight: 700; line-height: 1.2; }
.kpi-label  { font-size: .8rem; color: var(--text-muted); }

/* ── DASHBOARD COLS ── */
.dashboard-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px,1fr)); gap: 1.25rem; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem 1rem; border-radius: var(--radius); border: none;
  font-size: .875rem; font-weight: 500; cursor: pointer;
  transition: opacity .15s, transform .1s; white-space: nowrap;
}
.btn:hover { opacity: .9; }
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-outline   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm        { padding: .3rem .7rem; font-size: .8rem; }
.btn-block     { width: 100%; justify-content: center; }
.btn-icon      { padding: .45rem; }

/* ── FORMS ── */
.form-group     { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .35rem; color: var(--text-muted); }
.form-control {
  width: 100%; padding: .5rem .75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: .875rem;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 1rem; }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn-toggle-pass {
  border: 1px solid var(--border); border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--bg); padding: 0 .75rem; cursor: pointer;
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── TABLES ── */
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
  padding: .65rem 1rem; text-align: left; font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.table td { padding: .65rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: rgba(37,99,235,.03); }
.table-sm th, .table-sm td { padding: .45rem .75rem; }
.table-warning td { background: rgba(217,119,6,.07); }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
}
.badge-draft         { background: #e2e8f0; color: #475569; }
.badge-active        { background: #dcfce7; color: #166534; }
.badge-paid          { background: #dcfce7; color: #166534; }
.badge-completed     { background: #dcfce7; color: #166534; }
.badge-sent          { background: #dbeafe; color: #1e40af; }
.badge-partially_paid{ background: #fef3c7; color: #92400e; }
.badge-overdue       { background: #fee2e2; color: #991b1b; }
.badge-cancelled     { background: #fee2e2; color: #991b1b; }
.badge-on_hold       { background: #fef3c7; color: #92400e; }
.badge-pending_approval { background: #fef3c7; color: #92400e; }
.badge-accepted      { background: #dcfce7; color: #166534; }
.badge-rejected      { background: #fee2e2; color: #991b1b; }
.badge-expired       { background: #fee2e2; color: #991b1b; }
.badge-converted     { background: #ede9fe; color: #5b21b6; }
.badge-pending       { background: #fef3c7; color: #92400e; }

/* ── ALERTS ── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .875rem; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ── MODALS ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 500; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-md);
  width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; margin: 1rem;
}
.modal-lg { max-width: 900px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 1rem;
}
.modal-body   { padding: 1.25rem; }
.modal-footer {
  padding: 1rem 1.25rem; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: .5rem;
}
.btn-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); }

/* ── NOTIFICATIONS ── */
.notif-btn   { background: none; border: none; cursor: pointer; font-size: 1rem; position: relative; }
.notif-btn .badge { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; min-width: 18px; height: 18px; font-size: .7rem; }
.notif-dropdown {
  position: absolute; top: 100%; right: 0; min-width: 320px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); z-index: 200;
}
.notif-header { padding: .75rem 1rem; font-weight: 600; border-bottom: 1px solid var(--border); }
.notif-all    { display: block; text-align: center; padding: .5rem; border-top: 1px solid var(--border); font-size: .85rem; }
#notifDropdown { position: relative; }

/* ── USER MENU ── */
.user-btn { background: none; border: none; cursor: pointer; color: var(--text); font-size: .875rem; }
.user-btn small { color: var(--text-muted); font-size: .78rem; }
.user-dropdown {
  position: absolute; top: 100%; right: 0; min-width: 200px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); z-index: 200;
}
.user-dropdown a { display: block; padding: .6rem 1rem; color: var(--text); font-size: .875rem; }
.user-dropdown a:hover { background: var(--bg); text-decoration: none; }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: .25rem 0; }
#userMenu { position: relative; }

/* ── PAGINATION ── */
.pagination { display: flex; align-items: center; gap: .25rem; margin-top: 1rem; }
.pagination button {
  padding: .35rem .65rem; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius); cursor: pointer; font-size: .85rem; color: var(--text);
}
.pagination button.active, .pagination button:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .5; cursor: not-allowed; }

/* ── SEARCH BAR ── */
.search-bar { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.search-bar .form-control { max-width: 300px; }

/* ── PERMISSION MATRIX ── */
.perm-matrix { overflow-x: auto; }
.perm-matrix table { font-size: .82rem; }
.perm-matrix th:first-child, .perm-matrix td:first-child { min-width: 180px; font-weight: 500; }
.perm-matrix input[type=checkbox] { cursor: pointer; width: 16px; height: 16px; }
.perm-group-header td { background: var(--bg); font-weight: 700; color: var(--text-muted); font-size: .78rem; text-transform: uppercase; }
.perm-premium td { background: rgba(124,58,237,.04); }
.perm-premium td:first-child::after { content: ' ★'; color: var(--purple); }

/* ── QUICK ACTIONS ── */
.quick-actions { display: flex; flex-wrap: wrap; gap: .75rem; }

/* ── STARS ── */
.stars { color: #fbbf24; letter-spacing: 1px; }

/* ── PROGRESS BAR ── */
.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }

/* ── STATUS INDICATOR ── */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.active    { background: var(--success); }
.status-dot.inactive  { background: var(--danger); }
.status-dot.pending   { background: var(--warning); }

/* ── TOAST ── */
#toastContainer { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  padding: .75rem 1.25rem; border-radius: var(--radius); box-shadow: var(--shadow-md);
  font-size: .875rem; min-width: 250px; max-width: 380px; animation: slideIn .2s ease;
}
.toast-success { background: #166534; color: #fff; }
.toast-error   { background: #991b1b; color: #fff; }
.toast-info    { background: #1e40af; color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── LOGIN PAGE ── */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; background: var(--bg); }
.login-container { width: 100%; max-width: 420px; padding: 1.5rem; }
.login-card { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-md); padding: 2rem; }
.login-header { text-align: center; margin-bottom: 1.5rem; }
.login-header h1 { font-size: 1.5rem; font-weight: 700; margin: .5rem 0 .25rem; }
.login-header p  { color: var(--text-muted); font-size: .9rem; }
.logo-placeholder { width: 60px; height: 60px; background: var(--primary); color: #fff; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; font-weight: 800; margin: 0 auto; }
.login-footer { text-align: center; margin-top: 1.5rem; color: var(--text-muted); }

/* ── UTILITIES ── */
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.text-muted    { color: var(--text-muted); }
.text-danger   { color: var(--danger); }
.text-success  { color: var(--success); }
.fw-bold       { font-weight: 700; }
.mt-1  { margin-top: .25rem; }
.mt-2  { margin-top: .5rem; }
.mt-3  { margin-top: 1rem; }
.mb-1  { margin-bottom: .25rem; }
.mb-2  { margin-bottom: .5rem; }
.mb-3  { margin-bottom: 1rem; }
.gap-2 { gap: .5rem; }
.flex  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.w-100 { width: 100%; }
.d-none { display: none; }
.overflow-auto { overflow: auto; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .kpi-row { grid-template-columns: repeat(2,1fr); }
  .dashboard-cols { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page-content { padding: 1rem; }
}