/* ========================================================
   KAIZREN ENGINE — SENIOR UI/UX DESIGN SYSTEM
   Inspired by Linear, Raycast, & Stripe
   Precision Typography • Calibrated Contrast • Functional Luxury
   ======================================================== */

:root {
  /* Surface Palettes */
  --bg-app: #090a0f;
  --bg-surface: #11141d;
  --bg-surface-hover: #171c28;
  --bg-surface-elevated: #1a202e;
  --bg-input: #0e121a;

  /* Borders */
  --border-subtle: #1e2433;
  --border-muted: #283145;
  --border-focus: #3b82f6;

  /* Typography */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-faint: #475569;

  /* Accent Brands */
  --emerald: #10b981;
  --emerald-subtle: rgba(16, 185, 129, 0.1);
  --emerald-border: rgba(16, 185, 129, 0.25);

  --indigo: #3b82f6;
  --indigo-subtle: rgba(59, 130, 246, 0.1);
  --indigo-border: rgba(59, 130, 246, 0.25);

  --amber: #f59e0b;
  --amber-subtle: rgba(245, 158, 11, 0.1);
  --amber-border: rgba(245, 158, 11, 0.25);

  --rose: #f43f5e;
  --rose-subtle: rgba(244, 63, 94, 0.1);

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ========================================================
   Shell Architecture
   ======================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: 250px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  margin-bottom: 24px;
}
.brand-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #2563eb, #10b981);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 0.95rem;
}
.brand-meta {
  display: flex;
  flex-direction: column;
}
.brand-meta h2 {
  font-size: 0.92rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
}
.brand-meta span {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

/* Navigation */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.15s;
}
.nav-link:hover {
  background: var(--bg-surface-hover);
  color: #fff;
}
.nav-link.active {
  background: var(--bg-surface-elevated);
  color: #fff;
  font-weight: 700;
}
.nav-badge {
  margin-left: auto;
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.nav-link.active .nav-badge {
  background: var(--indigo);
  color: #fff;
}

.sidebar-status-card {
  margin-top: auto;
  padding: 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}
.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--emerald);
  margin-bottom: 4px;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 6px var(--emerald);
}
.status-desc {
  color: var(--text-muted);
  font-size: 0.7rem;
}

/* ========================================================
   Main Canvas & Header
   ======================================================== */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

.top-control-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-lead h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #fff;
}
.header-lead p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.domain-badge-active {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--emerald-subtle);
  border: 1px solid var(--emerald-border);
  color: #34d399;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}
.btn-action-primary {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-action-primary:hover {
  background: #1d4ed8;
}

/* ========================================================
   KPI Ribbon (Linear/Stripe Style)
   ======================================================== */
.kpi-ribbon {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(17, 20, 29, 0.6);
}
.kpi-item {
  flex: 1;
  padding: 14px 28px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}
.kpi-item:last-child { border-right: none; }
.kpi-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 2px;
}
.kpi-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  font-family: var(--font-mono);
}

/* ========================================================
   Filter Toolbar & Category Pills
   ======================================================== */
.workspace-container {
  padding: 24px 28px;
}

.filter-command-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.niche-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.niche-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.niche-pill:hover {
  background: var(--bg-surface-hover);
  color: #fff;
  border-color: var(--border-muted);
}
.niche-pill.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  font-weight: 700;
}

.filter-secondary-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.city-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  outline: none;
}
.city-select:focus { border-color: var(--border-focus); }

.search-box-wrap {
  position: relative;
  width: 240px;
}
.search-box-wrap input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 7px 12px 7px 32px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  outline: none;
}
.search-box-wrap input:focus { border-color: var(--border-focus); }
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ========================================================
   Data Table (Linear / Attio Table Mode)
   ======================================================== */
.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.data-table th {
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.data-table tr:hover td {
  background: var(--bg-surface-hover);
}

.store-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}
.store-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}
.store-avatar.cafe { background: #78350f; }
.store-avatar.apotek { background: #003366; }
.store-avatar.resto { background: #881337; }
.store-avatar.klinik { background: #0f766e; }
.store-avatar.default { background: #334155; }

.store-info strong {
  display: block;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
}
.store-info small {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.dot-wa {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--emerald);
}

.opp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.7rem;
  font-weight: 700;
}
.opp-badge.none {
  background: var(--rose-subtle);
  color: #fb7185;
}
.opp-badge.social {
  background: var(--amber-subtle);
  color: #fcd34d;
}
.opp-badge.custom {
  background: var(--emerald-subtle);
  color: #6ee7b7;
}

.action-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-table-action {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}
.btn-table-action:hover {
  background: var(--border-subtle);
  color: #fff;
}
.btn-table-action.primary {
  background: var(--emerald-subtle);
  border-color: var(--emerald-border);
  color: #34d399;
}
.btn-table-action.primary:hover {
  background: var(--emerald);
  color: #fff;
}

/* ========================================================
   Slide-Over Inspection Panel (Right Drawer)
   ======================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 998;
  display: none;
}
.drawer-backdrop.active { display: block; }

.side-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 520px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  z-index: 999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -10px 0 40px rgba(0,0,0,0.5);
}
.side-drawer.active {
  transform: translateX(0);
}

.drawer-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-header h3 {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
}
.btn-close-drawer {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.drawer-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.drawer-section {
  margin-bottom: 24px;
}
.drawer-section h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 10px;
}

.drawer-pitch-box textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.82rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 180px;
  outline: none;
}
.drawer-pitch-box textarea:focus { border-color: var(--border-focus); }

.tone-chips {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.tone-chip {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  cursor: pointer;
}
.tone-chip.active {
  background: var(--indigo);
  color: #fff;
  border-color: var(--indigo);
}

.drawer-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ========================================================
   Responsive
   ======================================================== */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .app-sidebar { width: 100%; height: auto; position: static; }
  .side-drawer { width: 100%; }
  .kpi-ribbon { flex-direction: column; }
  .kpi-item { border-right: none; border-bottom: 1px solid var(--border-subtle); }
}

/* ========================================================
   Additional Utility Rules
   ======================================================== */
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

.btn-refresh {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-refresh:hover {
  background: var(--border-subtle);
  color: #fff;
  border-color: var(--border-muted);
}

.btn-action-secondary {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.btn-action-secondary:hover {
  background: var(--border-subtle);
  border-color: var(--border-muted);
}
