/* hiza.app — Multi-Theme + Dark/Light Mode + shadcn/ui Design System */
.hiza-logo-dark { display: none; }
.hiza-logo-light { display: inline-block; }
[data-mode="dark"] .hiza-logo-light { display: none; }
[data-mode="dark"] .hiza-logo-dark { display: inline-block; }

:root,
[data-theme="teal"] {
  --background: #f5f8f8;
  --sidebar: #ebf1f1;
  --card: #ffffff;
  --border: #d8e3e3;
  --input: #cfe0e0;
  --foreground: #0f2224;
  --muted: #eef4f4;
  --muted-foreground: #526c6f;
  --primary: #0f766e;
  --primary-hover: #0d655e;
  --primary-foreground: #ffffff;
  --secondary: #e6efef;
  --secondary-foreground: #0f2224;
  --ring: rgba(15, 118, 110, 0.25);
  --table-head: rgba(235, 241, 241, 0.55);
  --table-hover: rgba(235, 241, 241, 0.45);
}

/* Theme 2: Ocean Blue */
[data-theme="ocean"] {
  --background: #f4f7fb;
  --sidebar: #eaf0f8;
  --card: #ffffff;
  --border: #d5e0ee;
  --input: #c8d7ea;
  --foreground: #0c1d33;
  --muted: #edf2f9;
  --muted-foreground: #4b6382;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-foreground: #ffffff;
  --secondary: #e3ecf7;
  --secondary-foreground: #0c1d33;
  --ring: rgba(2, 132, 199, 0.25);
  --table-head: rgba(227, 236, 247, 0.6);
  --table-hover: rgba(227, 236, 247, 0.45);
}

/* Theme 3: Royal Cobalt */
[data-theme="cobalt"] {
  --background: #f6f7fb;
  --sidebar: #ecedf6;
  --card: #ffffff;
  --border: #dadfee;
  --input: #cfd6ea;
  --foreground: #111827;
  --muted: #eef0f8;
  --muted-foreground: #4b5563;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-foreground: #ffffff;
  --secondary: #e5e9f5;
  --secondary-foreground: #111827;
  --ring: rgba(37, 99, 235, 0.25);
  --table-head: rgba(229, 233, 245, 0.6);
  --table-hover: rgba(229, 233, 245, 0.45);
}

/* Theme 4: Slate Graphite */
[data-theme="graphite"] {
  --background: #f6f7f8;
  --sidebar: #eceef1;
  --card: #ffffff;
  --border: #dcdfe4;
  --input: #d0d5dd;
  --foreground: #111827;
  --muted: #f0f2f5;
  --muted-foreground: #525866;
  --primary: #334155;
  --primary-hover: #1e293b;
  --primary-foreground: #ffffff;
  --secondary: #e6e8ec;
  --secondary-foreground: #111827;
  --ring: rgba(51, 65, 85, 0.22);
  --table-head: rgba(230, 232, 236, 0.6);
  --table-hover: rgba(230, 232, 236, 0.45);
}

/* Theme 5: Warm Terracotta / Copper */
[data-theme="copper"] {
  --background: #faf7f5;
  --sidebar: #f3ece7;
  --card: #ffffff;
  --border: #e6dad1;
  --input: #dccbc0;
  --foreground: #271711;
  --muted: #f5efe9;
  --muted-foreground: #6e564b;
  --primary: #c2410c;
  --primary-hover: #9a3412;
  --primary-foreground: #ffffff;
  --secondary: #efe5dd;
  --secondary-foreground: #271711;
  --ring: rgba(194, 65, 12, 0.25);
  --table-head: rgba(239, 229, 221, 0.6);
  --table-hover: rgba(239, 229, 221, 0.45);
}

/* ================= DARK MODE OVERRIDES ================= */
[data-mode="dark"] {
  --background: #0b1315;
  --sidebar: #0e181b;
  --card: #121f23;
  --border: #1f3339;
  --input: #243b42;
  --foreground: #e6f1f2;
  --muted: #16262b;
  --muted-foreground: #8ba5aa;
  --secondary: #192b30;
  --secondary-foreground: #e6f1f2;
  --table-head: rgba(25, 43, 48, 0.75);
  --table-hover: rgba(25, 43, 48, 0.55);

  --ok-bg: rgba(16, 185, 129, 0.2);
  --ok-fg: #6ee7b7;
  --warn-bg: rgba(245, 158, 11, 0.22);
  --warn-fg: #fcd34d;
  --bad-bg: rgba(239, 68, 68, 0.22);
  --bad-fg: #fca5a5;
  --info-bg: rgba(14, 165, 233, 0.22);
  --info-fg: #7dd3fc;
  --idle-bg: rgba(148, 163, 184, 0.18);
  --idle-fg: #cbd5e1;
}
[data-mode="dark"][data-theme="teal"] {
  --primary: #14b8a6;
  --primary-hover: #0d9488;
  --primary-foreground: #042f2e;
}
[data-mode="dark"][data-theme="ocean"] {
  --background: #0b121e;
  --sidebar: #0e1726;
  --card: #131e31;
  --border: #1e2f4a;
  --secondary: #192740;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-foreground: #082f49;
}
[data-mode="dark"][data-theme="cobalt"] {
  --background: #0b0f19;
  --sidebar: #0f1422;
  --card: #141b2d;
  --border: #222d47;
  --secondary: #1b243b;
  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --primary-foreground: #0f172a;
}
[data-mode="dark"][data-theme="graphite"] {
  --background: #0c0d10;
  --sidebar: #111318;
  --card: #161920;
  --border: #262b36;
  --secondary: #1e222b;
  --primary: #94a3b8;
  --primary-hover: #cbd5e1;
  --primary-foreground: #0f172a;
}
[data-mode="dark"][data-theme="copper"] {
  --background: #140f0d;
  --sidebar: #1b1411;
  --card: #231a16;
  --border: #382923;
  --secondary: #2d211c;
  --primary: #fb923c;
  --primary-hover: #f97316;
  --primary-foreground: #271105;
}

/* Harmonize common Tailwind utility classes in Dark Mode */
[data-mode="dark"] .text-teal-700,
[data-mode="dark"] .text-teal-800 { color: #2dd4bf !important; }
[data-mode="dark"] .text-amber-700,
[data-mode="dark"] .text-amber-800,
[data-mode="dark"] .text-amber-900 { color: #fbbf24 !important; }
[data-mode="dark"] .text-rose-700,
[data-mode="dark"] .text-rose-800,
[data-mode="dark"] .text-red-700,
[data-mode="dark"] .text-red-800 { color: #f87171 !important; }
[data-mode="dark"] .text-sky-700 { color: #38bdf8 !important; }
[data-mode="dark"] .bg-white { background-color: var(--card) !important; }
[data-mode="dark"] .bg-amber-50\/35,
[data-mode="dark"] .bg-amber-50\/30,
[data-mode="dark"] .bg-teal-50\/40 { background-color: rgba(255, 255, 255, 0.03) !important; }

:root {
  /* Default Light Mode Status tokens per docs/ui-fields.md */
  --ok-bg: rgba(16, 185, 129, 0.14);
  --ok-fg: #065f46;
  --ok-dot: #10b981;

  --warn-bg: rgba(245, 158, 11, 0.16);
  --warn-fg: #92400e;
  --warn-dot: #f59e0b;

  --bad-bg: rgba(239, 68, 68, 0.14);
  --bad-fg: #991b1b;
  --bad-dot: #ef4444;

  --info-bg: rgba(14, 165, 233, 0.14);
  --info-fg: #075985;
  --info-dot: #0ea5e9;

  --idle-bg: rgba(100, 116, 139, 0.14);
  --idle-fg: #475569;
  --idle-dot: #94a3b8;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* shadcn/ui primitives */
.sh-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px 0 rgba(15, 34, 36, 0.04);
}

.sh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 600;
  padding: 0.5rem 0.875rem;
  border-radius: 0.5rem;
  transition: all 140ms ease;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
}
.sh-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.sh-btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  border-radius: 0.375rem;
}
.sh-btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.sh-btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}
.sh-btn-secondary {
  background: var(--card);
  color: var(--foreground);
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(15, 34, 36, 0.03);
}
.sh-btn-secondary:hover:not(:disabled) {
  background: var(--secondary);
}
.sh-btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
}
.sh-btn-ghost:hover:not(:disabled) {
  background: var(--secondary);
  color: var(--foreground);
}
.sh-btn-danger {
  background: #dc2626;
  color: #ffffff;
}
.sh-btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.sh-input, .sh-select, .sh-textarea {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.75rem;
  color: var(--foreground);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.sh-input:focus, .sh-select:focus, .sh-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

/* Status Badges (ok / warn / bad / info / idle) */
.sh-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  white-space: nowrap;
}
.sh-badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.sh-badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.sh-badge-bad { background: var(--bad-bg); color: var(--bad-fg); }
.sh-badge-info { background: var(--info-bg); color: var(--info-fg); }
.sh-badge-idle { background: var(--idle-bg); color: var(--idle-fg); }

/*
 * Compact Multi-Color Flag-Accented 2-Letter Country Badges (BR, MX, CL, CO, AR, UY)
 * Reduced height, deep forest green for MX, vivid red for CL, golden-lime for BR.
 */
.site-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.04rem 0.42rem 0.04rem 0.62rem;
  font-size: 0.68rem;
  line-height: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  border-radius: 0.3rem;
  background: var(--secondary);
  color: var(--foreground);
  border: 1px solid rgba(15, 34, 36, 0.12);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
}
.site-pill::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

/* BR · Brazil — Yellow-Green-Blue flag bar + warm golden-lime tint */
.site-pill.site-BR, .site-pill[data-site="BR"] {
  background: linear-gradient(135deg, #fef08acc 0%, #bbf7d0cc 100%);
  color: #14532d;
  border-color: #84cc1699;
}
.site-pill.site-BR::before, .site-pill[data-site="BR"]::before {
  background: linear-gradient(180deg, #009c3b 0%, #009c3b 35%, #ffdf00 35%, #ffdf00 70%, #002776 70%, #002776 100%);
}

/* MX · Mexico — Deep Forest Green (#006847) surface + Green/White/Red flag bar */
.site-pill.site-MX, .site-pill[data-site="MX"] {
  background: linear-gradient(135deg, #a7f3d0aa 0%, #6ee7b799 100%);
  color: #064e3b;
  border-color: #04785777;
}
.site-pill.site-MX::before, .site-pill[data-site="MX"]::before {
  background: linear-gradient(180deg, #006847 0%, #006847 34%, #ffffff 34%, #ffffff 66%, #ce1126 66%, #ce1126 100%);
}

/* CL · Chile — Vivid Red (#D52B1E) surface + Blue/White/Red flag bar */
.site-pill.site-CL, .site-pill[data-site="CL"] {
  background: linear-gradient(135deg, #fecacacc 0%, #fca5a5cc 100%);
  color: #991b1b;
  border-color: #dc262680;
}
.site-pill.site-CL::before, .site-pill[data-site="CL"]::before {
  background: linear-gradient(180deg, #0039a6 0%, #0039a6 30%, #ffffff 30%, #ffffff 45%, #d52b1e 45%, #d52b1e 100%);
}

/* CO · Colombia — Amarillo + Azul + Rojo */
.site-pill.site-CO, .site-pill[data-site="CO"] {
  background: linear-gradient(135deg, #fef08add 0%, #fde68acc 100%);
  color: #78350f;
  border-color: #f59e0b88;
}
.site-pill.site-CO::before, .site-pill[data-site="CO"]::before {
  background: linear-gradient(180deg, #fcd116 0%, #fcd116 50%, #003893 50%, #003893 75%, #ce1126 75%, #ce1126 100%);
}

/* AR · Argentina — Celeste + Blanco + Sol de Mayo */
.site-pill.site-AR, .site-pill[data-site="AR"] {
  background: linear-gradient(135deg, #e0f2fedd 0%, #bae6fdcc 100%);
  color: #075985;
  border-color: #38bdf888;
}
.site-pill.site-AR::before, .site-pill[data-site="AR"]::before {
  background: linear-gradient(180deg, #38bdf8 0%, #38bdf8 35%, #f6b40e 35%, #f6b40e 65%, #38bdf8 65%, #38bdf8 100%);
}

/* UY · Uruguay — Azul Real + Blanco + Sol */
.site-pill.site-UY, .site-pill[data-site="UY"] {
  background: linear-gradient(135deg, #e0e7ffdd 0%, #c7d2fecc 100%);
  color: #1e3a8a;
  border-color: #6366f180;
}
.site-pill.site-UY::before, .site-pill[data-site="UY"]::before {
  background: linear-gradient(180deg, #eab308 0%, #eab308 30%, #1d4ed8 30%, #1d4ed8 65%, #ffffff 65%, #1d4ed8 100%);
}

/* Two-sided Order Side Badges (BUY on Amazon / SELL on Mercado Libre) */
.o-side {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem 0.42rem;
  border-radius: 0.3rem;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.o-side.buy {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border: 1px solid rgba(245, 158, 11, 0.32);
}
.o-side.sell {
  background: var(--info-bg);
  color: var(--info-fg);
  border: 1px solid rgba(14, 165, 233, 0.3);
}

/* Vertical 3-Dots Action Menu (shadcn/ui DropdownMenu) */
.row-menu {
  position: relative;
  display: inline-flex;
  justify-content: flex-end;
}
.row-menu-btn {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 0.45rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 120ms ease;
}
.row-menu-btn:hover,
.row-menu.open .row-menu-btn {
  background: var(--secondary);
  border-color: var(--border);
  color: var(--foreground);
}
.row-menu-pop {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  min-width: 11.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 0.3rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 4px 10px -4px rgba(0, 0, 0, 0.12);
  z-index: 50;
  text-align: left;
}
.row-menu.open .row-menu-pop {
  display: block;
}
.row-menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.42rem 0.6rem;
  border-radius: 0.4rem;
  border: 0;
  background: transparent;
  color: var(--foreground);
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 100ms ease;
}
.row-menu-item:hover {
  background: var(--secondary);
}
.row-menu-item.danger {
  color: #ef4444;
}
.row-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.12);
}
.row-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* Inline Copy Button */
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 0.25rem;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0;
}
.copy-btn:hover {
  background: var(--secondary);
  color: var(--foreground);
}

/* shadcn Tabs */
.sh-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--secondary);
  padding: 0.25rem;
  border-radius: 0.6rem;
}
.sh-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.35rem 0.7rem;
  border-radius: 0.45rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all 120ms ease;
  border: none;
  background: transparent;
}
.sh-tab:hover {
  color: var(--foreground);
}
.sh-tab.active {
  background: var(--card);
  color: var(--foreground);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 34, 36, 0.08);
}

/* Switch */
.sh-switch {
  position: relative;
  display: inline-flex;
  width: 2.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  background: #cbd5e1;
  transition: background 150ms;
  cursor: pointer;
  border: none;
  padding: 2px;
}
.sh-switch.on {
  background: var(--primary);
}
.sh-switch-thumb {
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  background: #ffffff;
  transition: transform 150ms;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.sh-switch.on .sh-switch-thumb {
  transform: translateX(1rem);
}

/* Table */
.sh-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.sh-table th {
  padding: 0.65rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted-foreground);
  background: var(--table-head);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.sh-table td {
  padding: 0.75rem 0.85rem;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.sh-table tbody tr:hover {
  background: var(--table-hover);
}

/* ================= RESPONSIVE SHELL / COLLAPSIBLE SIDEBAR ================= */
#appSidebar { transition: width 180ms ease, transform 200ms ease; }
#sbBackdrop { display: none; }
#sbMobileBar { display: none; }

@media (min-width: 1024px) {
  #appSidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  body.sb-collapsed #appSidebar { width: 4.25rem !important; padding: 0.875rem 0.5rem !important; }
  body.sb-collapsed #appSidebar .sb-hide { display: none !important; }
  body.sb-collapsed #appSidebar .sb-item { justify-content: center; padding-left: 0; padding-right: 0; }
  body.sb-collapsed #appSidebar > div:first-child > div:first-child > div:first-child {
    flex-direction: column; gap: 0.75rem; padding-left: 0; padding-right: 0;
  }
}

@media (max-width: 1023.98px) {
  #appSidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: 17rem !important; overflow-y: auto;
    transform: translateX(-100%);
  }
  body.sb-open #appSidebar { transform: none; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); }
  body.sb-open #sbBackdrop {
    display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.4);
  }
  body.sb-open { overflow: hidden; }
  .sb-toggle { display: none !important; }

  #sbMobileBar {
    display: flex; align-items: center; gap: 0.75rem;
    position: sticky; top: 0; z-index: 30;
    margin: -1rem -1rem 0; padding: 0.625rem 1rem;
    background: var(--background); border-bottom: 1px solid var(--border);
  }
  #appSidebar ~ main { padding: 1rem !important; width: 100%; }
  #appSidebar ~ main h1 { font-size: 1.25rem; line-height: 1.75rem; }
}
