/* ============================================================
   ENBE Grosir — Custom Stylesheet
   ============================================================ */

:root {
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 68px;
  --topnav-height: 56px;
  --primary: #1e3a5f;
  --primary-light: #2d5a9e;
  --accent: #e67e22;
  --sidebar-bg: #1a2035;
  --sidebar-text: #c8cfe8;
  --sidebar-hover: rgba(255,255,255,.07);
  --sidebar-active-bg: var(--accent);
}

/* ── RESET & BASE ── */
* { box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: #f0f2f7; font-size: .9rem; }

/* ── TOP NAV ── */
.top-nav {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  height: var(--topnav-height);
  z-index: 1050;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.top-nav .navbar-brand { font-size: 1.1rem; letter-spacing: .5px; }
.sidebar-toggle { padding: 4px 8px; border: none !important; }

/* ── WRAPPER ── */
.wrapper { padding-top: var(--topnav-height); min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - var(--topnav-height));
  background: var(--sidebar-bg);
  position: fixed;
  top: var(--topnav-height);
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .25s ease;
  z-index: 1040;
  box-shadow: 2px 0 10px rgba(0,0,0,.2);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.35); }
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar-inner { padding: 12px 0 32px; }
.sidebar-nav { list-style: none; padding: 0; margin: 0; }

.sidebar-section {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #5a6a8a;
  padding: 18px 20px 6px;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar.collapsed .sidebar-section { opacity: 0; }

.sidebar-item { position: relative; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background .2s, color .2s;
  white-space: nowrap;
}
.sidebar-link i:first-child { font-size: 1rem; width: 20px; flex-shrink: 0; text-align: center; }
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-item.active > .sidebar-link {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-link .arrow { display: none; }

/* Submenu */
.submenu {
  list-style: none;
  padding: 0;
  background: rgba(0,0,0,.15);
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}
.sidebar-item.has-submenu.open .submenu { max-height: 400px; }
.submenu li a {
  display: block;
  padding: 8px 20px 8px 50px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .85rem;
  transition: background .2s, color .2s;
}
.submenu li a:hover { background: var(--sidebar-hover); color: #fff; }
.submenu li.active a { color: var(--accent); font-weight: 600; }
.arrow { font-size: .7rem !important; transition: transform .25s; }
.sidebar-item.has-submenu.open .arrow { transform: rotate(90deg); }

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-width);
  transition: margin-left .25s ease;
  min-height: calc(100vh - var(--topnav-height));
  flex: 1;
}
.main-content.expanded { margin-left: var(--sidebar-collapsed-width); }
.content-inner { padding: 24px; }

/* ── CARDS ── */
.card { border: none; box-shadow: 0 2px 8px rgba(0,0,0,.08); border-radius: 10px; }
.card-header {
  background: #fff;
  border-bottom: 2px solid #f0f2f7;
  font-weight: 600;
  border-radius: 10px 10px 0 0 !important;
  padding: 14px 20px;
}
.card-header .card-title { font-size: .95rem; margin: 0; color: var(--primary); }

/* ── STAT CARDS ── */
.stat-card { border-radius: 12px; color: #fff; padding: 20px; position: relative; overflow: hidden; }
.stat-card .stat-icon { font-size: 3rem; opacity: .2; position: absolute; right: 16px; bottom: 8px; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-card .stat-label { font-size: .8rem; opacity: .85; }
.stat-card.blue  { background: linear-gradient(135deg, #1e3a5f, #2d5a9e); }
.stat-card.green { background: linear-gradient(135deg, #0f6b3d, #27ae60); }
.stat-card.orange{ background: linear-gradient(135deg, #b94e00, #e67e22); }
.stat-card.purple{ background: linear-gradient(135deg, #4a1569, #8e44ad); }

/* ── TABLES ── */
.table-responsive { border-radius: 0 0 10px 10px; }
.table thead th {
  background: #f7f8fc;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #64748b;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}
.table tbody tr:hover { background: #f7f9ff; }
.table td { vertical-align: middle; }

/* ── FORMS ── */
.form-label { font-weight: 500; font-size: .85rem; }
.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(45,90,158,.15);
}
.form-section-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--primary);
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 6px;
  margin-bottom: 16px;
}

/* ── BUTTONS ── */
.btn { border-radius: 6px; font-size: .85rem; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-xs { padding: 2px 8px; font-size: .75rem; }

/* ── BADGES ── */
.badge { font-size: .72rem; font-weight: 600; border-radius: 5px; }

/* ── INVOICE / PO EDITOR TABLE ── */
.editor-table { border-collapse: collapse; width: 100%; }
.editor-table th {
  background: var(--primary);
  color: #fff;
  font-size: .78rem;
  font-weight: 600;
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.editor-table td { padding: 4px 6px; border-bottom: 1px solid #e8ecf3; vertical-align: middle; }
.editor-table tr:hover > td { background: #f0f6ff; }
.editor-table tr.active-row > td { background: #e8f0fe !important; }
.editor-table input.cell-input {
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: .85rem;
  transition: border-color .15s, background .15s;
  outline: none;
}
.editor-table input.cell-input:focus {
  border-color: var(--primary-light);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(45,90,158,.15);
}
.editor-table select.cell-select {
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 2px;
  border-radius: 4px;
  font-size: .85rem;
  width: 100%;
  cursor: pointer;
}
.editor-table select.cell-select:focus {
  border-color: var(--primary-light);
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(45,90,158,.15);
}
.editor-table .cell-num { text-align: right; font-variant-numeric: tabular-nums; }
.editor-table .cell-subtotal { font-weight: 600; color: var(--primary); }
.editor-table .row-no { color: #94a3b8; font-size: .78rem; text-align: center; width: 36px; }
.editor-table .btn-remove-row {
  background: none; border: none; color: #ef4444; font-size: .95rem; cursor: pointer; padding: 2px 6px;
  opacity: .5; transition: opacity .2s;
}
.editor-table .btn-remove-row:hover { opacity: 1; }
.editor-table-footer { background: #f7f8fc; border-top: 2px solid #e2e8f0; padding: 12px 20px; }
.sku-not-found { font-size: .75rem; color: #ef4444; padding: 2px 0; display: none; }

/* ── TOTAL SUMMARY ── */
.total-summary { background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.total-summary .total-row { display: flex; justify-content: space-between; padding: 8px 16px; border-bottom: 1px solid #f1f5f9; }
.total-summary .total-row:last-child { border-bottom: none; background: var(--primary); color: #fff; border-radius: 0 0 8px 8px; font-weight: 700; font-size: 1rem; }

/* ── AUTH PAGES ── */
.auth-wrapper { min-height: 100vh; background: linear-gradient(135deg, #1a2035 0%, #1e3a5f 50%, #2d5a9e 100%); display: flex; align-items: center; justify-content: center; }
.auth-card { width: 420px; max-width: 95vw; background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; }
.auth-header { background: linear-gradient(135deg, var(--primary), var(--primary-light)); padding: 32px; text-align: center; color: #fff; }
.auth-header .brand-icon { font-size: 3rem; margin-bottom: 8px; }
.auth-header h4 { font-weight: 700; margin: 0; }
.auth-body { padding: 32px; }

/* ── MISC ── */
.page-title { font-size: 1.3rem; font-weight: 700; color: var(--primary); margin: 0; }
.search-bar .form-control { border-radius: 20px; padding-left: 14px; }
.tooltip-inner { font-size: .78rem; }
.cursor-pointer { cursor: pointer; }
.text-rupiah { font-variant-numeric: tabular-nums; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 0; overflow: hidden; }
  .sidebar.mobile-open { width: var(--sidebar-width); }
  .main-content { margin-left: 0; }
  .content-inner { padding: 16px; }
}
