/* ============================================================
   SALVADOR OS — custom.css
   Sistema de diseño personal basado en Bootstrap 5
   ============================================================ */

/* ─── Variables globales ──────────────────────────────────── */
:root {
  --sidebar-width: 260px;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #4f46e5;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --navbar-height: 64px;
  --accent: #4f46e5;
  --accent-light: #eef2ff;
  --body-bg: #f1f5f9;
  --card-radius: 12px;
  --transition: 0.25s ease;
}

/* ─── Base ────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--body-bg);
  color: #1e293b;
  font-size: 14px;
}

/* Utilidades tipográficas */
.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }

/* ─── Layout principal ────────────────────────────────────── */
.sos-wrapper {
  display: flex;
  min-height: 100vh;
}

.sos-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

.sos-content {
  flex: 1;
  padding: 28px;
  max-width: 1400px;
  margin-inline: auto;   /* Sprint 44 C6: centra el contenido en pantallas anchas */
}

/* Sprint 44 C6: modificador para vistas planner que necesitan ancho completo */
.sos-content--wide {
  max-width: none;
}

.sos-footer {
  padding: 12px 28px;
  border-top: 1px solid #e2e8f0;
  background: white;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sos-sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
  scrollbar-width: thin;
  scrollbar-color: #1e293b transparent;
}

.sos-sidebar::-webkit-scrollbar {
  width: 4px;
}
.sos-sidebar::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

/* Brand/Logo */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid #1e293b;
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-icon span {
  color: white;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.sidebar-brand-text {
  color: white;
  line-height: 1.3;
}

.sidebar-brand-text .fw-bold {
  font-size: 14px;
}

.sidebar-version {
  font-size: 10px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Nav labels */
.sidebar-nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #334155;
  text-transform: uppercase;
  padding: 14px 16px 4px;
}

/* Nav list */
.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0 8px;
}

/* Nav links */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 1px;
  position: relative;
}

.sidebar-link i {
  font-size: 16px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.sidebar-link:hover:not(.disabled) {
  background: var(--sidebar-hover);
  color: white;
}

.sidebar-link.active {
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.sidebar-link.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.sidebar-link.disabled:hover {
  background: transparent;
  color: var(--sidebar-text);
}

/* Badge "Pronto" */
.sidebar-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  background: #1e293b;
  color: #475569;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Usuario en el fondo del sidebar */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid #1e293b;
  margin-top: 8px;
}

.sidebar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-user-avatar span {
  color: white;
  font-weight: 700;
  font-size: 14px;
}

.sidebar-user-info {
  flex: 1;
  overflow: hidden;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-settings {
  color: #475569;
  font-size: 15px;
  transition: color var(--transition);
  flex-shrink: 0;
}

.sidebar-user-settings:hover {
  color: white;
}

/* ─── Navbar ──────────────────────────────────────────────── */
.sos-navbar {
  height: var(--navbar-height);
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: #64748b;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
}

.sidebar-toggle:hover {
  background: var(--body-bg);
  color: var(--accent);
}

.navbar-page-title {
  font-size: 15px;
  color: #334155;
}

/* Avatar en navbar */
.navbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.navbar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.navbar-avatar span {
  color: white;
  font-weight: 700;
  font-size: 12px;
}

.navbar-user-btn {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 100px;
  padding: 4px 12px 4px 4px;
  transition: all var(--transition);
}

.navbar-user-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.btn-icon {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 8px;
  color: #64748b;
  transition: all var(--transition);
}

.btn-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Cards generales ─────────────────────────────────────── */
.card {
  border-radius: var(--card-radius) !important;
}

.card-header {
  border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
}

/* ─── Stat Cards (Dashboard) ──────────────────────────────── */
.stat-card {
  border-radius: var(--card-radius);
  padding: 20px;
  color: white;
  position: relative;
  overflow: hidden;
  min-height: 110px;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
}

.stat-card-icon {
  font-size: 22px;
  opacity: 0.85;
  margin-bottom: 6px;
}

.stat-card-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 2px;
}

.stat-card-label {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card-sub {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 2px;
}

.stat-card-blue    { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-card-orange  { background: linear-gradient(135deg, #f97316, #ea580c); }
.stat-card-purple  { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-card-green   { background: linear-gradient(135deg, #22c55e, #16a34a); }

/* ─── Dashboard header ────────────────────────────────────── */
.dashboard-greeting {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.3;
}

.page-header-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

/* ─── Módulos grid ────────────────────────────────────────── */
.module-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: white;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: #475569;
  transition: all var(--transition);
}

.module-chip.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.module-chip.disabled {
  opacity: 0.5;
  background: #f8fafc;
}

.module-chip i {
  font-size: 16px;
}

/* ─── Empty state ─────────────────────────────────────────── */
.empty-state {
  padding: 20px;
}

/* ─── Badges soft ─────────────────────────────────────────── */
.bg-primary-soft { background: var(--accent-light) !important; }
.bg-secondary-soft { background: #f1f5f9 !important; }
.text-purple { color: #7c3aed !important; }

/* ─── Goal cards ──────────────────────────────────────────── */
.min-w-0 {
  min-width: 0;
}
.goal-card {
  transition: transform .15s, box-shadow .15s;
  overflow: hidden;
}
.goal-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15,23,42,.10) !important;
}
.goal-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.goal-card-subline {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-weight: 600;
}
.goal-card-toggle {
  font-size: .75rem;
  color: var(--text-muted, #64748b);
  font-weight: 600;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.goal-card-toggle:hover {
  color: var(--accent);
}
.goal-card-toggle .bi-chevron-down {
  transition: transform .2s ease;
  display: inline-block;
}
.goal-card-toggle[aria-expanded="true"] .bi-chevron-down {
  transform: rotate(180deg);
}
.goal-card-desc-full {
  font-size: .8rem;
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ─── Panel expandible de objetivos (Sprint 4.8.4) ───────────── */
.goal-card-panel {
  font-size: .8rem;
}
.goal-panel-section {
  margin-bottom: 10px;
}
.goal-panel-section:last-child {
  margin-bottom: 0;
}
.goal-panel-heading {
  font-weight: 700;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted, #64748b);
  margin-bottom: 6px;
}
.goal-panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.goal-panel-list li {
  min-width: 0;
}
.goal-panel-item-name {
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}
.goal-panel-notes p {
  overflow-wrap: break-word;
  word-break: break-word;
  font-size: .78rem;
}

/* ─── Auth pages ──────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  padding: 24px;
  position: relative;
}

.auth-bg {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 50%);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

.auth-logo {
  width: 64px;
  height: 64px;
  background: var(--accent);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.4);
}

.auth-logo span {
  color: white;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 1px;
}

.auth-title {
  color: white;
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}

.auth-subtitle {
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  margin-bottom: 0;
}

.auth-card {
  background: white;
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}

.auth-card-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}

.auth-card-header p {
  color: #64748b;
  font-size: 13px;
  margin-bottom: 24px;
}

.auth-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.auth-link:hover { text-decoration: underline; }

.btn-auth {
  padding: 12px 20px;
  font-weight: 600;
  border-radius: 10px;
}

/* ─── Responsive ──────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
}

@media (max-width: 991.98px) {
  .sos-sidebar {
    transform: translateX(-100%);
  }

  .sos-sidebar.show {
    transform: translateX(0);
  }

  .sidebar-overlay.show {
    display: block;
  }

  .sos-main {
    margin-left: 0;
  }

  .sos-content {
    padding: 16px;
  }

  .dashboard-greeting {
    font-size: 18px;
  }
}

@media (max-width: 575.98px) {
  .stat-card-value { font-size: 22px; }
  .auth-card { padding: 24px; }
}

/* ─── HABIT TRACKER ───────────────────────────────────────── */

/* Header de la vista Hoy */
.habits-title {
  font-size: 22px;
  font-weight: 700;
}

/* Score cards de hábitos */
.score-card {
  border-radius: var(--card-radius);
  padding: 16px 12px;
  text-align: center;
  border: 1px solid #e2e8f0;
  background: white;
  min-height: 100px;
}

.score-card-primary { border-top: 3px solid var(--accent); }
.score-card-green   { border-top: 3px solid #22c55e; }
.score-card-orange  { border-top: 3px solid #f97316; }

.score-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: #1e293b;
  margin-bottom: 4px;
}

.score-unit { font-size: 16px; font-weight: 400; color: #64748b; }
.score-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: #64748b; }
.score-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }

/* Score ring (SVG circular) */
.score-ring {
  position: relative;
  width: 56px;
  height: 56px;
  margin: 0 auto 6px;
}

.circular-chart {
  display: block;
  max-width: 100%;
  transform: rotate(-90deg);
}

.circle-bg {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 3.8;
}

.circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3.8;
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s ease;
}

.ring-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: 800;
  color: #1e293b;
}

.ring-text small { font-size: 8px; }

/* Categoría de hábitos */
.habit-category-block {
  border: 1px solid #e2e8f0;
  border-radius: var(--card-radius);
  background: white;
  overflow: hidden;
}

.habit-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
  user-select: none;
}

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

.cat-icon { font-size: 16px; }
.cat-name { font-size: 14px; color: #1e293b; }

.cat-count {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
}

.cat-chevron { font-size: 12px; color: #94a3b8; transition: transform 0.2s; }
.collapsed .cat-chevron { transform: rotate(-90deg); }

/* Fila de hábito */
.habit-list { padding: 4px 8px; }

.habit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 8px;
  transition: background var(--transition);
  margin-bottom: 2px;
}

.habit-row:hover { background: #f8fafc; }
.habit-row--done { background: #f0fdf4; }
.habit-row--done:hover { background: #dcfce7; }

/* Botón toggle */
.habit-toggle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--habit-color, #3b82f6);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.2s;
}

.habit-toggle--pending {
  color: var(--habit-color, #3b82f6);
}

.habit-toggle--done {
  background: var(--habit-color, #3b82f6);
  color: white;
  border-color: var(--habit-color, #3b82f6);
}

.habit-toggle:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--habit-color, #3b82f6) 20%, transparent);
}

/* Nombre del hábito */
.habit-name {
  font-size: 14px;
  font-weight: 500;
  color: #1e293b;
  line-height: 1.3;
}

.habit-meta { font-size: 11px; margin-top: 1px; }

/* Streak badge */
.streak-badge {
  font-size: 11px;
  font-weight: 700;
  color: #f59e0b;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Botones extra-pequeños */
.btn-xs {
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 5px;
}

.btn-ghost {
  background: none;
  border: none;
  color: #94a3b8;
  padding: 4px;
}

.btn-ghost:hover { color: #64748b; background: #f1f5f9; }

/* Acciones del hábito */
.habit-actions { flex-shrink: 0; }

/* Mini chart semanal */
.weekly-mini-chart {
  height: 48px;
  align-items: flex-end;
}

.weekly-day-bar {
  border-radius: 3px 3px 0 0;
  background: #f1f5f9;
  height: 100%;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.4s ease;
}

/* Formulario: emoji y color pickers */
.emoji-option {
  font-size: 18px;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: background 0.15s;
}
.emoji-option:hover { background: #f1f5f9; }

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}
.color-swatch:hover { border-color: #1e293b; transform: scale(1.15); }

/* Detalle: calendario de días */
.day-cell {
  width: 18px;
  height: 18px;
  border-radius: 3px;
}

.day-cell--done   { background: #22c55e; }
.day-cell--missed { background: #fee2e2; border: 1px solid #fca5a5; }
.day-cell--empty  { background: #f1f5f9; border: 1px solid #e2e8f0; }

/* Heatmap */
.heatmap-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.heatmap-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.heatmap-zero { background: #f1f5f9; }
.heatmap-low  { background: #bbf7d0; }
.heatmap-mid  { background: #22c55e; }
.heatmap-high { background: #15803d; }

/* Badges extra */
.bg-success-soft { background: #f0fdf4 !important; }
.bg-purple-soft  { background: #f5f3ff !important; }
.text-purple      { color: #7c3aed !important; }
.bg-warning-soft  { background: #fefce8 !important; }
.bg-danger-soft   { background: #fef2f2 !important; }
.bg-info-soft     { background: #ecfeff !important; }
.border-dashed    { border: 2px dashed #e2e8f0 !important; border-radius: 8px; }

/* ─── Sprint 5.3 — Dashboard ejecutivo ───────────────────────── */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: .85rem;
  border-bottom: 1px solid #f1f5f9;
}
.alert-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.alert-item-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
}

/* ─── Sprint 5.3 — Jerarquía visual de objetivos ─────────────── */
.goal-tree-node {
  border-left: 2px solid #e2e8f0;
  padding-left: 14px;
  margin-bottom: 6px;
}
.goal-tree-node .goal-tree-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f8fafc;
}
.goal-tree-node .goal-tree-row:hover {
  background: var(--accent-light);
}
.goal-tree-children {
  margin-top: 6px;
  margin-left: 8px;
}
.goal-tree-meta {
  font-size: .7rem;
  color: var(--text-muted, #64748b);
  white-space: nowrap;
}
.goal-tree-icon {
  font-size: 1rem;
  flex-shrink: 0;
}
.goal-tree-title {
  min-width: 0;
}

/* ─── Sprint 5.4 — Centro de Comando Diario ──────────────────── */
.command-current-card {
  border-left: 4px solid var(--accent) !important;
}

.command-timeline {
  display: flex;
  flex-direction: column;
}

.command-timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}
.command-timeline-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.command-timeline-time {
  flex-shrink: 0;
  width: 48px;
  font-size: .75rem;
  font-weight: 600;
  color: #64748b;
  padding-top: 2px;
}

.command-timeline-dot {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 4px;
  background: #cbd5e1;
}

.command-timeline-item.is-done .command-timeline-dot { background: #22c55e; }
.command-timeline-item.is-current .command-timeline-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.command-timeline-item.is-missed .command-timeline-dot { background: #ef4444; }
.command-timeline-item.is-skipped .command-timeline-dot { background: #94a3b8; }

.command-timeline-content { flex-grow: 1; min-width: 0; }

.command-timeline-item.is-current .command-timeline-content {
  background: var(--accent-light);
  border-radius: 8px;
  padding: 6px 10px;
  margin: -6px -10px;
}

.command-timeline-item.is-done .command-timeline-content,
.command-timeline-item.is-skipped .command-timeline-content {
  opacity: .65;
}

/* ============================================================
   PWA / MOBILE / OFFLINE OS (Sprint 13)
   Estilos aditivos: no se elimina ni reescribe CSS existente.
   ============================================================ */

/* ─── Indicador de conexión (navbar) ──────────────────────── */
.pwa-connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pwa-connection-badge.pwa-online {
  background: #dcfce7;
  color: #16a34a;
}

.pwa-connection-badge.pwa-offline {
  background: #fee2e2;
  color: #dc2626;
}

.pwa-queue-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #fef3c7;
  color: #b45309;
  white-space: nowrap;
}

/* ─── Aviso de actualización del Service Worker ───────────── */
.pwa-update-banner {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1080;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  max-width: 92vw;
}

@media (max-width: 991.98px) {
  .pwa-update-banner {
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
}

/* ─── Página offline (/pwa/offline/) ──────────────────────── */
.pwa-offline-wrap {
  max-width: 720px;
  margin: 0 auto;
}

.pwa-offline-card {
  background: #fff;
  border-radius: var(--card-radius);
  padding: 28px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.pwa-offline-icon {
  font-size: 40px;
  color: var(--accent);
  margin-bottom: 8px;
}

.pwa-offline-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.pwa-offline-box {
  background: var(--accent-light);
  border-radius: var(--card-radius);
  padding: 12px 16px;
  height: 100%;
}

/* ─── Navegación inferior móvil (bottom nav) ──────────────── */
.pwa-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 220;
  display: flex;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.pwa-bottom-nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  min-height: 56px;
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  background: none;
  border: none;
  text-decoration: none;
}

.pwa-bottom-nav-link i { font-size: 18px; }

.pwa-bottom-nav-link.active {
  color: var(--accent);
}

/* ─── Borrador local / aviso de formulario offline ────────── */
#pwa-draft-banner,
.pwa-offline-form-notice {
  border-radius: var(--card-radius);
}

/* ─── Ajustes mobile-first generales ──────────────────────── */
@media (max-width: 991.98px) {
  /* Espacio para que el bottom nav no tape contenido */
  .sos-content {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  /* Respiración para notch / safe areas en iPhone */
  .sos-navbar {
    padding-top: max(0px, env(safe-area-inset-top));
  }
}

@media (max-width: 767.98px) {
  /* Botones y enlaces con área táctil mínima */
  .btn {
    min-height: 40px;
  }

  .btn-sm {
    min-height: 36px;
  }

  .sidebar-link,
  .pwa-bottom-nav-link {
    min-height: 44px;
  }

  /* Formularios: evitar zoom automático en iOS y mejorar tacto */
  .form-control,
  .form-select {
    font-size: 16px;
    min-height: 44px;
  }

  textarea.form-control {
    min-height: 100px;
  }

  .form-check-input {
    width: 1.25em;
    height: 1.25em;
  }

  .form-label {
    font-size: 14px;
    font-weight: 600;
  }

  /* Tablas: compactas y con scroll horizontal suave dentro de su contenedor */
  .table {
    font-size: 12.5px;
  }

  .table th,
  .table td {
    padding: 0.45rem 0.5rem;
  }

  .table-responsive {
    -webkit-overflow-scrolling: touch;
  }

  /* Cards: menos espaciado vertical en móvil */
  .card-body {
    padding: 14px;
  }
}

/* ─── Centro de Ayuda (Sprint 13.5): contenido renderizado desde Markdown ─── */
.help-doc-content h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

.help-doc-content h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #e9ecef;
}

.help-doc-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.help-doc-content h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.help-doc-content p,
.help-doc-content ul,
.help-doc-content ol {
  font-size: 0.92rem;
  line-height: 1.6;
}

.help-doc-content ul,
.help-doc-content ol {
  padding-left: 1.4rem;
}

.help-doc-content li {
  margin-bottom: 0.25rem;
}

.help-doc-content table {
  width: 100%;
  margin: 1rem 0;
  font-size: 0.85rem;
  border-collapse: collapse;
}

.help-doc-content table th,
.help-doc-content table td {
  border: 1px solid #e9ecef;
  padding: 0.5rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.help-doc-content table th {
  background: #f8f9fb;
  font-weight: 600;
}

.help-doc-content code {
  background: #f1f3f9;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.help-doc-content pre {
  background: #f1f3f9;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.82rem;
}

.help-doc-content pre code {
  background: none;
  padding: 0;
}

.help-doc-content blockquote {
  border-left: 3px solid #4f46e5;
  padding-left: 1rem;
  color: #6c757d;
  margin: 1rem 0;
}

.help-doc-content hr {
  margin: 1.75rem 0;
  border-top: 1px solid #e9ecef;
}

@media (max-width: 575.98px) {
  .help-doc-content table {
    font-size: 0.78rem;
  }
}
