/* Inward — Brand OS Design System
   Paleta derivada del mockup_IDE.png (dark + lima)
   Compartido por todos los mockups. Refactor robusto v2. */

:root {
  --lime: #C8E04A;
  --lime-bright: #D4EB55;
  --lime-soft: rgba(200, 224, 74, 0.15);
  --lime-glow: rgba(200, 224, 74, 0.08);
  --lime-border: rgba(200, 224, 74, 0.35);

  --cyan: #5EE3FF;
  --cyan-soft: rgba(94, 227, 255, 0.12);
  --magenta: #FF6BB5;
  --magenta-soft: rgba(255, 107, 181, 0.12);
  --warning: #FFB547;
  --warning-soft: rgba(255, 181, 71, 0.12);
  --error: #FF5F57;
  --error-soft: rgba(255, 95, 87, 0.12);
  --success: #28C840;
  --success-soft: rgba(40, 200, 64, 0.12);

  --bg: #0A0A0B;
  --bg-elevated: #141416;
  --bg-elevated-2: #1C1C1F;
  --bg-input: #1F1F23;
  --sidebar-bg: #0F0F11;
  --topbar-bg: #141416;

  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #F5F5F7;
  --text-soft: #A0A0A8;
  --text-muted: #6B6B73;

  --wm-blue: #4A8FFF;

  --sidebar-w: 240px;
}

/* ---------- Reset ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
/* Default flex/grid items to min-width:0 so long content can't blow out tracks.
   IMPORTANT: this rule MUST NOT apply to the shell (.app, .sidebar, .main) —
   if it does, the fixed-width sidebar collapses and the layout breaks (the
   sidebar visually stacks on top of main). Those three are excluded below. */
*, *::before, *::after { min-width: 0; }
.app, .sidebar, .main { min-width: auto; }
html, body {
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  /* IMPORTANT: body is a normal block. Each page either uses .app (full-shell)
     or its own grid/flex layout. NEVER make body a flex container — it caused
     a regression where .app shrank to content width. */
}
button, input, select, textarea { font-family: inherit; color: inherit; }
img, svg, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
code { font-family: 'JetBrains Mono', monospace; font-size: 0.9em; background: var(--bg-input); padding: 1px 6px; border-radius: 4px; color: var(--lime); }

/* ---------- App shell (sidebar + main) ----------
   The shell is a single flex row that ALWAYS fills the viewport horizontally.
   Sidebar is fixed-width; main fills the rest and never overflows. */
.app {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  min-height: 100vh;
}

/* SIDEBAR — fixed 240px track that CANNOT shrink or collapse.
   We force min-width AND max-width AND flex-basis to the sidebar width so no
   universal min-width:0 rule can ever flatten this track. */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  min-height: 100vh;
  box-sizing: border-box;
}
.sb-brand {
  padding: 6px 10px 14px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sb-brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--lime); color: var(--bg);
  display: grid; place-items: center;
  font-weight: 900; font-size: 14px;
  flex-shrink: 0;
}
.sb-brand-name { font-weight: 700; font-size: 15px; }
.sb-newchat {
  background: var(--lime); color: var(--bg);
  font-weight: 700; padding: 9px 12px; border-radius: 8px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; margin-bottom: 14px;
  cursor: pointer; border: none; width: 100%; justify-content: flex-start;
}
.sb-newchat svg { width: 14px; height: 14px; }
.sb-section {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-muted); padding: 10px 10px 4px;
}
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px;
  font-size: 13px; color: var(--text-soft);
  cursor: pointer;
}
.sb-item:hover { background: var(--bg-elevated-2); color: var(--text); }
.sb-item.active { background: var(--lime-soft); color: var(--lime); }
.sb-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.sb-item-count { margin-left: auto; font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.sb-divider { height: 1px; background: var(--border); margin: 12px 8px; }
.sb-plan {
  margin-top: auto;
  padding: 10px; background: var(--bg-elevated-2);
  border-radius: 8px;
}
.sb-plan-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.sb-plan-value { font-size: 13px; font-weight: 700; color: var(--lime); margin-top: 2px; }
.sb-footer-actions { display: flex; gap: 4px; margin-top: 8px; }
.sb-footer-actions .sb-item { padding: 6px 10px; font-size: 12px; }

/* MAIN — fills remaining horizontal space, organizes topbar + canvas + footer vertically */
.main {
  flex: 1 1 0;
  min-width: 0;          /* critical so children with long text don't blow it out */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  background: var(--topbar-bg);
}
.crumb {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-muted);
}
.crumb b { color: var(--text); font-weight: 600; }

.brand-tabs { display: flex; gap: 4px; margin-left: 8px; flex-wrap: wrap; }
.brand-tab {
  padding: 5px 12px; font-size: 12px; border-radius: 6px;
  color: var(--text-soft); cursor: pointer;
  white-space: nowrap;
}
.brand-tab.active {
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border-strong);
}
.brand-tab:hover:not(.active) { background: var(--bg-elevated-2); color: var(--text); }

.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; background: var(--bg-elevated-2); border-radius: 100px; }
.user-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--magenta); color: var(--bg); display: grid; place-items: center; font-weight: 800; font-size: 12px; flex-shrink: 0; }
.user-name { font-size: 12px; font-weight: 600; white-space: nowrap; }

/* CANVAS — scrollable content. Vertical scroll only; never horizontal. */
.canvas {
  flex: 1 1 auto;
  min-height: 0;
  padding: 32px 40px;
  overflow-y: auto;
  overflow-x: hidden;
}
.canvas-narrow { max-width: 880px; margin: 0 auto; }

/* Buttons */
.btn { padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all 0.15s; text-decoration: none; white-space: nowrap; }
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--lime); color: var(--bg); }
.btn-primary:hover { background: var(--lime-bright); }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--bg-elevated-2); }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { color: var(--text); background: var(--bg-elevated-2); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 22px; font-size: 14px; }
.btn-danger { background: var(--error-soft); color: var(--error); border: 1px solid rgba(255,95,87,0.3); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; white-space: nowrap; }
.badge-lime { background: var(--lime-soft); color: var(--lime); border: 1px solid var(--lime-border); }
.badge-cyan { background: var(--cyan-soft); color: var(--cyan); border: 1px solid rgba(94,227,255,0.3); }
.badge-warn { background: var(--warning-soft); color: var(--warning); border: 1px solid rgba(255,181,71,0.3); }
.badge-magenta { background: var(--magenta-soft); color: var(--magenta); border: 1px solid rgba(255,107,181,0.3); }
.badge-muted { background: var(--bg-input); color: var(--text-soft); border: 1px solid var(--border); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Form */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.field input, .field textarea, .field select {
  background: var(--bg-input); border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 9px 12px; color: var(--text);
  font-size: 13px; outline: none; font-family: inherit; width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--lime); }
.field textarea { resize: vertical; min-height: 80px; }
.field-help { font-size: 11px; color: var(--text-muted); }

/* Cards */
.card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.card-desc { font-size: 13px; color: var(--text-soft); }
.card-section-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 10px; }

/* Page header */
.page-h { margin-bottom: 24px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-h-l { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 320px; }
.page-h h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.3px; }
.page-h p { font-size: 13px; color: var(--text-soft); max-width: 640px; }
.page-h-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; padding: 16px; min-width: 0; }
.kpi-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -0.5px; }
.kpi-trend { font-size: 11px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--error); }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-weight: 600; }
.table td { font-size: 13px; padding: 14px; border-bottom: 1px solid var(--border); }
.table tr:hover td { background: var(--bg-elevated-2); }

/* Watermark / footer */
.wm-footer { padding: 12px 24px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 11px; color: var(--text-muted); background: var(--bg); flex-wrap: wrap; }
.wm { display: flex; align-items: center; gap: 8px; }
.wm-mark { width: 18px; height: 18px; border-radius: 50%; background: var(--wm-blue); color: white; display: grid; place-items: center; font-weight: 800; font-size: 9px; flex-shrink: 0; }

/* Generic icon */
.ico { width: 16px; height: 16px; flex-shrink: 0; }
.ico-lg { width: 24px; height: 24px; }
.ico-xl { width: 40px; height: 40px; }

/* Conversational onboarding (chat bubbles) */
.chat-wrap { display: flex; flex-direction: column; gap: 14px; max-width: 720px; margin: 0 auto; }
.bubble { padding: 14px 18px; border-radius: 14px; max-width: 80%; font-size: 14px; line-height: 1.55; }
.bubble-bot { background: var(--bg-elevated); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble-user { background: var(--lime); color: var(--bg); align-self: flex-end; border-bottom-right-radius: 4px; font-weight: 500; }
.bubble-system { background: transparent; border: 1px dashed var(--border-strong); align-self: center; max-width: 60%; text-align: center; font-size: 12px; color: var(--text-muted); }

/* Prompt input box (reusable) */
.prompt-box { background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.prompt-box:focus-within { border-color: var(--lime); }
.prompt-input-text { color: var(--text); font-size: 14px; outline: none; border: none; background: transparent; width: 100%; font-family: inherit; resize: none; min-height: 24px; }
.prompt-input-text::placeholder { color: var(--text-muted); }
.prompt-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prompt-chip { background: var(--bg-elevated-2); border: 1px solid var(--border); border-radius: 7px; padding: 5px 10px; font-size: 11px; color: var(--text-soft); display: inline-flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }
.prompt-chip:hover { background: var(--bg-elevated); color: var(--text); }
.prompt-chip svg { width: 12px; height: 12px; }
.prompt-send { margin-left: auto; width: 32px; height: 32px; border-radius: 50%; background: var(--lime); display: grid; place-items: center; color: var(--bg); border: none; cursor: pointer; flex-shrink: 0; }
.prompt-send svg { width: 14px; height: 14px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: grid; place-items: center; z-index: 100; }
.modal { background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 14px; padding: 28px; max-width: 480px; width: 90%; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.modal-desc { font-size: 13px; color: var(--text-soft); margin-bottom: 20px; }

/* Layout helpers */
.row { display: flex; gap: 12px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--border); width: 100%; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-24 { margin-top: 24px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

/* Standalone page (no sidebar) */
.standalone { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 40px 24px; width: 100%; }
.standalone-inner { max-width: 480px; width: 100%; }
.standalone-header { text-align: center; margin-bottom: 32px; }
.standalone-logo { width: 56px; height: 56px; border-radius: 13px; background: var(--lime); color: var(--bg); display: inline-grid; place-items: center; font-weight: 900; font-size: 28px; margin-bottom: 16px; }
.standalone-title { font-size: 24px; font-weight: 700; letter-spacing: -0.3px; }
.standalone-sub { font-size: 13px; color: var(--text-soft); margin-top: 6px; }

/* ---------- Responsive (desktop-only mockups) ----------
   Mockups son para presentación a cliente en proyector / pantalla grande.
   NO cambiamos a column en viewports angostos — eso causaba que el sidebar
   apareciera encima del main cuando la ventana del navegador era estrecha.
   Solo encogemos un poco el sidebar y los grids. Siempre row, siempre. */
@media (max-width: 1200px) {
  :root { --sidebar-w: 220px; }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
  .canvas { padding: 24px 24px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  :root { --sidebar-w: 180px; }
  .canvas { padding: 20px 16px; }
  .topbar { padding: 10px 16px; }
  .sb-section, .sb-item, .sb-newchat { font-size: 12px; }
}

/* Force row layout in all viewports — defensive against any future regression. */
.app { flex-direction: row !important; }
.sidebar { flex-shrink: 0 !important; }
