/* =========================================================
   styles.css — estilos compartidos Text2SQL
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0a0e1a;
  --surface:  #111827;
  --surface2: #161f30;
  --border:   #1e2d40;
  --accent:   #00d4ff;
  --accent2:  #7c3aed;
  --text:     #e2e8f0;
  --muted:    #64748b;
  --error:    #f87171;
  --success:  #34d399;
  --radius:   12px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Syne', sans-serif;
}

/* Grid background */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}

.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1rem; letter-spacing: -0.02em; text-decoration: none; color: var(--text); }
.logo-icon { width: 28px; height: 28px; background: linear-gradient(135deg, var(--accent2), var(--accent)); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-family: 'JetBrains Mono', monospace; font-size: 0.6rem; font-weight: 600; color: white; }
.logo span { color: var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

.nav-link {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 0.72rem;
  padding: 0.3rem 0.7rem; cursor: pointer; text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}
.nav-link:hover { color: var(--accent); border-color: var(--accent); }

.btn-logout {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 0.72rem;
  padding: 0.3rem 0.7rem; cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.btn-logout:hover { color: var(--error); border-color: var(--error); }

.user-badge { font-size: 0.78rem; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.user-badge strong { color: var(--accent); }

/* ---- Cards ---- */
.card {
  width: 100%; max-width: 500px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem;
  animation: fadeUp 0.4s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Auth card centered ---- */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; overflow-y: auto; padding: 2rem 1rem;
}

.auth-card { max-width: 420px; padding: 2.5rem; box-shadow: 0 25px 50px rgba(0,0,0,0.5); }

.logo-lg { display: flex; align-items: center; gap: 10px; margin-bottom: 2rem; }
.logo-lg .logo-icon { width: 38px; height: 38px; font-size: 0.75rem; border-radius: 8px; }
.logo-lg .logo-text { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
.logo-lg .logo-text span { color: var(--accent); }

.project-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(0,212,255,0.08); border: 1px solid rgba(0,212,255,0.2);
  border-radius: 6px; padding: 0.3rem 0.7rem;
  font-family: 'JetBrains Mono', monospace; font-size: 0.72rem;
  color: var(--accent); margin-bottom: 1.5rem;
}

h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 0.4rem; }
.subtitle { font-size: 0.85rem; color: var(--muted); margin-bottom: 2rem; font-family: 'JetBrains Mono', monospace; }

/* ---- Forms ---- */
.field { margin-bottom: 1rem; }
.field.full { grid-column: 1 / -1; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

label {
  display: block; font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: 0.4rem;
  font-family: 'JetBrains Mono', monospace;
}

input, select, textarea {
  width: 100%; padding: 0.75rem 1rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 0.88rem;
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,212,255,0.08);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; line-height: 1.5; }
select option { background: var(--surface); }

/* ---- Buttons ---- */
.btn {
  width: 100%; padding: 0.75rem; border: none; border-radius: 8px;
  font-family: 'Syne', sans-serif; font-size: 0.9rem; font-weight: 700;
  cursor: pointer; transition: opacity 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 0.5rem;
}
.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary  { background: linear-gradient(135deg, var(--accent2), var(--accent)); color: white; }
.btn-secondary { background: var(--surface2); border: 1px solid var(--border); color: var(--text); }
.btn-danger   { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); color: var(--error); }
.btn-danger:hover { background: rgba(248,113,113,0.2); }
.btn-sm       { width: auto; flex: 1; padding: 0.7rem 1rem; margin-top: 0; font-size: 0.85rem; }

.btn .spinner { display: none; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.loading span  { display: none; }
.btn.loading .spinner { display: block; }

.btn-row { display: flex; gap: 0.75rem; margin-top: 0.5rem; }

/* ---- Messages ---- */
.msg {
  display: none; font-size: 0.8rem; font-family: 'JetBrains Mono', monospace;
  padding: 0.6rem 0.8rem; border-radius: 6px; margin-top: 0.75rem;
}
.msg.error   { display: block; background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); color: var(--error); }
.msg.success { display: block; background: rgba(52,211,153,0.1);  border: 1px solid rgba(52,211,153,0.3);  color: var(--success); }

/* ---- Section title ---- */
.section-title {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--muted);
  font-family: 'JetBrains Mono', monospace; margin-bottom: 1.2rem;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ---- Divider ---- */
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }

/* ---- Danger zone ---- */
.danger-zone { background: rgba(248,113,113,0.04); border: 1px solid rgba(248,113,113,0.15); border-radius: 8px; padding: 1.2rem; }
.danger-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--error); font-family: 'JetBrains Mono', monospace; margin-bottom: 0.5rem; }
.danger-desc  { font-size: 0.8rem; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-bottom: 1rem; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center; z-index: 100; }
.modal-overlay.show { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; max-width: 420px; width: 90%; animation: fadeUp 0.3s ease both; }
.modal-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 1rem; }
.modal p { font-size: 0.85rem; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-bottom: 1.5rem; }
.modal-btns { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.modal-btns .btn { margin-top: 0; }

/* ---- Status dot ---- */
.status-dot { display: flex; align-items: center; gap: 6px; font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); transition: background 0.3s; }
.dot.ok  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot.err { background: var(--error); }

/* ---- App layout ---- */
.app-layout { display: grid; grid-template-rows: 56px 1fr; height: 100vh; overflow: hidden; }
.app-main   { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; }
.panel      { display: flex; flex-direction: column; padding: 1.5rem; overflow-y: auto; border-right: 1px solid var(--border); }
.panel:last-child { border-right: none; }
.panel-title { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-bottom: 1.2rem; display: flex; align-items: center; gap: 8px; }
.panel-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.output-box { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; line-height: 1.6; color: var(--accent); overflow-y: auto; min-height: 120px; white-space: pre-wrap; word-break: break-word; }
.output-box.empty { color: var(--muted); }

.empty-state { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; }

/* ---- Results table ---- */
.results-wrap { flex: 1; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; }
thead { position: sticky; top: 0; background: var(--surface2); }
th { text-align: left; padding: 0.6rem 0.8rem; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.68rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 0.5rem 0.8rem; border-bottom: 1px solid rgba(30,45,64,0.6); color: var(--text); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr:hover td { background: rgba(0,212,255,0.03); }

.badge { display: inline-block; font-family: 'JetBrains Mono', monospace; font-size: 0.65rem; padding: 0.15rem 0.5rem; border-radius: 4px; background: rgba(0,212,255,0.1); color: var(--accent); border: 1px solid rgba(0,212,255,0.2); margin-left: 0.5rem; }

/* ---- Users table ---- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-title  { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
.table-wrap  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.empty       { text-align: center; padding: 3rem; color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; }

.role-badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; }
.role-badge.admin { background: rgba(124,58,237,0.15); color: #a78bfa; border: 1px solid rgba(124,58,237,0.3); }
.role-badge.user  { background: rgba(0,212,255,0.08); color: var(--accent); border: 1px solid rgba(0,212,255,0.2); }

.actions { display: flex; gap: 0.4rem; }
.btn-action { padding: 0.25rem 0.6rem; border-radius: 5px; font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; cursor: pointer; border: 1px solid var(--border); background: none; color: var(--muted); transition: all 0.2s; }
.btn-action.edit:hover { color: var(--accent); border-color: var(--accent); }
.btn-action.del:hover  { color: var(--error);  border-color: var(--error); }

/* ---- Hint text ---- */
.hint { font-size: 0.7rem; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-top: 0.4rem; }

/* ---- Links ---- */
.bottom-link { text-align: center; margin-top: 1.5rem; font-size: 0.8rem; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.bottom-link a { color: var(--accent); text-decoration: none; }
.bottom-link a:hover { text-decoration: underline; }

/* ---- Content wrapper ---- */
.content { flex: 1; display: flex; justify-content: center; padding: 2rem 1rem; }
.content-wide { flex: 1; padding: 1.5rem; max-width: 900px; margin: 0 auto; width: 100%; }

/* ---- Nav links group ---- */
.nav-links { display: flex; gap: 0.5rem; }

@media (max-width: 768px) {
  .app-main { grid-template-columns: 1fr; grid-template-rows: auto auto; }
  .panel { border-right: none; border-bottom: 1px solid var(--border); }
  .row { grid-template-columns: 1fr; }
}