@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;1,14..32,400&family=JetBrains+Mono:wght@400;500&display=swap");

/* ─── Design tokens ─────────────────────────────────────────────── */
:root {
  --bg:             #f0f4f8;
  --surface:        #ffffff;
  --surface-2:      #f6f9fb;
  --surface-3:      #edf1f5;
  --ink:            #0f1f2e;
  --ink-2:          #2d4a5e;
  --muted:          #5a7287;
  --accent:         #0a8c73;
  --accent-h:       #087a65;
  --accent-2:       #0e68a3;
  --accent-2-h:     #0b5990;
  --danger:         #d93636;
  --danger-h:       #b82d2d;
  --border:         #cdd8e0;
  --border-2:       #dde6ec;
  --sidebar-bg:     #0c1a24;
  --sidebar-fg:     #bcd3de;
  --sidebar-hover:  rgba(255,255,255,0.07);
  --sidebar-active: rgba(10,140,115,0.16);
  --sidebar-ab:     #0a8c73;
  --shadow-xs:      0 1px 3px rgba(0,0,0,0.06);
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.07);
  --shadow:         0 6px 20px rgba(0,0,0,0.09);
  --shadow-lg:      0 16px 48px rgba(0,0,0,0.13);
  --r-sm:           6px;
  --r:              10px;
  --r-lg:           14px;
  --t:              0.18s ease;
}

/* ─── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ─── App shell ──────────────────────────────────────────────────── */
.layout-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px 1fr;
}

/* ─── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.brand-badge {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 13px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}

.brand-text h1 { font-size: 15px; font-weight: 700; margin: 0; color: #edf7fb; line-height: 1.2; }
.brand-text p  { font-size: 11px; margin: 2px 0 0; color: #7ca0b0; }

.sidebar-nav {
  display: flex; flex-direction: column; gap: 1px;
  padding: 12px 10px; flex: 1;
}

.sidebar-nav a {
  display: flex; align-items: center; gap: 9px;
  color: var(--sidebar-fg);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500;
  transition: background var(--t), color var(--t);
  border-left: 2px solid transparent;
}

.sidebar-nav a svg {
  width: 15px; height: 15px;
  flex-shrink: 0; opacity: 0.75;
  transition: opacity var(--t);
}

.sidebar-nav a:hover        { background: var(--sidebar-hover); color: #edf7fb; }
.sidebar-nav a:hover svg    { opacity: 1; }
.sidebar-nav a.active       { background: var(--sidebar-active); color: #70e8d4; border-left-color: var(--sidebar-ab); }
.sidebar-nav a.active svg   { opacity: 1; }

.sidebar-footer {
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 11.5px; color: #7ca0b0;
}

/* ─── Main workspace ─────────────────────────────────────────────── */
.workspace {
  display: flex; flex-direction: column; min-height: 100vh;
  overflow-x: hidden;
}

.workspace-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 26px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}

.workspace-header-left h2 { margin: 0; font-size: 19px; font-weight: 700; }
.workspace-header-left p  { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.workspace-body { flex: 1; padding: 22px 26px; }

/* ─── Alerts ─────────────────────────────────────────────────────── */
.alerts { margin-bottom: 14px; }

.alert {
  padding: 11px 15px;
  border-radius: var(--r-sm);
  margin-bottom: 8px;
  font-size: 13.5px; font-weight: 500;
  background: #fff8e6; border: 1px solid #f4d58d; color: #7a5200;
}
.alert-success { background: #e0f5ec; border-color: #9dd9bc; color: #0d5a3d; }
.alert-error,
.alert-danger   { background: #fde8e8; border-color: #f5a9a9; color: #8a1c1c; }
.alert-info     { background: #e0f0ff; border-color: #a3ccee; color: #0d4e7a; }
.alert-warning  { background: #fff4e0; border-color: #f5c87a; color: #7a4500; }

/* ─── Panels ─────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-xs);
}

.panel h3 { margin: 0 0 14px; font-size: 14.5px; font-weight: 700; }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.panel-header h3 { margin: 0; }

.hero-panel {
  background: linear-gradient(118deg, #0b2a3a 0%, #0d7a66 55%, #0e4f7a 100%);
  border-color: transparent;
  color: #eef8fb;
}
.hero-panel h3 { color: #eef8fb; font-size: 17px; }
.hero-panel p  { margin: 5px 0 0; color: rgba(238,248,251,0.78); font-size: 13px; }

/* ─── KPI cards ──────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 14px; margin-bottom: 18px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px 16px;
  box-shadow: var(--shadow-xs);
  position: relative; overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute; inset-block: 0; left: 0;
  width: 3px;
  background: linear-gradient(var(--accent), var(--accent-2));
}

.kpi-card h3       { margin: 0; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-card .kpi-val { margin: 10px 0 0; font-size: 33px; font-weight: 800; color: var(--ink); line-height: 1; }

.kpi-icon {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--bg); display: grid; place-items: center;
  color: var(--accent);
}
.kpi-icon svg { width: 17px; height: 17px; }

/* ─── Two-col layout helper ──────────────────────────────────────── */
.col-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

/* ─── Tables ─────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead tr  { border-bottom: 2px solid var(--border); }
th {
  padding: 9px 12px;
  text-align: left; color: var(--muted);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-2);
  color: var(--ink); vertical-align: middle;
}
tbody tr:last-child td  { border-bottom: none; }
tbody tr:hover          { background: var(--surface-2); }
.td-mono { font-family: "JetBrains Mono", monospace; font-size: 12px; }

/* ─── Forms ──────────────────────────────────────────────────────── */
.form-group       { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }

.form-grid   { display: grid; gap: 14px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="search"],
textarea, select {
  width: 100%; padding: 8px 11px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit; font-size: 13.5px; color: var(--ink);
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10,140,115,0.11);
}
textarea { resize: vertical; min-height: 78px; }

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn, button[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-sm);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--t), transform var(--t);
  width: auto;
}
.btn:hover, button[type="submit"]:hover { background: var(--accent-h); }
.btn:active, button[type="submit"]:active { transform: scale(0.98); }

.btn-secondary { background: var(--surface); color: var(--ink); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--surface-3); }

.btn-danger  { background: var(--danger); }
.btn-danger:hover { background: var(--danger-h); }

.btn-sm    { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-ghost { background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.24); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,0.22); }

/* ─── Status badges ──────────────────────────────────────────────── */
.status-chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  text-transform: capitalize; white-space: nowrap;
}
.status-pending    { background: #fff2c6; color: #7a5b00; }
.status-processing { background: #dceeff; color: #1b4b7a; }
.status-shipped    { background: #dff8ee; color: #0d5a43; }
.status-delivered  { background: #d3f0d9; color: #1d6b29; }
.status-canceled   { background: #ffe1e1; color: #8a2222; }

/* ─── Channel chip ───────────────────────────────────────────────── */
.channel-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600;
}
.channel-whatsapp { background: #d5f4e1; color: #1a6e3a; }
.channel-web      { background: #dceeff; color: #1b4b7a; }

/* ─── Status list (dashboard) ────────────────────────────────────── */
.status-list { display: grid; gap: 7px; padding: 0; list-style: none; margin: 0; }
.status-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
}

/* ─── Inline order-update form ───────────────────────────────────── */
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form select,
.inline-form input  { padding: 5px 7px; font-size: 12px; border-radius: 5px; height: 30px; width: auto; }
.inline-form select { min-width: 110px; }
.inline-form input  { min-width: 112px; }

/* ─── Link button ────────────────────────────────────────────────── */
.link-btn {
  display: inline-flex; align-items: center; gap: 4px;
  text-decoration: none; background: var(--surface-3); color: var(--accent-2);
  padding: 5px 10px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600;
  border: 1px solid var(--border);
  transition: background var(--t);
}
.link-btn:hover { background: #dceeff; border-color: #a3ccee; }

/* ─── Auth pages ─────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #0c1a24 0%, #0f2b3d 50%, #0a2218 100%);
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--surface);
  padding: 36px 38px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.auth-card.wide { width: min(680px, 100%); }

.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-logo-badge {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff;
  font-weight: 800; font-size: 16px; flex-shrink: 0;
}
.auth-logo h1 { font-size: 19px; font-weight: 800; margin: 0; color: var(--ink); }
.auth-logo p  { margin: 0; font-size: 12px; color: var(--muted); }

.auth-card h2           { margin: 0 0 4px; font-size: 21px; font-weight: 700; }
.auth-card .auth-sub    { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.auth-footer            { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--muted); }
.auth-footer a          { color: var(--accent); font-weight: 600; text-decoration: none; }

/* ─── Chat log (retailer view) ───────────────────────────────────── */
.chat-history-panel { min-height: 55vh; }

.chat-log {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 68vh; overflow-y: auto;
  padding: 2px; scroll-behavior: smooth;
}

.chat-bubble {
  padding: 11px 14px;
  border-radius: 12px;
  max-width: 76%;
}
.chat-bubble.customer  {
  align-self: flex-end;
  background: #e6f2fd; border: 1px solid #aed4f7;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--surface-2); border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-bubble header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 5px; gap: 8px;
}
.chat-bubble header strong { font-size: 11.5px; font-weight: 700; color: var(--ink-2); }
.chat-bubble header small  { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.chat-bubble p             { margin: 0; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }

/* ─── Customer-facing chat widget ────────────────────────────────── */
.customer-chat-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0c1a24, #0f2b3d 55%, #0a2218);
  display: grid; place-items: center; padding: 20px;
}

.customer-chat-shell {
  width: min(820px, 100%);
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
  display: flex; flex-direction: column;
}

.customer-chat-header {
  background: linear-gradient(120deg, #0b2a3a, #0d7a66);
  padding: 18px 22px; color: #fff;
}
.customer-chat-header h1 { margin: 0; font-size: 17px; font-weight: 700; }
.customer-chat-header p  { margin: 4px 0 0; font-size: 12.5px; opacity: 0.8; }

.customer-chat-body  { padding: 18px 22px; flex: 1; display: flex; flex-direction: column; gap: 12px; }

.meta-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  padding: 14px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-sm);
}

.chat-log.customer {
  flex: 1; min-height: 340px; max-height: 400px;
  padding: 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r);
}

.chat-input-row { display: flex; gap: 8px; align-items: stretch; }
.chat-input-row input  { flex: 1; border-radius: 8px; }
.chat-input-row button { border-radius: 8px; padding: 8px 18px; width: auto; }

/* Typing indicator */
.typing-indicator {
  display: none;
  align-items: center; gap: 4px;
  padding: 9px 13px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.typing-indicator.visible { display: flex; }

.typing-dot {
  width: 6px; height: 6px;
  background: var(--muted); border-radius: 50%;
  animation: tdBounce 1.3s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes tdBounce {
  0%, 60%, 100% { transform: translateY(0);     opacity: 0.35; }
  30%           { transform: translateY(-5px);  opacity: 1;    }
}

/* Order confirmation banner */
.order-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: #e0f5ec; border: 1px solid #9dd9bc;
  border-radius: var(--r-sm); font-size: 13.5px; color: #0d5a3d;
  font-weight: 600;
}

/* ─── Misc utilities ─────────────────────────────────────────────── */
.muted-note  { color: var(--muted); font-size: 13.5px; }
.text-sm     { font-size: 12.5px; }
.text-muted  { color: var(--muted); }
.flex-between{ display: flex; justify-content: space-between; align-items: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 920px) {
  .layout-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .workspace-header { position: static; }
  .workspace-body { padding: 16px 16px; }
  .col-2 { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form select, .inline-form input { width: 100%; min-width: 0; }
  .meta-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 24px 20px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 540px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .chat-bubble { max-width: 90%; }
  .auth-card, .auth-card.wide { padding: 20px 16px; }
}

/* ─── Sidebar logout link ────────────────────────────────────────── */
.sidebar-nav a.nav-logout {
  margin-top: auto;
  color: #f87171;
  opacity: .75;
}
.sidebar-nav a.nav-logout:hover { background: rgba(248,113,113,.1); color: #f87171; opacity: 1; }

/* ─── Panel head (settings sections) ────────────────────────────── */
.panel-head {
  display: flex; align-items: center; gap: .6rem;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.panel-head svg { color: var(--accent); flex-shrink: 0; }
.panel-head h3 { margin: 0; font-size: 1rem; font-weight: 700; }

/* ─── Settings layout ───────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.5rem;
}
.settings-grid .field-group { display: flex; flex-direction: column; gap: .35rem; }
.settings-grid label { font-size: .8rem; font-weight: 600; color: var(--fg-muted); }
.settings-grid input,
.settings-grid select,
.settings-grid textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--fg);
  padding: .55rem .75rem;
  font-size: .875rem;
  font-family: inherit;
  transition: border-color var(--t), box-shadow var(--t);
}
.settings-grid textarea { resize: vertical; min-height: 140px; line-height: 1.55; }
.settings-grid input:focus,
.settings-grid select:focus,
.settings-grid textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,.15);
}
.settings-grid small { font-size: .75rem; color: var(--fg-muted); }
.settings-grid .req { color: #f87171; }

.settings-callout {
  background: rgba(56,189,248,.06);
  border: 1px solid rgba(56,189,248,.18);
  border-radius: var(--r-sm);
  padding: .65rem .9rem;
  font-size: .8rem;
  color: var(--fg-muted);
  margin-bottom: 1.1rem;
  line-height: 1.55;
}
.settings-callout a { color: var(--accent); text-decoration: underline; }

.settings-info-row {
  display: flex; align-items: center; gap: .4rem;
  margin-top: 1rem; padding-top: .75rem;
  border-top: 1px solid var(--border);
  font-size: .78rem; color: var(--fg-muted);
}
.settings-info-row code {
  background: var(--bg);
  padding: .15rem .4rem;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  color: var(--accent);
  border: 1px solid var(--border);
}

/* ─── Toggle switch ─────────────────────────────────────────────── */
.toggle-label { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle-label input[type=checkbox] { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  display: block; width: 44px; height: 24px;
  background: var(--border); border-radius: 9999px;
  transition: background var(--t);
  position: relative;
}
.toggle-track::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff; border-radius: 50%;
  transition: transform var(--t);
}
.toggle-label input:checked + .toggle-track { background: var(--accent); }
.toggle-label input:checked + .toggle-track::after { transform: translateX(20px); }

/* ─── Ghost button ──────────────────────────────────────────────── */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--fg); }

/* ─── Badge ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-info    { background: #dceeff; color: #1b4b7a; }
.badge-success { background: #d3f0d9; color: #1d6b29; }
.badge-warning { background: #fff2c6; color: #7a5b00; }
.badge-danger  { background: #ffe1e1; color: #8a2222; }

@media (max-width: 920px) {
  .settings-grid { grid-template-columns: 1fr; }
}

