/* ---------------------------------------------------
   PromptVault — tokens
--------------------------------------------------- */
:root{
  --bg: #0c0f0d;
  --bg-panel: #121613;
  --bg-elevated: #181d1a;
  --border: #232b26;
  --border-soft: #1a201c;
  --text: #e8f0ea;
  --text-muted: #869488;
  --text-dim: #566058;

  --accent: #d98f4e;       /* ambar terminal */
  --accent-soft: #d98f4e26;
  --accent-2: #5fb3a3;     /* teal para tags/vars */
  --accent-2-soft: #5fb3a326;
  --danger: #e0665a;
  --danger-soft: #e0665a22;

  --mono: ui-monospace, "JetBrains Mono", "Fira Code", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: -apple-system, "Segoe UI", system-ui, sans-serif;

  --radius: 6px;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  background-image:
    radial-gradient(circle at 15% 0%, #d98f4e0d, transparent 40%),
    radial-gradient(circle at 85% 20%, #5fb3a30a, transparent 45%);
}

::selection{ background: var(--accent-soft); color: var(--text); }

.crt-line{
  position: fixed; top:0; left:0; right:0; height:2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  opacity:.55; z-index: 50;
}

/* ---------------------------------------------------
   Header
--------------------------------------------------- */
.app-header{
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  position: sticky; top:0; z-index: 20;
  flex-wrap: wrap; gap: 12px;
}
.brand{ font-family: var(--mono); font-size: 1.25rem; letter-spacing:.5px; }
.brand-caret{ color: var(--accent); margin-right: 6px; }
.brand-name{ font-weight: 600; }
.brand-cursor{
  color: var(--accent);
  animation: blink 1.1s step-end infinite;
  margin-left: 2px;
}
@keyframes blink{ 50%{ opacity:0; } }

.header-actions{ display:flex; align-items:center; gap:10px; flex-wrap: wrap; }

.local-badge{
  font-family: var(--mono); font-size: .72rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  display:inline-flex; align-items:center; gap:6px;
}
.local-badge .dot{
  width:6px; height:6px; border-radius:50%;
  background: var(--accent-2);
  box-shadow: 0 0 6px var(--accent-2);
}

/* ---------------------------------------------------
   Buttons
--------------------------------------------------- */
.btn{
  font-family: var(--mono);
  font-size: .82rem;
  border-radius: var(--radius);
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s ease, transform .1s ease, background .15s ease;
}
.btn:hover{ border-color: var(--text-dim); transform: translateY(-1px); }
.btn:active{ transform: translateY(0); }

.btn-ghost{ background: transparent; }
.btn-accent{
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.btn-accent:hover{ background: var(--accent); color: #12100c; }
.btn-danger{
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover{ background: var(--danger); color: #1a0e0c; }

/* ---------------------------------------------------
   Layout
--------------------------------------------------- */
.app-main{
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  min-height: calc(100vh - 66px);
}
.sidebar{
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  background: var(--bg-panel);
}
.sidebar-title{
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: lowercase;
}
.sidebar-title-spaced{ margin-top: 22px; }

.tag-list{ display:flex; flex-wrap: wrap; gap: 8px; }
.tag-chip{
  font-family: var(--mono);
  font-size: .74rem;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.tag-chip:hover{ border-color: var(--accent-2); color: var(--text); }
.tag-chip.active{
  background: var(--accent-2-soft);
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.search-input, .text-input, .text-area{
  width: 100%;
  font-family: var(--mono);
  font-size: .85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}
.search-input:focus, .text-input:focus, .text-area:focus{
  border-color: var(--accent-2);
}
.text-area{ resize: vertical; line-height: 1.5; min-height: 140px; }

.sidebar-stats{
  margin-top: 26px;
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
}

.content{ padding: 24px; }

/* ---------------------------------------------------
   Empty state
--------------------------------------------------- */
.empty-state{
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-title{ font-family: var(--mono); color: var(--text); font-size: 1rem; margin: 0 0 6px; }
.empty-sub{ margin: 0 0 18px; font-size: .88rem; }

/* ---------------------------------------------------
   Prompt cards
--------------------------------------------------- */
.prompt-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.prompt-card{
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  display:flex; flex-direction: column; gap:10px;
  transition: border-color .15s ease, transform .12s ease;
  cursor: pointer;
}
.prompt-card:hover{ border-color: var(--accent-2); transform: translateY(-2px); }

.pc-top{ display:flex; justify-content: space-between; align-items:flex-start; gap: 8px; }
.pc-title{ font-weight:600; font-size: .95rem; line-height:1.3; }
.pc-edit{
  background:none; border:none; color: var(--text-dim);
  cursor:pointer; font-size: .85rem; padding: 2px 4px;
}
.pc-edit:hover{ color: var(--text); }

.pc-body{
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.55;
  max-height: 4.7em;
  overflow: hidden;
  position: relative;
}
.pc-var{
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 3px;
  padding: 0 3px;
}

.pc-tags{ display:flex; flex-wrap:wrap; gap:6px; }
.pc-tag{
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--accent-2);
  background: var(--accent-2-soft);
  border-radius: 999px;
  padding: 2px 8px;
}

.pc-footer{
  display:flex; justify-content: space-between; align-items:center;
  margin-top: 4px;
}
.pc-use{
  font-family: var(--mono); font-size: .74rem;
  color: var(--accent);
  background: none; border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
}
.pc-use:hover{ background: var(--accent); color:#12100c; }

/* ---------------------------------------------------
   Modal
--------------------------------------------------- */
.modal-overlay{
  position: fixed; inset:0;
  background: #05070599;
  backdrop-filter: blur(2px);
  display:flex; align-items:center; justify-content:center;
  z-index: 100;
  padding: 16px;
}
.modal-overlay[hidden]{
  display: none !important;
}
.modal{
  width: 100%; max-width: 560px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 20px 60px #000000aa;
}
.terminal-titlebar{
  display:flex; align-items:center; gap:7px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.tb-dot{ width:10px; height:10px; border-radius:50%; }
.tb-red{ background:#e0665a; }
.tb-yellow{ background:#d9b04e; }
.tb-green{ background:#5fb37a; }
.terminal-title{
  font-family: var(--mono); font-size:.78rem; color: var(--text-dim);
  margin-left: 8px;
}

.modal-body{ padding: 18px 20px; display:flex; flex-direction: column; gap: 6px; max-height: 65vh; overflow-y:auto; }
.field-label{
  font-family: var(--mono); font-size:.72rem; color: var(--text-dim);
  margin-top: 12px; margin-bottom: 2px;
}
.field-hint{ color: var(--text-dim); font-weight: 400; }

.modal-error{
  color: var(--danger); font-family: var(--mono); font-size: .78rem;
  margin-top: 10px;
}

.modal-footer{
  display:flex; justify-content:flex-end; gap:10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}

.preview-box{
  font-family: var(--mono);
  font-size: .85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  margin: 6px 0 0;
}

.var-field{ margin-bottom: 10px; }
.var-field label{
  display:block; font-family: var(--mono); font-size:.76rem;
  color: var(--accent); margin-bottom: 4px;
}

/* ---------------------------------------------------
   Toast
--------------------------------------------------- */
.toast{
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--accent);
  color: #14110c;
  font-family: var(--mono); font-weight: 600; font-size: .85rem;
  padding: 10px 18px; border-radius: 999px;
  box-shadow: 0 8px 24px #0009;
  z-index: 200;
}

/* ---------------------------------------------------
   Responsive
--------------------------------------------------- */
@media (max-width: 760px){
  .app-main{ grid-template-columns: 1fr; }
  .sidebar{ border-right:none; border-bottom: 1px solid var(--border); }
  .header-actions{ width:100%; justify-content: space-between; }
  .local-badge{ display:none; }
}

/* ---------------------------------------------------
   Botón teal (encadenado)
--------------------------------------------------- */
.btn-teal{
  background: var(--accent-2-soft);
  border-color: var(--accent-2);
  color: var(--accent-2);
}
.btn-teal:hover{ background: var(--accent-2); color:#0a1512; }

/* ---------------------------------------------------
   Modo combo
--------------------------------------------------- */
.prompt-card.combo-mode{ cursor: default; }
.pc-checkbox{
  position:absolute; top:12px; right:12px;
  width:18px; height:18px;
  accent-color: var(--accent);
  cursor:pointer;
}
.prompt-card{ position:relative; }
.prompt-card.combo-selected{ border-color: var(--accent); background: var(--accent-soft); }

.combo-bar{
  position: fixed; bottom: 0; left:0; right:0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--accent);
  padding: 14px 24px;
  display:flex; align-items:center; justify-content:space-between;
  z-index: 90;
  font-family: var(--mono); font-size: .85rem; color: var(--text);
}
.combo-bar > div{ display:flex; gap:10px; }

/* ---------------------------------------------------
   Revisor de calidad (linter)
--------------------------------------------------- */
.quality-panel{
  font-family: var(--mono); font-size: .74rem;
  margin-top: 8px; padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  display: flex; flex-direction: column; gap: 5px;
}
.quality-panel:empty{ display:none; }
.q-item{ display:flex; gap:7px; align-items:flex-start; }
.q-ok{ color: var(--accent-2); }
.q-warn{ color: var(--accent); }
.q-score{
  font-weight:600; color: var(--text); margin-bottom: 2px;
  border-bottom: 1px solid var(--border-soft); padding-bottom: 5px;
}

/* ---------------------------------------------------
   Historial de valores (chips de sugerencia)
--------------------------------------------------- */
.history-chips{
  display:flex; flex-wrap:wrap; gap:6px;
  margin: 4px 0 2px;
}
.history-chip{
  font-family: var(--mono); font-size: .7rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  cursor: pointer;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-chip:hover{ border-color: var(--accent-2); color: var(--text); }

/* ---------------------------------------------------
   Select de variable condicional
--------------------------------------------------- */
select.text-input{
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.chain-hint{ margin-top: 4px; }
.chain-hint code{
  background: var(--accent-soft); color: var(--accent);
  padding: 1px 5px; border-radius: 3px;
}

@media (prefers-reduced-motion: reduce){
  .brand-cursor{ animation: none; }
}
