/* ============================================================
   ERP SYSTEM - Dark Theme
   Modern Admin Panel CSS
   ============================================================ */

/* ─── CSS Variables ───────────────────────────────────────── */
:root {
  --bg-primary:     #0f1117;
  --bg-secondary:   #161b27;
  --bg-tertiary:    #1e2845;
  --bg-card:        #1a2035;
  --bg-card-hover:  #1e2845;
  --bg-input:       #111827;
  --bg-sidebar:     #0d1321;
  --bg-topbar:      #161b27;
  --border:         #2a3352;
  --border-light:   #1e2845;
  --border-color:   #2a3352;

  --text-primary:   #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-white:     #ffffff;

  --accent:         #6366f1;
  --accent-light:   #818cf8;
  --accent-dark:    #4f46e5;
  --accent-glow:    rgba(99, 102, 241, 0.25);

  --color-primary:  #6366f1;
  --color-success:  #10b981;
  --color-danger:   #ef4444;
  --color-warning:  #f59e0b;
  --color-info:     #3b82f6;

  --success:        #10b981;
  --success-bg:     rgba(16,185,129,0.15);
  --warning:        #f59e0b;
  --warning-bg:     rgba(245,158,11,0.15);
  --danger:         #ef4444;
  --danger-bg:      rgba(239,68,68,0.15);
  --info:           #3b82f6;
  --info-bg:        rgba(59,130,246,0.15);

  --sidebar-width:  260px;
  --topbar-height:  64px;
  --radius:         12px;
  --radius-sm:      8px;
  --radius-lg:      16px;
  --shadow:         0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg:      0 8px 40px rgba(0,0,0,0.6);
  --transition:     all 0.25s cubic-bezier(0.4,0,0.2,1);

  /* Chart colors */
  --chart-1: #6366f1;
  --chart-2: #10b981;
  --chart-3: #f59e0b;
  --chart-4: #ef4444;
  --chart-5: #3b82f6;
  --chart-6: #a855f7;
}

/* ─── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent-light); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--text-white); }

/* ─── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ─── Layout ──────────────────────────────────────────────── */
.layout-wrapper { display: flex; min-height: 100vh; }

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 3px; }

.sidebar-logo {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-height);
}
.sidebar-logo .logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 0 15px var(--accent-glow);
}
.sidebar-logo .logo-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.sidebar-logo .logo-version {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 400;
}

.sidebar-nav { flex: 1; padding: 16px 0; }

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 12px 24px 6px;
  margin-top: 8px;
}

.nav-item { position: relative; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0;
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}
.nav-link:hover {
  color: var(--text-white);
  background: rgba(99,102,241,0.08);
}
.nav-link.active {
  color: var(--text-white);
  background: linear-gradient(90deg, rgba(99,102,241,0.2), transparent);
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-link .nav-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.nav-link .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.nav-link .nav-arrow {
  margin-left: auto;
  font-size: 0.75rem;
  transition: transform 0.2s;
  color: var(--text-muted);
}
.nav-link[aria-expanded="true"] .nav-arrow { transform: rotate(90deg); }

.nav-submenu {
  background: rgba(0,0,0,0.15);
  display: none;
}
.nav-submenu.show { display: block; }
.nav-submenu .nav-link {
  padding-left: 56px;
  font-size: 0.825rem;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  color: white;
  flex-shrink: 0;
}
.sidebar-user .user-info .user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}
.sidebar-user .user-info .user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.sidebar-user .logout-btn {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-user .logout-btn:hover { color: var(--danger); background: var(--danger-bg); }

/* ─── Main Content ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ─── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-white);
  flex: 1;
}
.topbar-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  display: block;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.topbar-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
}
.icon-btn:hover { color: var(--text-white); border-color: var(--accent); background: var(--accent-glow); }

/* ─── Page Content ────────────────────────────────────────── */
.page-content { padding: 24px 28px; flex: 1; }

/* ─── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}
.card:hover { border-color: var(--border-light); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-white);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
}

/* ─── Stat Cards ──────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.stat-card.blue::before   { background: linear-gradient(90deg, var(--info), transparent); }
.stat-card.green::before  { background: linear-gradient(90deg, var(--success), transparent); }
.stat-card.yellow::before { background: linear-gradient(90deg, var(--warning), transparent); }
.stat-card.red::before    { background: linear-gradient(90deg, var(--danger), transparent); }
.stat-card.purple::before { background: linear-gradient(90deg, var(--accent), transparent); }

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
  box-shadow: var(--shadow);
}
.stat-card .stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.stat-card .stat-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-card .stat-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.stat-card.blue   .stat-icon { background: var(--info-bg); color: var(--info); }
.stat-card.green  .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-card.yellow .stat-icon { background: var(--warning-bg); color: var(--warning); }
.stat-card.red    .stat-icon { background: var(--danger-bg); color: var(--danger); }
.stat-card.purple .stat-icon { background: var(--accent-glow); color: var(--accent-light); }

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-white);
  line-height: 1.2;
  margin-bottom: 6px;
}
.stat-card.blue   .stat-value { color: var(--info); }
.stat-card.green  .stat-value { color: var(--success); }
.stat-card.yellow .stat-value { color: var(--warning); }
.stat-card.red    .stat-value { color: var(--danger); }
.stat-card.purple .stat-value { color: var(--accent-light); }

.stat-card .stat-change {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }
.stat-change.neutral  { color: var(--text-muted); }

/* ─── Grid ────────────────────────────────────────────────── */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }

/* ─── Tables ──────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.table thead th {
  background: rgba(0,0,0,0.2);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tbody tr:hover { background: rgba(99,102,241,0.04); }
.table tbody tr:last-child td { border-bottom: none; }
.table .text-right { text-align: right; }
.table .text-center { text-align: center; }

/* ─── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success   { background: var(--success-bg); color: var(--success); }
.badge-danger    { background: var(--danger-bg);  color: var(--danger); }
.badge-warning   { background: var(--warning-bg); color: var(--warning); }
.badge-info      { background: var(--info-bg);    color: var(--info); }
.badge-secondary { background: rgba(100,116,139,0.15); color: var(--text-secondary); }
.badge-primary   { background: var(--accent-glow); color: var(--accent-light); }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dark); color: white; box-shadow: 0 0 20px var(--accent-glow); }

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-success:hover { background: #059669; color: white; }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { background: #dc2626; color: white; }

.btn-warning {
  background: var(--warning);
  color: #000;
  border-color: var(--warning);
}
.btn-warning:hover { background: #d97706; }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent-light); background: var(--accent-glow); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-card); color: var(--text-white); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 9px; }
.btn-icon.btn-sm { padding: 6px; }

/* ─── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-label.required::after { content: ' *'; color: var(--danger); }

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 14px;
  font-size: 0.875rem;
  transition: var(--transition);
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-input);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { opacity: 0.5; cursor: not-allowed; }

select.form-control { cursor: pointer; }
select.form-control option { background: var(--bg-card); }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-row-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, 1fr); }
.form-row-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); }

.form-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-white);
  margin: 20px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}
.form-section-title:first-child { margin-top: 0; }

.form-text { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 4px; }

.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.form-check-label { font-size: 0.875rem; color: var(--text-primary); cursor: pointer; }

/* ─── Input Group ─────────────────────────────────────────── */
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .input-group-text {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: none;
  padding: 9px 12px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  white-space: nowrap;
}
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ─── Alerts / Flash Messages ─────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.3); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid rgba(59,130,246,0.3); }

/* ─── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header-title { font-size: 1.3rem; font-weight: 700; color: var(--text-white); }
.page-header-subtitle { font-size: 0.825rem; color: var(--text-muted); margin-top: 2px; }
.page-header-actions { display: flex; gap: 10px; align-items: center; }

/* ─── Breadcrumb ──────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent-light); }
.breadcrumb-sep { color: var(--border); }
.breadcrumb-current { color: var(--text-secondary); }

/* ─── Pagination ──────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  list-style: none;
  justify-content: center;
  margin-top: 20px;
}
.page-item .page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: var(--transition);
}
.page-item.active .page-link,
.page-item .page-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ─── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text-white); }
.tab-btn.active { color: var(--accent-light); border-bottom-color: var(--accent); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ─── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-backdrop.show { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.2s;
}
.modal-backdrop.show .modal { transform: translateY(0); }
.modal.modal-lg { max-width: 800px; }
.modal.modal-xl { max-width: 1100px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 600; color: var(--text-white); }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  line-height: 1;
}
.modal-close:hover { color: var(--danger); background: var(--danger-bg); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ─── Search & Filter Bar ─────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
}
.filter-bar .form-control { background: var(--bg-input); }
.search-input {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-input .form-control { padding-left: 36px; }
.search-input .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ─── Chart Containers ────────────────────────────────────── */
.chart-container { position: relative; }
.chart-container canvas { max-width: 100%; }

/* ─── Loading Spinner ─────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state .empty-title { font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.empty-state .empty-text { font-size: 0.875rem; }

/* ─── Dropdown ────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  right: 0; top: calc(100% + 4px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 180px;
  box-shadow: var(--shadow);
  z-index: 150;
  overflow: hidden;
  display: none;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.dropdown-item:hover { background: var(--bg-card-hover); color: var(--text-white); }
.dropdown-item.danger:hover { color: var(--danger); background: var(--danger-bg); }
.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ─── Info Rows (Cari/Detail) ─────────────────────────────── */
.info-row {
  display: flex;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}
.info-row:last-child { border-bottom: none; }
.info-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 120px;
  flex-shrink: 0;
}
.info-value { font-size: 0.875rem; color: var(--text-primary); }

/* ─── Number Inputs ───────────────────────────────────────── */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { opacity: 0.5; }

/* ─── Utilities ───────────────────────────────────────────── */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }
.text-info    { color: var(--info)    !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-primary { color: var(--text-primary) !important; }
.text-white   { color: var(--text-white)  !important; }
.text-right   { text-align: right !important; }
.text-center  { text-align: center !important; }
.text-left    { text-align: left !important; }
.fw-bold      { font-weight: 700; }
.fw-semibold  { font-weight: 600; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.mb-0  { margin-bottom: 0 !important; }
.mb-8  { margin-bottom: 8px !important; }
.mb-12 { margin-bottom: 12px !important; }
.mb-16 { margin-bottom: 16px !important; }
.mb-20 { margin-bottom: 20px !important; }
.mb-24 { margin-bottom: 24px !important; }
.mt-8  { margin-top: 8px !important; }
.mt-16 { margin-top: 16px !important; }
.mt-20 { margin-top: 20px !important; }
.p-0   { padding: 0 !important; }
.w-100 { width: 100%; }
.cursor-pointer { cursor: pointer; }
.hidden { display: none !important; }
.mt-4 { margin-top: 24px !important; }
.flex-wrap { flex-wrap: wrap; }
.overflow-auto { overflow: auto; }

/* ─── Responsive ──────────────────────────────────────────── */

/* Desktop hamburger hidden */
.mobile-menu-btn { display: none; }

/* ── Large tablets / small desktops ── */
@media (max-width: 1200px) {
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ── Tablets ── */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-6, .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .col-2, .col-3 { grid-column: span 1; }
  .page-content { padding: 20px; }
}

/* ── Mobile (< 768px) ── */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; --topbar-height: 56px; }

  /* Sidebar off-canvas */
  .sidebar {
    transform: translateX(-280px);
    width: 280px;
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0,0,0,0.5);
  }

  /* Main content full width */
  .main-content { margin-left: 0; }

  /* Show hamburger */
  .mobile-menu-btn { display: flex !important; }

  /* Topbar compact */
  .topbar {
    padding: 0 12px;
    height: var(--topbar-height);
    gap: 8px;
  }
  .topbar-title { font-size: 0.95rem; }
  .topbar-date { display: none; }
  .topbar-actions .btn span,
  .topbar-actions .btn-sm { font-size: 0.75rem; padding: 5px 10px; }

  /* Page content */
  .page-content { padding: 12px; }

  /* All grids single column */
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Forms single column */
  .form-row, .form-row-2, .form-row-3 { grid-template-columns: 1fr; gap: 12px; }

  /* Cards tighter padding */
  .card { padding: 14px; border-radius: var(--radius-sm); }
  .card-header { margin-bottom: 12px; padding-bottom: 10px; flex-wrap: wrap; gap: 8px; }

  /* Stat cards */
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 1.3rem; }
  .stat-card .stat-icon { width: 32px; height: 32px; font-size: 0.95rem; }
  .stat-card:hover { transform: none; }

  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-header-title { font-size: 1.1rem; }
  .page-header-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .page-header-actions .btn { flex: 1; min-width: 0; justify-content: center; }

  /* Tables - horizontal scroll with card-like rows */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -14px;
    padding: 0 14px;
  }
  .table { min-width: 600px; font-size: 0.8rem; }
  .table thead th { padding: 10px 12px; font-size: 0.7rem; }
  .table tbody td { padding: 10px 12px; }

  /* Filter bar */
  .filter-bar {
    flex-direction: column;
    padding: 12px;
    gap: 8px;
  }
  .filter-bar .form-control,
  .filter-bar .btn,
  .search-input { width: 100%; min-width: 0; }

  /* Buttons touch-friendly */
  .btn { padding: 10px 16px; font-size: 0.85rem; min-height: 44px; }
  .btn-sm { padding: 8px 12px; font-size: 0.8rem; min-height: 38px; }

  /* Form inputs touch-friendly */
  .form-control { padding: 11px 14px; font-size: 16px; min-height: 44px; }
  select.form-control { min-height: 44px; }
  textarea.form-control { min-height: 80px; }

  /* Info rows stack on mobile */
  .info-row { flex-direction: column; gap: 2px; padding: 10px 0; }
  .info-label { min-width: 0; font-size: 0.72rem; }
  .info-value { font-size: 0.9rem; }

  /* Badges & Pagination */
  .badge { font-size: 0.68rem; padding: 3px 8px; }
  .pagination { gap: 2px; flex-wrap: wrap; }
  .page-item .page-link { width: 36px; height: 36px; }

  /* Modal full-width on mobile */
  .modal {
    max-width: calc(100vw - 24px);
    max-height: 85vh;
    margin: 12px;
    border-radius: var(--radius);
  }
  .modal-body { padding: 16px; }
  .modal-header { padding: 14px 16px 12px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; }

  /* Tabs scrollable */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    flex-wrap: nowrap;
  }
  .tab-btn { padding: 10px 14px; font-size: 0.8rem; flex-shrink: 0; }

  /* Dropdown positioned correctly on mobile */
  .dropdown-menu { min-width: 160px; right: -8px; }

  /* Sidebar footer */
  .sidebar-footer { padding: 12px 16px; }

  /* Login page */
  .login-card { padding: 24px 20px; margin: 16px; }
  .login-logo .logo-circle { width: 50px; height: 50px; font-size: 1.5rem; }
  .login-logo h1 { font-size: 1.1rem; }

  /* Toast notifications */
  #toast-container { top: 10px; right: 10px; left: 10px; }

  /* Empty state */
  .empty-state { padding: 40px 16px; }
  .empty-state .empty-icon { font-size: 2.5rem; }

  /* Breadcrumb */
  .breadcrumb { font-size: 0.72rem; margin-bottom: 12px; overflow-x: auto; white-space: nowrap; }

  /* Order items table inputs */
  .form-control-sm,
  input.form-control[style*="width:80px"],
  input.form-control[style*="width:100px"],
  input.form-control[style*="width:60px"] {
    width: 100% !important;
    min-width: 60px;
  }

  /* Charts responsive */
  .chart-container { min-height: 200px; }
  .chart-container canvas { height: 200px !important; }

  /* Utilities */
  .hidden-mobile { display: none !important; }
}

/* ── Small phones (< 400px) ── */
@media (max-width: 400px) {
  html { font-size: 14px; }
  .page-content { padding: 8px; }
  .card { padding: 12px; }
  .stat-card .stat-value { font-size: 1.1rem; }
  .topbar-title { font-size: 0.85rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions .btn-sm { padding: 5px 8px; font-size: 0.72rem; }
  .topbar-actions .btn-sm i { margin: 0; }
  .topbar-actions .btn-sm span.btn-text { display: none; }
  .table { min-width: 500px; font-size: 0.75rem; }
  .filter-bar { padding: 10px; }
  .btn { font-size: 0.8rem; }
}

/* ── Touch device optimizations ── */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .nav-link { padding: 12px 24px; min-height: 44px; }
  .nav-submenu .nav-link { padding: 12px 24px 12px 56px; }
  .dropdown-item { padding: 12px 16px; min-height: 44px; }
  .page-item .page-link { width: 40px; height: 40px; }
  .icon-btn { width: 40px; height: 40px; }
  .form-check-input { width: 20px; height: 20px; }

  /* Remove hover effects on touch */
  .stat-card:hover { transform: none; box-shadow: none; border-color: var(--border); }
  .card:hover { border-color: var(--border); }

  /* Scroll hints */
  .table-wrapper { position: relative; }
  .table-wrapper::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(15,17,23,0.8));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
  }
  .table-wrapper.has-scroll::after { opacity: 1; }
}

/* ─── Sidebar Overlay (Mobile) ────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 99;
  transition: opacity 0.25s;
}
.sidebar-overlay.show { display: block; }

/* ─── Print ───────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .page-header-actions,
  .btn, .filter-bar, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  body { background: white !important; color: black !important; }
  .card { border: 1px solid #ddd !important; background: white !important; }
  .table tbody td, .table thead th { color: black !important; }
}

/* ─── Animations ──────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease forwards; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
.pulse { animation: pulse 2s ease infinite; }

/* ─── Tooltip ─────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 300;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ─── Login Page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(99,102,241,0.08) 0%, transparent 70%);
  top: -200px; right: -200px;
  pointer-events: none;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(16,185,129,0.05) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  pointer-events: none;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo .logo-circle {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 12px;
  box-shadow: 0 0 30px var(--accent-glow);
}
.login-logo h1 { font-size: 1.3rem; font-weight: 800; color: var(--text-white); }
.login-logo p { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ─── Progress bar ─────────────────────────────────────────── */
.progress {
  background: var(--bg-input);
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 0.5s ease;
}
