/* assets/css/style.css */
:root {
  --topnav-h: 58px;
  --sidebar-w: 240px;
  --radius: 10px;
  --radius-lg: 14px;
  --transition: 0.22s ease;

  /* Light */
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-topnav: #1a1f2e;
  --bg-sidebar: #1a1f2e;
  --bg-input: #ffffff;
  --bg-metric: #f4f6f9;

  --text: #1a1f2e;
  --text-muted: #6b7280;
  --text-hint: #9ca3af;
  --text-nav: rgba(255,255,255,0.72);
  --text-nav-active: #ffffff;

  --border: rgba(0,0,0,0.08);
  --border-md: rgba(0,0,0,0.14);

  --accent: #378ADD;
  --accent-hover: #2570c4;
  --success: #1D9E75;
  --warning: #BA7517;
  --danger: #E24B4A;
  --purple: #7F77DD;

  --shadow: 0 1px 4px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 18px rgba(0,0,0,0.11);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #1a1f2e;
  --bg-topnav: #0d1117;
  --bg-sidebar: #0d1117;
  --bg-input: #252b3b;
  --bg-metric: #252b3b;

  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --text-hint: #6b7280;
  --text-nav: rgba(255,255,255,0.65);
  --text-nav-active: #ffffff;

  --border: rgba(255,255,255,0.08);
  --border-md: rgba(255,255,255,0.13);

  --shadow: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 18px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* ============================================================
   TOPNAV — Desktop / TV: menu horizontal di atas
   ============================================================ */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topnav-h);
  background: var(--bg-topnav);
  z-index: 300;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.topnav-inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 20px;
  gap: 4px;
}

/* Logo */
.topnav-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  margin-right: 10px;
  flex-shrink: 0;
}
.topnav-logo i { font-size: 20px; color: var(--accent); }

/* Nav menu items */
.topnav-menu {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow: hidden;
}

.topnav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: var(--radius);
  color: var(--text-nav);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.topnav-item i { font-size: 16px; flex-shrink: 0; }

.topnav-item:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-nav-active);
}

.topnav-item.active {
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}

.topnav-logout { color: #f09595 !important; }
.topnav-logout:hover { background: rgba(226,75,74,0.18) !important; color: #fca5a5 !important; }

/* Right side: tema + user + hamburger */
.topnav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.theme-toggle {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  width: 34px; height: 34px;
  cursor: pointer;
  font-size: 17px;
  color: var(--text-nav);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover { background: rgba(255,255,255,0.16); color: #fff; }

.topnav-user {
  display: flex;
  align-items: center;
  gap: 7px;
}

.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-nav);
  white-space: nowrap;
}

/* Hamburger — tersembunyi di desktop, muncul di mobile */
.hamburger {
  display: none;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  width: 34px; height: 34px;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-nav);
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}
.hamburger:hover { background: rgba(255,255,255,0.16); color: #fff; }

/* ============================================================
   SIDEBAR — Mobile only (drawer)
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 400;
  transform: translateX(-100%);
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.open { transform: translateX(0); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--topnav-h);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}
.sidebar-logo i { font-size: 20px; color: var(--accent); }

.sidebar-close {
  background: none;
  border: none;
  color: var(--text-nav);
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}
.sidebar-close:hover { color: #fff; }

.sidebar-nav { padding: 12px 8px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-nav);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
  white-space: nowrap;
}
.nav-item i { font-size: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 500; }
.nav-logout { color: #f09595 !important; }
.nav-logout:hover { background: rgba(226,75,74,0.15) !important; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 10px 4px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 350;
}
.sidebar-overlay.open { display: block; }

/* ============================================================
   MAIN WRAPPER
   ============================================================ */
.main-wrapper {
  padding-top: var(--topnav-h);
  min-height: 100vh;
  width: 100%;
  box-sizing: border-box;
}

.main-content {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ============================================================
   AUTH
   ============================================================ */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}

.auth-logo { text-align: center; margin-bottom: 1.75rem; }
.auth-logo-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(55,138,221,0.12);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  font-size: 24px; color: var(--accent);
}
.auth-logo h1 { font-size: 18px; font-weight: 600; }
.auth-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title i { font-size: 18px; color: var(--accent); }

/* ============================================================
   METRIC CARDS
   ============================================================ */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--bg-metric);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
}
.metric-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.metric-value { font-size: 22px; font-weight: 600; color: var(--text); line-height: 1.2; }
.metric-sub { font-size: 12px; margin-top: 4px; color: var(--text-hint); }
.metric-pos { color: var(--success) !important; }
.metric-neg { color: var(--danger) !important; }

/* ============================================================
   CHART
   ============================================================ */
.chart-container { position: relative; width: 100%; height: 300px; }
.chart-sm { height: 220px; }
.chart-lg { height: 380px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

input[type=text], input[type=number], input[type=password],
input[type=email], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(55,138,221,0.15);
}
textarea { resize: vertical; min-height: 80px; }

.input-icon-wrap { position: relative; }
.input-icon-wrap i {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 17px; color: var(--text-hint);
}
.input-icon-wrap input { padding-left: 36px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-md);
  background: var(--bg-card);
  color: var(--text);
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-metric); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-sm  { padding: 5px 11px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: rgba(29,158,117,0.12); color: #0f6e56; border: 1px solid rgba(29,158,117,0.25); }
.alert-danger  { background: rgba(226,75,74,0.12);  color: #a32d2d; border: 1px solid rgba(226,75,74,0.25); }
.alert-info    { background: rgba(55,138,221,0.12);  color: #185fa5; border: 1px solid rgba(55,138,221,0.25); }
.alert-warning { background: rgba(186,117,23,0.12); color: #854f0b; border: 1px solid rgba(186,117,23,0.25); }

[data-theme="dark"] .alert-success { color: #5dcaa5; }
[data-theme="dark"] .alert-danger  { color: #f09595; }
[data-theme="dark"] .alert-info    { color: #85b7eb; }
[data-theme="dark"] .alert-warning { color: #ef9f27; }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left; padding: 10px 14px;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-metric);
  white-space: nowrap;
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-metric); }
.data-table input[type=number] { padding: 6px 8px; font-size: 13px; border-radius: 6px; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
}
.badge-blue   { background: rgba(55,138,221,0.12); color: #185fa5; }
.badge-green  { background: rgba(29,158,117,0.12); color: #0f6e56; }
.badge-orange { background: rgba(216,90,48,0.12);  color: #993c1d; }
.badge-red    { background: rgba(226,75,74,0.12);  color: #a32d2d; }
.badge-amber  { background: rgba(186,117,23,0.12); color: #854f0b; }

[data-theme="dark"] .badge-blue   { color: #85b7eb; }
[data-theme="dark"] .badge-green  { color: #5dcaa5; }
[data-theme="dark"] .badge-orange { color: #f0997b; }
[data-theme="dark"] .badge-red    { color: #f09595; }
[data-theme="dark"] .badge-amber  { color: #ef9f27; }

/* ============================================================
   RANK BAR
   ============================================================ */
.rank-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.rank-row:last-child { border-bottom: none; }
.rank-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.rank-name { width: 90px; flex-shrink: 0; color: var(--text); }
.rank-bar-wrap { flex: 1; background: var(--bg-metric); border-radius: 4px; height: 8px; overflow: hidden; }
.rank-bar { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.rank-val { width: 110px; text-align: right; flex-shrink: 0; color: var(--text-muted); }

/* ============================================================
   MISC
   ============================================================ */
.toko-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.page-header h2 { font-size: 20px; font-weight: 600; color: var(--text); }

.row { display: flex; gap: 20px; flex-wrap: wrap; }
.col { flex: 1; min-width: 280px; }
.col-2 { flex: 2; min-width: 320px; }

.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

.plan-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px; margin-bottom: 16px;
  border-left: 4px solid var(--accent);
}
.plan-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 12px; }
.plan-section { background: var(--bg-metric); border-radius: var(--radius); padding: 10px 12px; }
.plan-section-label { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 4px; }
.plan-section-body { font-size: 13px; color: var(--text); }
.plan-section-warn .plan-section-label { color: var(--warning); }
.plan-section-warn .plan-section-body { color: var(--warning); }
.plan-section-warn { background: rgba(186,117,23,0.1); }
.plan-section-success .plan-section-label { color: var(--success); }
.plan-section-success .plan-section-body { color: var(--success); }
.plan-section-success { background: rgba(29,158,117,0.1); }

.text-muted  { color: var(--text-muted); }
.text-small  { font-size: 12px; }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.saved-msg { font-size: 12px; color: var(--success); transition: opacity 0.3s; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }
.empty-state i { font-size: 36px; display: block; margin-bottom: 10px; color: var(--text-hint); }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-bar select { width: auto; min-width: 160px; }

/* ============================================================
   RESPONSIVE — Mobile (≤ 900px): topnav ciut, sidebar drawer
   ============================================================ */
@media (max-width: 900px) {
  /* Sembunyikan menu horizontal, tampilkan hamburger */
  .topnav-menu  { display: none; }
  .hamburger    { display: flex; }
  .user-name-text { display: none; }

  .main-content { padding: 16px; }
}

@media (max-width: 600px) {
  .metric-grid  { grid-template-columns: repeat(2, 1fr); }
  .metric-value { font-size: 18px; }
  .chart-container { height: 240px; }
  .page-header  { flex-direction: column; align-items: flex-start; }
  .plan-grid    { grid-template-columns: 1fr; }
  .data-table th, .data-table td { padding: 8px 10px; font-size: 13px; }
  .rank-name { width: 70px; }
  .rank-val  { width: 90px; font-size: 12px; }
  .topnav-logo span { display: none; }
}

/* ============================================================
   ANDROID TV / LARGE SCREEN (≥ 1600px)
   ============================================================ */
@media (min-width: 1600px) {
  html { font-size: 16px; }
  .main-content { padding: 32px 40px; }
  .metric-grid  { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .topnav-item  { padding: 8px 14px; font-size: 14px; }
  .topnav-logo  { font-size: 16px; margin-right: 16px; }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-hint); }

/* Print */
@media print {
  .topnav, .sidebar { display: none !important; }
  .main-wrapper { padding-top: 0 !important; }
}
