/* ═══════════════════════════════════════════
   ADMIN BORRADO DEL MAPA — Estilos
   Tema oscuro, mobile-first, responsive
   ═══════════════════════════════════════════ */

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #1e2a4a;
  --bg-card-hover: #243056;
  --bg-input: #0f1629;
  --text-primary: #e8e8f0;
  --text-secondary: #8b8fa3;
  --text-muted: #5a5e72;
  --border: rgba(255,255,255,.08);
  --border-hover: rgba(255,255,255,.15);
  --accent: #4361ee;
  --accent-hover: #3a56d4;
  --green: #06d6a0;
  --red: #ef476f;
  --yellow: #ffd166;
  --dorado: #d4a017;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,.3);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Consolas", monospace;
}

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

html {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

/* ─── LOGIN ─── */

.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  gap: 32px;
}

.login-logo {
  width: 220px;
  height: auto;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 320px;
}

.login-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  padding: 14px 16px;
  outline: none;
  transition: border-color .2s;
}

.login-input:focus {
  border-color: var(--accent);
}

.login-input::placeholder {
  color: var(--text-muted);
}

.login-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

.login-btn:hover {
  background: var(--accent-hover);
}

.login-error {
  color: var(--red);
  font-size: 13px;
  text-align: center;
  min-height: 20px;
}

/* ─── APP SHELL ─── */

.app { display: none; }
.app.active { display: flex; flex-direction: column; min-height: 100vh; }

/* ─── HEADER / TABS ─── */

.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 56px;
  max-width: 1400px;
  margin: 0 auto;
}

.header-logo {
  height: 28px;
  margin-right: 24px;
  flex-shrink: 0;
}

.hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-left: auto;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Tabs desktop — ocultas en móvil */
.tabs-desktop {
  display: none;
  gap: 4px;
  flex: 1;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}

.tab-btn:hover {
  background: rgba(255,255,255,.05);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Menú móvil */
.mobile-menu {
  display: none;
  flex-direction: column;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px 16px;
  gap: 4px;
}

.mobile-menu.open { display: flex; }

.mobile-menu .tab-btn {
  text-align: left;
  padding: 12px 14px;
  font-size: 15px;
}

/* ─── MAIN CONTENT ─── */

.main {
  flex: 1;
  padding: 20px 16px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn .2s ease;
}

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

/* ─── PLACEHOLDER (contenido vacío por fase) ─── */

.tab-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  gap: 12px;
  color: var(--text-muted);
}

.tab-placeholder-icon {
  font-size: 48px;
  opacity: .5;
}

.tab-placeholder-text {
  font-size: 15px;
  text-align: center;
}

/* ─── METRIC CARDS (para Dashboard y futuras pestañas) ─── */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color .2s;
}

.metric-card:hover {
  border-color: var(--border-hover);
}

.metric-icon {
  font-size: 20px;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.5px;
  line-height: 1.1;
}

.metric-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.metric-trend {
  font-size: 12px;
  font-weight: 600;
}

.metric-trend.up { color: var(--green); }
.metric-trend.down { color: var(--red); }

/* ─── SEMÁFORO ─── */

.health-row {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.health-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
}

.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.health-dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.health-dot.yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.health-dot.red { background: var(--red); box-shadow: 0 0 6px var(--red); }
.health-dot.grey { background: var(--text-muted); }

/* ─── TABLES ─── */

.admin-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 12px 14px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .5px;
}

.admin-table td {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  white-space: nowrap;
}

.admin-table tr:nth-child(even) {
  background: rgba(255,255,255,.02);
}

.admin-table tr:hover {
  background: rgba(255,255,255,.04);
}

/* ─── USERS TOOLBAR ─── */

.users-toolbar {
  margin-bottom: 16px;
}

.users-search {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  width: 100%;
  max-width: 360px;
  outline: none;
  transition: border-color .2s;
}

.users-search:focus { border-color: var(--accent); }
.users-search::placeholder { color: var(--text-muted); }

/* ─── SORTABLE COLUMNS ─── */

.sortable {
  cursor: pointer;
  user-select: none;
}

.sortable:hover { color: var(--text-primary); }

.sortable::after {
  content: ' ↕';
  opacity: .3;
  font-size: 10px;
}

.sortable.asc::after { content: ' ↑'; opacity: .8; }
.sortable.desc::after { content: ' ↓'; opacity: .8; }

/* ─── PAGINATION ─── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.pagination button:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination button:disabled { opacity: .3; cursor: default; }

.pagination-info {
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── LOADING SPINNER ─── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
  gap: 8px;
}

.loading::before {
  content: '';
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── SECTION TITLE ─── */

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

.subsection-title {
  font-size: 15px;
  font-weight: 600;
  margin: 24px 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── BUTTONS ─── */

.btn-sm {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.btn-sm:hover { background: var(--accent-hover); }

.btn-sm.danger { background: var(--red); }
.btn-sm.danger:hover { background: #d63a5c; }

.btn-sm.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-sm.secondary:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* ─── ROADMAP ─── */

.roadmap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.phase-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.phase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.phase-name {
  font-weight: 700;
  font-size: 14px;
}

.phase-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-transform: uppercase;
}

.phase-badge.done { background: var(--green); color: #000; }
.phase-badge.in_progress { background: var(--yellow); color: #000; }
.phase-badge.designed { background: var(--yellow); color: #000; }
.phase-badge.planned { background: var(--text-muted); color: #fff; }
.phase-badge.pending { background: var(--text-muted); color: #fff; }

.progress-bar {
  height: 4px;
  background: rgba(255,255,255,.08);
  border-radius: 2px;
  margin-bottom: 12px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width .3s;
}

.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
}

.task-status {
  flex-shrink: 0;
  font-size: 14px;
}

.task-name {
  flex: 1;
}

.task-name.done { text-decoration: line-through; color: var(--text-muted); }

.task-action {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
}

.task-action:hover { color: var(--text-primary); background: rgba(255,255,255,.06); }

.phase-add-task {
  margin-top: 8px;
}

/* ─── CHANGELOG ─── */

.changelog-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.changelog-entry {
  display: flex;
  gap: 12px;
  font-size: 13px;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.changelog-date {
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 80px;
}

/* ─── SYSTEM INFO ─── */

.system-info {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 24px;
}

.info-row {
  display: flex;
  gap: 8px;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.info-label {
  color: var(--text-muted);
  min-width: 130px;
  flex-shrink: 0;
}

/* ─── IDEAS LIST ─── */

.ideas-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.idea-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
}

.idea-priority {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-transform: uppercase;
}

.idea-priority.high { background: var(--red); color: #fff; }
.idea-priority.medium { background: var(--yellow); color: #000; }
.idea-priority.low { background: var(--text-muted); color: #fff; }

.idea-text { flex: 1; }

/* ─── INFO BOX ─── */

.info-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ─── MODAL ─── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal input, .modal textarea, .modal select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  width: 100%;
}

.modal textarea { resize: vertical; min-height: 60px; }
.modal input:focus, .modal textarea:focus, .modal select:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ─── SALMA ALERTS ─── */

.salma-alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

.salma-alert.red {
  background: rgba(239,71,111,.15);
  border: 1px solid var(--red);
  color: var(--red);
}

.salma-alert.yellow {
  background: rgba(255,209,102,.15);
  border: 1px solid var(--yellow);
  color: var(--yellow);
}

/* ─── STATUS BADGES ─── */

.status-ok {
  color: var(--green);
  font-weight: 600;
}

.status-error {
  color: var(--red);
  font-weight: 600;
}

.type-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.type-badge.route { background: var(--accent); color: #fff; }
.type-badge.conversational { background: var(--text-muted); color: #fff; }

/* ─── CHAT ─── */

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-actions {
  display: flex;
  gap: 6px;
}

.chat-messages {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 300px;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.chat-welcome {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 40px 16px;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.user {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-msg.thinking {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  align-self: flex-start;
  font-style: italic;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  padding: 12px 14px;
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 120px;
}

.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}

.chat-send:hover { background: var(--accent-hover); }
.chat-send:disabled { opacity: .5; cursor: default; }

/* ─── CHARTS ─── */

.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.chart-sm { max-width: 100%; }

.charts-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (min-width: 768px) {
  .charts-row { grid-template-columns: 1fr 1fr; }
}

/* ─── RESPONSIVE ─── */

@media (min-width: 768px) {
  .hamburger { display: none; }
  .mobile-menu { display: none !important; }

  .tabs-desktop {
    display: flex;
  }

  .metrics-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .main {
    padding: 28px 24px;
  }
}

@media (min-width: 1024px) {
  .metrics-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  .roadmap {
    grid-template-columns: repeat(2, 1fr);
  }
}
