/* ============================================================
   Editor de Informes — chrome de la app (sistema de diseño
   Colombia Fintech). Los tokens viven en colors_and_type.css.
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--fg-default);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#root { height: 100%; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
::selection { background: color-mix(in oklab, var(--cf-mint) 60%, transparent); }

/* ---------- botones base ---------- */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--cf-navy); color: var(--fg-on-dark);
  border: 1px solid var(--cf-navy); border-radius: var(--radius-pill);
  padding: 10px 18px; font-size: 14px; font-weight: 500;
  transition: background var(--dur-base) var(--ease-in-out), transform var(--dur-fast);
}
.btn-primary:hover { background: var(--cf-navy-ink); }
.btn-primary:active { transform: translateY(1px) scale(.99); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--cf-navy);
  border: 1px solid var(--border-default); border-radius: var(--radius-pill);
  padding: 9px 16px; font-size: 14px; font-weight: 500;
  transition: border-color var(--dur-base), background var(--dur-base);
}
.btn-ghost:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
.btn-ghost .caret { font-size: 10px; opacity: .7; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
  height: 100%; display: grid; place-items: center;
  background: var(--cf-navy); position: relative; overflow: hidden;
}
.login-pattern { position: absolute; inset: 0; pointer-events: none; }
.lp-sq { position: absolute; border-radius: 22%; background: var(--cf-mint); }
.lp-sq-0 { width: 420px; height: 420px; top: -8%; right: -6%; opacity: .10; }
.lp-sq-1 { width: 300px; height: 300px; top: 50%; right: 8%; opacity: .07; }
.lp-sq-2 { width: 240px; height: 240px; bottom: -10%; left: 6%; opacity: .09; }
.lp-sq-3 { width: 160px; height: 160px; top: 12%; left: 14%; opacity: .06; }
.lp-sq-4 { width: 200px; height: 200px; bottom: 18%; left: 38%; opacity: .05; }
.login-card {
  position: relative; z-index: 2; width: min(92vw, 480px);
  background: var(--bg-surface); border-radius: var(--radius-xl);
  padding: 48px 44px; box-shadow: var(--shadow-lg);
}
.login-logo { height: 30px; display: block; }
.login-eyebrow { margin: 28px 0 0; }
.login-title { margin: 10px 0 0; }
.login-lede { margin: 16px 0 0; font-size: 16px; }
.google-btn {
  margin-top: 30px; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  background: var(--bg-surface); color: var(--cf-navy);
  border: 1px solid var(--border-default); border-radius: var(--radius-pill);
  padding: 14px 20px; font-size: 15px; font-weight: 500;
  transition: border-color var(--dur-base), box-shadow var(--dur-base);
}
.google-btn:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.google-btn:active { transform: translateY(1px); }
.g-ico { display: inline-flex; }
.login-foot { margin: 22px 0 0; text-align: center; opacity: .6; }

/* ============================================================
   GALERÍA
   ============================================================ */
.gallery { min-height: 100%; display: flex; flex-direction: column; }
.g-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border-subtle);
  background: color-mix(in oklab, var(--bg-canvas) 80%, #fff); position: sticky; top: 0; z-index: 10;
  backdrop-filter: none;
}
.g-brand { display: flex; align-items: center; gap: 12px; }
.g-brand img { height: 22px; }
.g-brand-tag { color: var(--fg-muted); border-left: 1px solid var(--border-default); padding-left: 12px; }
.g-user { display: flex; align-items: center; gap: 14px; }
.g-search { display: flex; align-items: center; gap: 8px; background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-pill); padding: 8px 14px; color: var(--fg-muted); }
.g-search input { border: none; background: transparent; outline: none; font-size: 14px; width: 180px; color: var(--fg-default); }
.g-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--cf-mint);
  display: grid; place-items: center; font-family: var(--font-mono); font-size: 12px; color: var(--cf-navy); }
.g-signout { background: transparent; border: none; color: var(--fg-muted); letter-spacing: .12em; }
.g-signout:hover { color: var(--cf-navy); }

.g-main { width: min(1200px, 92vw); margin: 0 auto; padding: 56px 0 80px; flex: 1; }
.g-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 44px; }
.g-h1 { margin: 8px 0 12px; }
.g-new .plus { font-size: 18px; line-height: 1; margin-right: -2px; }

.g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 28px; }
.proj-card { background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); overflow: hidden; transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base), border-color var(--dur-base); }
.proj-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-default); }
.pc-cover { position: relative; width: 100%; aspect-ratio: 16/10; border: none; text-align: left;
  padding: 22px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; cursor: pointer; }
.pc-shapes { position: absolute; inset: 0; pointer-events: none; }
.pcs { position: absolute; border-radius: 22%; background: currentColor; opacity: .10; }
.pcs-a { width: 150px; height: 150px; top: -30px; right: -20px; }
.pcs-b { width: 90px; height: 90px; bottom: -20px; right: 40px; opacity: .07; }
.pcs-c { width: 60px; height: 60px; top: 40%; right: 30%; opacity: .06; }
.pc-num { position: relative; opacity: .7; }
.pc-cover-title { position: relative; font-family: var(--font-display); font-weight: 500; font-size: 22px;
  line-height: 1.1; letter-spacing: -.01em; margin-top: auto; }
.pc-cover-title em { font-style: italic; }
.pc-edition { position: relative; opacity: .7; margin-top: 4px; }
.pc-body { display: flex; align-items: flex-start; justify-content: space-between; padding: 16px 18px; gap: 10px; }
.pc-title { font-size: 15px; font-weight: 500; margin: 0 0 6px; color: var(--cf-navy); line-height: 1.3; }
.pc-meta { display: flex; align-items: center; gap: 8px; color: var(--fg-muted); }
.pc-theme, .pc-date { font-size: 10px; }
.pc-dot { opacity: .4; }
.pc-actions { position: relative; }
.pc-menu-btn { background: transparent; border: none; color: var(--fg-muted); font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 8px; }
.pc-menu-btn:hover { background: var(--bg-subtle); color: var(--cf-navy); }
.pc-menu { position: absolute; right: 0; top: 26px; z-index: 5; background: var(--bg-surface);
  border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; min-width: 150px; overflow: hidden; }
.pc-menu button { background: transparent; border: none; text-align: left; padding: 10px 14px; font-size: 13px; color: var(--cf-navy); }
.pc-menu button:hover { background: var(--bg-subtle); }
.pc-menu button.danger { color: var(--danger); }
.g-empty { text-align: center; padding: 80px 0; display: flex; flex-direction: column; align-items: center; gap: 20px; }

/* ============================================================
   WORKSPACE
   ============================================================ */
.ws { height: 100%; display: flex; flex-direction: column; background: var(--bg-canvas); }
.ws-top { display: flex; align-items: center; gap: 16px; padding: 10px 18px;
  border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface); z-index: 20; }
.ws-top-l { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.ws-top-c { display: flex; align-items: center; }
.ws-top-r { display: flex; align-items: center; gap: 10px; }
.ws-back { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border-subtle); background: transparent; color: var(--cf-navy); }
.ws-back:hover { background: var(--bg-subtle); border-color: var(--border-default); }
.ws-title { border: 1px solid transparent; background: transparent; font-size: 16px; font-weight: 500;
  color: var(--cf-navy); padding: 6px 10px; border-radius: var(--radius-sm); min-width: 120px; max-width: 360px; outline: none; }
.ws-title:hover { background: var(--bg-subtle); }
.ws-title:focus { border-color: var(--border-default); background: var(--bg-surface); }
.ws-save { color: var(--fg-subtle); font-size: 10px; letter-spacing: .12em; }
.ws-save.saving { color: var(--warning); }

.theme-seg { display: inline-flex; background: var(--bg-subtle); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill); padding: 3px; gap: 2px; }
.seg-btn { border: none; background: transparent; color: var(--fg-muted); font-size: 13px; font-weight: 500;
  padding: 6px 16px; border-radius: var(--radius-pill); transition: all var(--dur-base); }
.seg-btn:hover { color: var(--cf-navy); }
.seg-btn.on { background: var(--cf-navy); color: var(--fg-on-dark); }
.ws-render svg { margin-right: -2px; }

.actions-menu { position: relative; }
.am-pop { position: absolute; right: 0; top: 44px; z-index: 30; background: var(--bg-surface);
  border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; min-width: 250px; overflow: hidden; }
.am-pop button { background: transparent; border: none; text-align: left; padding: 12px 16px; font-size: 13px; color: var(--cf-navy); }
.am-pop button:hover { background: var(--bg-subtle); }

/* ---- cuerpo split ---- */
.ws-body { flex: 1; display: flex; min-height: 0; }
.ws-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ws-left { border-right: none; }
.ws-divider { width: 8px; flex: 0 0 8px; cursor: col-resize; background: transparent; display: grid; place-items: center; }
.ws-divider span { width: 2px; height: 36px; border-radius: 2px; background: var(--border-default); transition: background var(--dur-base); }
.ws-divider:hover span { background: var(--cf-navy); }

/* ---- tabs ---- */
.tabbar { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface); }
.tab { position: relative; border: none; background: transparent; padding: 13px 14px 12px; font-size: 13px; font-weight: 500;
  color: var(--fg-muted); border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 7px; }
.tab:hover { color: var(--cf-navy); }
.tab.on { color: var(--cf-navy); border-bottom-color: var(--cf-navy); }
.tab-badge { background: var(--bg-subtle); color: var(--fg-muted); font-family: var(--font-mono); font-size: 10px;
  min-width: 16px; height: 16px; padding: 0 5px; border-radius: 8px; display: inline-grid; place-items: center; }
.tab-badge.err { background: var(--danger); color: #fff; }

.panel { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--bg-surface); }

/* ---- barra de inserción ---- */
.insert-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 14px;
  border-bottom: 1px solid var(--border-subtle); background: color-mix(in oklab, var(--bg-canvas) 60%, #fff); }
.ins-btn { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  padding: 6px 10px; font-size: 12px; color: var(--cf-navy); font-weight: 500; transition: all var(--dur-fast); }
.ins-btn:hover { border-color: var(--border-default); background: var(--bg-subtle); }
.ins-btn:disabled { opacity: .5; }
.ins-block { position: relative; margin-left: auto; }
.ins-pop { position: absolute; right: 0; top: 34px; z-index: 25; background: var(--bg-surface);
  border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; min-width: 240px; overflow: hidden; }
.ins-pop button { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; background: transparent;
  border: none; text-align: left; padding: 10px 14px; }
.ins-pop button:hover { background: var(--bg-subtle); }
.ip-name { color: var(--cf-navy); font-size: 12px; }
.ip-desc { color: var(--fg-muted); font-size: 11px; }

/* ============================================================
   CODE EDITOR
   ============================================================ */
.doc-editor-wrap { flex: 1; min-height: 0; position: relative; }
.code-editor { position: absolute; inset: 0; overflow: hidden; background: var(--bg-surface); }
.code-back, .code-ta {
  font-family: var(--font-mono); font-size: 13px; line-height: 21px; letter-spacing: 0;
  tab-size: 2; margin: 0;
}
/* Altura COMPLETA del contenido (sin bottom, sin overflow:hidden): el recorte lo
   hace .code-editor (overflow:hidden) y el scroll se simula con translateY. Si se
   recortara aquí a la altura del viewport, al desplazar quedaría todo en blanco. */
.code-back { position: absolute; top: 0; left: 0; right: 0; overflow: visible; pointer-events: none;
  padding: 14px 16px 14px 0; will-change: transform; color: var(--cf-navy); }
.ln-row { display: flex; align-items: flex-start; min-height: 21px; }
.ln-num { flex: 0 0 56px; width: 56px; text-align: right; padding-right: 14px; color: var(--fg-subtle);
  user-select: none; opacity: .65; font-size: 12px; }
.ln-code { flex: 1 1 auto; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.code-ta { position: absolute; inset: 0; border: none; outline: none; resize: none; background: transparent;
  color: transparent; caret-color: var(--cf-navy); white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  padding: 14px 16px 14px 56px; overflow-y: auto; scrollbar-gutter: stable; }
.code-mirror { position: absolute; visibility: hidden; white-space: pre-wrap; word-break: break-word; top: 0; left: 0; }

/* tokens de resaltado */
.hl-fence { color: var(--cf-olive); font-weight: 500; }
.hl-head { color: var(--cf-navy); font-weight: 700; }
.hl-h3 { color: color-mix(in oklab, var(--cf-navy) 80%, var(--cf-mint-300)); }
.hl-h4 { color: var(--fg-muted); font-weight: 500; }
.hl-fig { color: #1c7a52; background: color-mix(in oklab, var(--cf-mint) 40%, transparent); border-radius: 3px; }
.hl-fn { color: var(--ft-peach); filter: brightness(.8); font-weight: 500; }
.hl-bold { color: var(--cf-navy); font-weight: 700; }
.hl-attr { color: var(--fg-subtle); }
.hl-link { color: var(--info); }
.hl-list { color: var(--cf-mint-300); font-weight: 700; }
.hl-key { color: #7a4ea8; }
.hl-punct { color: var(--fg-subtle); }
.hl-yaml { color: var(--fg-muted); }
.hl-str { color: #1c7a52; }
.hl-num { color: #b06a2c; }
.hl-bool { color: #7a4ea8; }

/* autocompletado */
.ac-pop { position: absolute; z-index: 40; background: var(--cf-navy); color: var(--fg-on-dark);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 4px; min-width: 220px; max-width: 360px; }
.ac-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); font-size: 12.5px; }
.ac-item:hover, .ac-item.sel { background: rgba(255,255,255,.12); }
.ac-ico { font-family: var(--font-mono); font-size: 11px; color: var(--cf-mint); opacity: .9; }

/* ---- panel de problemas ---- */
.problems { border-top: 1px solid var(--border-subtle); background: var(--bg-surface); flex: 0 0 auto; max-height: 38px; transition: max-height var(--dur-base); display: flex; flex-direction: column; }
.problems.open { max-height: 220px; }
.problems-head { display: flex; align-items: center; gap: 12px; width: 100%; background: transparent; border: none;
  padding: 10px 16px; color: var(--fg-muted); }
.problems-head .cf-mono { font-size: 10px; letter-spacing: .12em; }
.prob-counts { display: flex; gap: 12px; font-size: 12px; }
.pc-err { color: var(--danger); } .pc-warn { color: var(--warning); } .pc-ok { color: var(--success); }
.prob-chev { margin-left: auto; opacity: .6; }
.problems-list { overflow-y: auto; padding: 4px 0 10px; }
.prob-item { display: flex; gap: 10px; padding: 6px 18px; font-size: 12.5px; align-items: flex-start; }
.prob-item.error { color: var(--cf-navy); } .prob-item.warn { color: var(--cf-navy); } .prob-item.info { color: var(--fg-muted); }
.prob-ico { flex: 0 0 auto; }
.prob-empty { padding: 10px 18px; color: var(--fg-muted); font-size: 13px; }

/* ---- panel datos ---- */
.data-bar { display: flex; align-items: center; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--border-subtle); }
.data-bar .cf-mono { font-size: 10px; letter-spacing: .12em; color: var(--fg-muted); }
.pv-grow { flex: 1; }
.data-ok { color: var(--success); } .data-err { color: var(--danger); }
.data-err-msg { background: color-mix(in oklab, var(--danger) 12%, #fff); color: var(--danger);
  padding: 8px 16px; font-size: 12px; font-family: var(--font-mono); border-bottom: 1px solid var(--border-subtle); }

/* ---- panel metadatos ---- */
.meta-panel { overflow: hidden; }
.meta-scroll { overflow-y: auto; padding: 22px 24px 40px; }
.meta-eyebrow { margin: 0 0 4px; }
.meta-note { color: var(--fg-muted); font-size: 13px; margin: 0 0 22px; max-width: 52ch; line-height: 1.5; }
.meta-field { margin-bottom: 18px; max-width: 620px; }
.meta-field label { display: flex; align-items: baseline; gap: 10px; font-size: 13px; font-weight: 500; color: var(--cf-navy); margin-bottom: 7px; }
.mf-hint { font-weight: 400; font-size: 11px; color: var(--fg-subtle); }
.meta-field input, .meta-field textarea { width: 100%; border: 1px solid var(--border-default);
  border-radius: var(--radius-md); padding: 10px 12px; font-size: 14px; color: var(--cf-navy); background: var(--bg-surface); outline: none; resize: vertical; }
.meta-field input:focus, .meta-field textarea:focus { border-color: var(--cf-navy); }

/* ---- panel materiales ---- */
.mat-panel { overflow-y: auto; padding: 22px 24px 40px; }
.mat-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.mat-upload { cursor: pointer; }
.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.mat-item { border: 1px solid var(--border-subtle); border-radius: var(--radius-md); overflow: hidden; background: var(--bg-surface); }
.mat-thumb { aspect-ratio: 4/3; display: grid; place-items: center; background: var(--bg-subtle); overflow: hidden; }
.mat-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mat-ext { font-size: 16px; color: var(--fg-muted); }
.mat-info { padding: 8px 10px 4px; display: flex; flex-direction: column; gap: 2px; }
.mat-name { font-size: 12px; color: var(--cf-navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mat-size { font-size: 10px; color: var(--fg-subtle); }
.mat-acts { display: flex; border-top: 1px solid var(--border-subtle); }
.mat-acts button { flex: 1; background: transparent; border: none; padding: 7px; font-size: 11px; color: var(--fg-muted); }
.mat-acts button:hover { background: var(--bg-subtle); color: var(--cf-navy); }
.mat-acts button.danger:hover { color: var(--danger); }
.mat-acts button + button { border-left: 1px solid var(--border-subtle); }
.mat-empty { padding: 50px 10px; text-align: center; }

/* ---- vista previa ---- */
.ws-right { background: var(--bg-subtle); }
.preview-bar { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface); }
.pv-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px color-mix(in oklab, var(--success) 22%, transparent); }
.pv-label { font-size: 10px; letter-spacing: .12em; color: var(--fg-muted); }
.pv-ok { font-size: 10px; color: var(--success); letter-spacing: .1em; }
.pv-warn { font-size: 10px; color: var(--danger); letter-spacing: .1em; }
.preview-wrap { flex: 1; min-height: 0; padding: 0; }
.preview-iframe { width: 100%; height: 100%; border: none; background: #fff; display: block; }

/* ---- toast ---- */
.ws-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: var(--cf-navy); color: var(--fg-on-dark); padding: 12px 20px; border-radius: var(--radius-pill);
  font-size: 13px; box-shadow: var(--shadow-lg); animation: toastIn var(--dur-base) var(--ease-out); max-width: 80vw; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 900px) {
  .ws-top { flex-wrap: wrap; }
  .g-search input { width: 110px; }
}

/* ============================================================
   LOGIN (Google) · SPLASH · estados async
   ============================================================ */
.google-host { margin-top: 30px; min-height: 44px; display: flex; justify-content: center; }
.login-busy { margin: 14px 0 0; text-align: center; color: var(--fg-muted); letter-spacing: .12em; font-size: 11px; }
.login-error { margin: 14px 0 0; text-align: center; color: var(--danger); font-size: 13px; }

.app-splash { height: 100%; display: grid; place-items: center; align-content: center; gap: 16px; background: var(--bg-canvas); }
.splash-label { color: var(--fg-muted); letter-spacing: .14em; font-size: 11px; }
.splash-spin { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--border-default);
  border-top-color: var(--cf-navy); animation: cfspin .8s linear infinite; }
@keyframes cfspin { to { transform: rotate(360deg); } }
.g-opening { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: color-mix(in oklab, var(--bg-canvas) 60%, transparent); }
.ws-save.save-err { color: var(--danger); }
