/* ============================================================
   IndoDash — E-Commerce Dashboard Theme
   Clean · Lightweight · Bootstrap 5.3
   ============================================================ */

/* ── ROOT VARIABLES ──────────────────────────────────────── */
:root {
  --primary:        #4F46E5;
  --primary-hover:  #4338CA;
  --primary-light:  #EEF2FF;
  --primary-soft:   #C7D2FE;

  --success:        #10B981;
  --success-light:  #D1FAE5;
  --warning:        #F59E0B;
  --warning-light:  #FEF3C7;
  --danger:         #EF4444;
  --danger-light:   #FEE2E2;
  --info:           #0EA5E9;
  --info-light:     #E0F2FE;

  --sidebar-bg:     #0F172A;
  --sidebar-width:  240px;
  --sidebar-text:   #94A3B8;
  --sidebar-hover:  rgba(255,255,255,.06);
  --sidebar-active: rgba(79,70,229,.25);
  --sidebar-border: rgba(255,255,255,.06);

  --topbar-height:  60px;
  --bg:             #F1F5F9;
  --card-bg:        #FFFFFF;
  --border:         #E2E8F0;
  --text:           #0F172A;
  --text-muted:     #64748B;
  --text-sm:        #94A3B8;

  --radius:         .625rem;
  --radius-sm:      .375rem;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:         0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);

  --font: 'Inter', sans-serif;
}

/* ── BASE ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font);
  font-size: .875rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ── APP WRAPPER ─────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform .25s ease;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: 1.125rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: .5rem;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: .9rem;
}
.sidebar-logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}
.sidebar-logo-text span { color: var(--primary-soft); }

.sidebar-nav { padding: .75rem 0; flex: 1; }

.sidebar-section {
  padding: .625rem 1.25rem .25rem;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  margin-top: .25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem 1.25rem;
  color: var(--sidebar-text);
  font-size: .825rem;
  font-weight: 500;
  border-radius: 0;
  transition: background .15s, color .15s;
  position: relative;
  cursor: pointer;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: #CBD5E1; }
.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}
.sidebar-link i { font-size: 1rem; flex-shrink: 0; width: 18px; text-align: center; }

.sidebar-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 100px;
  line-height: 1.4;
}

.sidebar-footer {
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-shrink: 0;
}
.sidebar-footer-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.sidebar-footer-name { color: #CBD5E1; font-size: .8rem; font-weight: 600; }
.sidebar-footer-role { color: #475569; font-size: .7rem; }
.sidebar-footer-logout {
  margin-left: auto;
  color: #475569;
  font-size: .95rem;
  transition: color .15s;
}
.sidebar-footer-logout:hover { color: #EF4444; }

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

/* ── TOPBAR ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 900;
}
.topbar-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.topbar-search {
  flex: 1;
  max-width: 320px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 .875rem 0 2.25rem;
  font-size: .8rem;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.topbar-search input:focus { border-color: var(--primary); }
.topbar-search input::placeholder { color: var(--text-sm); }
.topbar-search i {
  position: absolute;
  left: .7rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-sm);
  font-size: .85rem;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.topbar-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: .95rem;
  cursor: pointer;
  position: relative;
  transition: background .15s, color .15s;
}
.topbar-btn:hover { background: var(--primary-light); color: var(--primary); }
.topbar-btn .badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 1.5px solid #fff;
}
.topbar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid var(--border);
}

/* ── PAGE BODY ───────────────────────────────────────────── */
.page-body { padding: 1.5rem; flex: 1; }

.page-title { font-size: 1.15rem; font-weight: 700; margin-bottom: .25rem; }
.page-subtitle { font-size: .8rem; color: var(--text-muted); margin-bottom: 1.25rem; }

/* ── STAT CARDS ──────────────────────────────────────────── */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.stat-value { font-size: 1.35rem; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: .15rem; }
.stat-change { font-size: .72rem; font-weight: 600; margin-top: .4rem; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.card-title { font-size: .9rem; font-weight: 700; }
.card-body { padding: 1.25rem; }
.card-footer {
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: .78rem;
  color: var(--text-muted);
}

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: .625rem 1rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .825rem;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FAFAFA; }

/* ── BADGES / STATUS ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .7rem;
  font-weight: 600;
  padding: .28rem .65rem;
  border-radius: 100px;
  white-space: nowrap;
}
.badge-success  { background: var(--success-light); color: #065F46; }
.badge-warning  { background: var(--warning-light); color: #92400E; }
.badge-danger   { background: var(--danger-light);  color: #991B1B; }
.badge-info     { background: var(--info-light);    color: #0C4A6E; }
.badge-primary  { background: var(--primary-light); color: var(--primary); }
.badge-gray     { background: #F1F5F9; color: #475569; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, box-shadow .15s, transform .1s;
  white-space: nowrap;
  font-family: var(--font);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-outline:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: .35rem .75rem; font-size: .76rem; }
.btn-icon { padding: .4rem; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; transition: background .15s, color .15s; }
.btn-icon:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary-soft); }

/* ── FORM CONTROLS ───────────────────────────────────────── */
.form-label { font-size: .78rem; font-weight: 600; color: var(--text); margin-bottom: .375rem; display: block; }
.form-control, .form-select {
  width: 100%;
  padding: .5rem .875rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .825rem;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: var(--font);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-control::placeholder { color: var(--text-sm); }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-group { margin-bottom: 1rem; }

/* ── AVATAR ──────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  color: var(--primary);
  font-size: .75rem;
}

/* ── PRODUCT IMAGE ───────────────────────────────────────── */
.product-thumb {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}

/* ── PAGINATION ──────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: .25rem; }
.page-btn {
  min-width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0 .5rem;
  transition: background .15s, color .15s;
}
.page-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary-soft); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: default; pointer-events: none; }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(2px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0,0,0,.18);
  overflow: hidden;
}
.modal-box.modal-lg { max-width: 720px; }
.modal-header {
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-size: .95rem; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  transition: background .15s;
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }
.modal-body { padding: 1.25rem 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: .875rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: .625rem;
  flex-shrink: 0;
}

/* ── CHART WRAPPER ───────────────────────────────────────── */
.chart-wrap { position: relative; }
.chart-wrap canvas { display: block; }

/* ── PROGRESS BAR ────────────────────────────────────────── */
.progress-bar-wrap {
  height: 6px;
  background: var(--bg);
  border-radius: 100px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width .6s ease;
}

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; color: var(--border); margin-bottom: .75rem; display: block; }
.empty-state p { font-size: .85rem; }

/* ── ALERT ───────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  display: flex;
  align-items: flex-start;
  gap: .625rem;
  margin-bottom: 1rem;
}
.alert-success { background: var(--success-light); color: #065F46; }
.alert-warning { background: var(--warning-light); color: #92400E; }
.alert-danger  { background: var(--danger-light);  color: #991B1B; }
.alert-info    { background: var(--info-light);    color: #0C4A6E; }

/* ── UTILITIES ───────────────────────────────────────────── */
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.text-muted { color: var(--text-muted) !important; }
.text-sm { font-size: .78rem; }
.text-xs { font-size: .7rem; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.ms-auto { margin-left: auto; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .25rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.w-100 { width: 100%; }
.rounded-full { border-radius: 50%; }
.overflow-hidden { overflow: hidden; }
.border-bottom { border-bottom: 1px solid var(--border); }

/* ── LAYOUT GRIDS ────────────────────────────────────────── */
/* Named grid helpers — replace inline grid styles so media queries can override */
.g-chart-split   { display: grid; grid-template-columns: 1fr 320px; gap: 1rem; }
.g-content-split { display: grid; grid-template-columns: 1fr 340px; gap: 1rem; }
.g-detail        { display: grid; grid-template-columns: 1fr 300px; gap: 1rem; align-items: start; }
.g-report-top    { display: grid; grid-template-columns: 2fr 1fr;   gap: 1rem; }
.g-2col          { display: grid; grid-template-columns: 1fr 1fr;   gap: 1rem; }
.g-settings      { display: grid; grid-template-columns: 220px 1fr; gap: 1.25rem; align-items: start; }
.g-modal-form    { display: grid; grid-template-columns: 1fr 1fr;   gap: 1rem; }

/* ── SETTINGS NAV ────────────────────────────────────────── */
.settings-nav {
  display: flex;
  flex-direction: column;
  padding: .5rem;
  height: fit-content;
}

/* ── MOBILE TOGGLE ───────────────────────────────────────── */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 999;
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .topbar { padding: 0 1rem; }
  .topbar-search { max-width: 200px; }
  .page-body { padding: 1rem; }
}

@media (max-width: 768px) {
  /* Two-column page grids collapse to single column */
  .g-chart-split,
  .g-content-split,
  .g-detail,
  .g-report-top,
  .g-2col { grid-template-columns: 1fr; }

  /* Settings layout: nav above content */
  .g-settings { grid-template-columns: 1fr; }
  .settings-nav {
    flex-direction: row;
    overflow-x: auto;
    flex-wrap: nowrap;
    height: auto;
    gap: .25rem;
    padding: .5rem;
    border-bottom: 1px solid var(--sidebar-border);
    scrollbar-width: none;
  }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav .sidebar-link {
    flex-shrink: 0;
    padding: .5rem .875rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    font-size: .78rem;
  }
  .settings-nav .sidebar-link::before { display: none; }

  .topbar-search { max-width: 180px; }
  .card-header { flex-wrap: wrap; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
}

@media (max-width: 575px) {
  .topbar { padding: 0 .875rem; gap: .5rem; }
  .topbar-search { display: none; }
  .page-body { padding: .875rem; }

  .stat-card { padding: 1rem; }
  .stat-value { font-size: 1.15rem; }
  .page-title { font-size: 1rem; }

  /* Modal slides up from bottom on phones */
  .modal-overlay { padding: .5rem; align-items: flex-end; }
  .modal-box {
    max-height: 94vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .modal-body { padding: 1rem; }
  .modal-header,
  .modal-footer { padding: .875rem 1rem; }

  /* Modal forms: single column, reset span-2 items */
  .g-modal-form { grid-template-columns: 1fr; }
  .g-modal-form > * { grid-column: auto !important; }

  /* Pagination wraps on small screens */
  .pagination { flex-wrap: wrap; justify-content: center; }
}

/* ── LOGIN PAGE ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  padding: 1rem;
}
.login-card {
  background: var(--card-bg);
  border-radius: calc(var(--radius) * 1.5);
  padding: 2.25rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px rgba(0,0,0,.3);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin-bottom: 1.75rem;
}
.login-logo-icon {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: .625rem;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem;
}
.login-logo-text { font-size: 1.2rem; font-weight: 800; color: var(--text); }
.login-logo-text span { color: var(--primary); }
.login-title { font-size: 1.3rem; font-weight: 800; margin-bottom: .25rem; }
.login-subtitle { font-size: .82rem; color: var(--text-muted); margin-bottom: 1.75rem; }
.password-wrap { position: relative; }
.password-wrap .form-control { padding-right: 2.5rem; }
.password-toggle {
  position: absolute; right: .75rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-sm);
  cursor: pointer;
  font-size: .95rem;
  transition: color .15s;
}
.password-toggle:hover { color: var(--primary); }
