/* assets/css/style.css */
:root {
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --radius: 10px;
  --radius-lg: 14px;
  --transition: 0.2s ease;

  /* Light theme */
  --bg: #f4f5f7;
  --bg-card: #ffffff;
  --bg-sidebar: #1a1f2e;
  --bg-sidebar-hover: rgba(255,255,255,0.08);
  --bg-sidebar-active: rgba(255,255,255,0.15);
  --bg-topbar: #ffffff;
  --bg-input: #ffffff;
  --bg-metric: #f8f9fb;

  --text: #1a1f2e;
  --text-muted: #6b7280;
  --text-hint: #9ca3af;
  --text-sidebar: rgba(255,255,255,0.75);
  --text-sidebar-active: #ffffff;
  --text-on-accent: #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.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #1a1f2e;
  --bg-sidebar: #0d1117;
  --bg-sidebar-hover: rgba(255,255,255,0.06);
  --bg-sidebar-active: rgba(55,138,221,0.2);
  --bg-topbar: #1a1f2e;
  --bg-input: #252b3b;
  --bg-metric: #252b3b;

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

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

  --shadow: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px 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);
}

/* ---- SIDEBAR ---- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
}

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
}

.sidebar-logo i { font-size: 20px; color: var(--accent); }

.sidebar-close {
  background: none;
  border: none;
  color: var(--text-sidebar);
  cursor: pointer;
  font-size: 18px;
  display: none;
  padding: 4px;
}

.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-sidebar);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}

.nav-item i { font-size: 18px; flex-shrink: 0; }

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}

.nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
  font-weight: 500;
}

.nav-item.active i { color: var(--accent); }

.nav-logout { color: #E24B4A !important; }
.nav-logout:hover { background: rgba(226,75,74,0.12) !important; }

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

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}

/* ---- TOPBAR ---- */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  z-index: 100;
  transition: left var(--transition), background var(--transition);
  box-shadow: var(--shadow);
}

.topbar-menu {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}

.topbar-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.theme-toggle:hover { background: var(--bg-metric); color: var(--text); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

/* ---- MAIN WRAPPER ---- */
.main-wrapper {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.main-content {
  padding: 24px;
  max-width: 1400px;
}

/* ---- 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 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 CONTAINER ---- */
.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); }

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

/* ---- PAGE HEADER ---- */
.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);
}

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

/* ---- LEGEND ---- */
.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;
}

/* ---- PLANNING CARDS ---- */
.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 { background: rgba(186,117,23,0.1); }
.plan-section-warn .plan-section-label { color: var(--warning); }
.plan-section-warn .plan-section-body { color: var(--warning); }
.plan-section-success { background: rgba(29,158,117,0.1); }
.plan-section-success .plan-section-label { color: var(--success); }
.plan-section-success .plan-section-body { color: var(--success); }

/* ---- UTIL ---- */
.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; }
.gap-2 { gap: 8px; }
.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); }

/* ---- SELECT FILTER ---- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.filter-bar select {
  width: auto;
  min-width: 160px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-close { display: flex !important; }

  .sidebar-overlay.open { display: block; }

  .topbar {
    left: 0;
  }

  .topbar-menu { display: flex; }
  .user-name { display: none; }

  .main-wrapper {
    margin-left: 0;
  }

  .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; }
  .topbar-title { font-size: 14px; }
}

/* ---- ANDROID TV / LARGE SCREEN ---- */
@media (min-width: 1600px) {
  :root { --sidebar-w: 260px; }
  .main-content { padding: 32px 40px; }
  html { font-size: 16px; }
  .metric-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

/* ---- 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 {
  .sidebar, .topbar { display: none !important; }
  .main-wrapper { margin-left: 0 !important; padding-top: 0 !important; }
}
