@import url('/assets/fonts/fonts.css');

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --ink: #14161a;
  --ink-2: #4a4f57;
  --muted: #767c86;
  --rule: #e4e6eb;
  --rule-strong: #d3d7de;
  --accent: #4361ee;
  --accent-hover: #3450d8;
  --accent-soft: #eef1fe;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(20, 22, 26, 0.06);
  --shadow-md: 0 8px 24px rgba(20, 22, 26, 0.08);
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --topbar-h: 66px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------- Barra superior ------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.15rem;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.brand { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.brand-mark { width: 30px; height: 30px; color: var(--ink); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name { font-weight: 700; letter-spacing: -0.02em; font-size: 15px; }
.brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.controls { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; justify-content: flex-end; }

.field { display: flex; flex-direction: column; gap: 2px; }
.field-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input,
.field select {
  height: 32px;
  min-width: 190px;
  padding: 0 0.55rem;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  color: var(--ink);
}
.field--sm select { min-width: 92px; }
.field input:focus, .field select:focus, .toggle input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 13px;
  color: var(--ink-2);
  user-select: none;
  cursor: pointer;
  align-self: flex-end;
  height: 32px;
}
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 32px;
  padding: 0 0.85rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: #fff; align-self: flex-end; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary[disabled] { background: var(--rule-strong); color: var(--muted); cursor: progress; }

.btn-ghost {
  height: 26px;
  padding: 0 0.55rem;
  background: transparent;
  border-color: var(--rule);
  color: var(--ink-2);
  font-weight: 500;
  font-size: 12px;
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--rule-strong); color: var(--ink); }

/* --------------------------------- Workspace --------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px;
  background: var(--rule);
  height: calc(100vh - var(--topbar-h));
}

.pane { display: flex; flex-direction: column; min-width: 0; background: var(--surface); }
.pane--preview { background: var(--surface-2); }

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  height: 38px;
  padding: 0 0.9rem;
  border-bottom: 1px solid var(--rule);
  flex: none;
}
.pane-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.pane-actions { display: flex; gap: 0.35rem; }
.pane-note { font-size: 11px; color: var(--muted); }

#editor {
  flex: 1;
  width: 100%;
  border: 0;
  resize: none;
  padding: 1.1rem 1.15rem;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
  background: transparent;
  tab-size: 2;
}
#editor:focus { outline: none; }

.pane--editor.is-dragover { box-shadow: inset 0 0 0 2px var(--accent); }

.pane-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  padding: 0 0.9rem;
  border-top: 1px solid var(--rule);
  font-size: 11px;
  color: var(--muted);
  flex: none;
}
.hint { opacity: 0.75; }

.preview-scroll { flex: 1; min-height: 0; overflow: hidden; padding: 1.3rem 1.2rem 1.3rem; }

.sheet {
  display: block;
  width: 100%;
  max-width: 820px;
  height: 100%;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

/* ------------------------------- Medalla Integra ------------------------------ */

.integra-badge {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  transition: transform 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.integra-badge svg { width: 17px; height: 17px; color: var(--ink); }
.integra-badge .arrow { color: var(--muted); }
.integra-badge:hover { transform: translateY(-1px) scale(1.03); color: var(--ink); border-color: var(--accent); }

/* ----------------------------------- Toast ----------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.3rem;
  transform: translate(-50%, 12px);
  z-index: 40;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #b4232a; }

/* --------------------------------- Responsive -------------------------------- */

@media (max-width: 900px) {
  :root { --topbar-h: auto; }
  .topbar { flex-direction: column; align-items: stretch; gap: 0.7rem; padding: 0.8rem 1rem; }
  .controls { justify-content: flex-start; }
  .field input { min-width: 0; width: 100%; }
  .field { flex: 1 1 160px; }
  .workspace { grid-template-columns: 1fr; height: auto; }
  .pane--editor #editor { min-height: 46vh; }
  .preview-scroll { height: 70vh; }
  .sheet { padding: 1.8rem 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
