/**
 * HabitFlow - Sistema de Estilos Moderno y Mobile-First
 * Soporte completo para temas Claro/Oscuro, CSS Grid, Flexbox y animaciones fluidas.
 */

/* ==========================================================================
   Variables y Paleta de Colores (Tema Oscuro por defecto)
   ========================================================================== */
:root {
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  /* Colores de Marca y Acento */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  --primary-glow: rgba(99, 102, 241, 0.35);

  --secondary: #8b5cf6;
  --accent: #ec4899;

  /* Estados Funcionales */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.15);

  /* Tema Oscuro (Base) */
  --bg-app: #090d16;
  --bg-surface: #111827;
  --bg-surface-elevated: #1f2937;
  --bg-card: #141e33;
  --bg-card-hover: #1b2845;
  --bg-input: #0c1220;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #6366f1;

  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
  --shadow-primary: 0 8px 20px rgba(99, 102, 241, 0.3);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);

  --header-height: 64px;
  --bottom-nav-height: 68px;
  --container-max-w: 920px;
}

/* ==========================================================================
   Tema Claro
   ========================================================================== */
[data-theme="light"] {
  --bg-app: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f1f5f9;

  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: #4f46e5;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 14px 30px rgba(0, 0, 0, 0.12);
  --shadow-primary: 0 8px 20px rgba(79, 70, 229, 0.25);
}

/* ==========================================================================
   Reset y Estilos Base
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100%;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-bottom: calc(var(--bottom-nav-height) + 24px);
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

@media (min-width: 768px) {
  body {
    padding-bottom: 40px;
  }
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

svg.icon {
  width: 20px;
  height: 20px;
  vertical-align: middle;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Cabecera de la Aplicación
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  height: var(--header-height);
  transition: background-color var(--transition-normal);
}

[data-theme="light"] .app-header {
  background-color: rgba(255, 255, 255, 0.85);
}

.header-container {
  max-width: var(--container-max-w);
  margin: 0 auto;
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .brand-name {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

/* Indicador de estado de red (Online / Offline) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all var(--transition-normal);
}

.status-pill .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-pill.online {
  background-color: var(--success-bg);
  color: var(--success);
}
.status-pill.online .status-dot {
  background-color: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.status-pill.offline {
  background-color: var(--warning-bg);
  color: var(--warning);
}
.status-pill.offline .status-dot {
  background-color: var(--warning);
  box-shadow: 0 0 6px var(--warning);
}

/* Botón de Instalación Header */
.btn-install-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: var(--shadow-primary);
  transition: transform var(--transition-fast), filter var(--transition-fast);
}

.btn-install-header:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

/* ==========================================
   Navegación Desktop Superior
   ========================================== */
.desktop-nav {
  display: none;
}

@media (min-width: 768px) {
  .desktop-nav {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .desktop-nav .nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    transition: all var(--transition-normal);
  }

  .desktop-nav .nav-btn:hover {
    color: var(--text-main);
    background-color: var(--bg-surface-elevated);
  }

  .desktop-nav .nav-btn.active {
    color: var(--primary);
    background-color: var(--primary-light);
  }
}

/* ==========================================
   Contenedor Principal y Vistas
   ========================================== */
.main-content {
  max-width: var(--container-max-w);
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px;
  flex: 1;
}

.view-section {
  animation: fadeIn 0.3s ease;
}

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

/* Títulos y Subtítulos de Secciones */
.page-intro {
  margin-bottom: 22px;
}

.user-greeting {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.current-date-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ==========================================
   Dashboard / Cards Resumen
   ========================================== */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.metric-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary-light);
}

.metric-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.metric-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.metric-subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.progress-track {
  width: 100%;
  height: 6px;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-full);
  margin-top: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: var(--radius-full);
  transition: width 0.4s var(--transition-smooth);
}

/* ==========================================
   Listas y Secciones del Dashboard
   ========================================== */
.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  margin-top: 10px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 30px;
}

/* ==========================================
   Tarjetas de Hábitos (Habit Card)
   ========================================== */
.habit-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-normal);
}

.habit-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
}

.habit-card.completed {
  background-color: rgba(16, 185, 129, 0.04);
  border-color: rgba(16, 185, 129, 0.25);
}

.habit-emoji-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.habit-info {
  flex: 1;
  min-width: 0;
}

.habit-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.habit-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.habit-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Insignia de Racha */
.habit-streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-elevated);
  color: var(--text-muted);
  flex-shrink: 0;
}

.habit-streak-badge.active {
  background-color: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

/* Botón Check de Hábito */
.habit-check-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-color);
  background-color: var(--bg-surface-elevated);
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-normal);
}

.habit-check-btn .icon-check {
  width: 22px;
  height: 22px;
  transition: transform var(--transition-fast);
}

.habit-check-btn:hover {
  transform: scale(1.08);
  border-color: var(--primary);
}

.habit-check-btn.checked {
  background-color: var(--success);
  border-color: var(--success);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

/* Vista Detallada de Hábito (Pestaña Hábitos) */
.habit-card.detailed {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.habit-main-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.habit-meta-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.habit-history-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}

.history-day-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.history-letter {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
}

.history-bubble {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  transition: background-color var(--transition-fast);
}

.history-bubble.done {
  background-color: var(--success);
  border-color: var(--success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.history-day-col.is-today .history-number {
  color: var(--primary);
  font-weight: 700;
}

.history-number {
  font-size: 0.68rem;
  color: var(--text-dim);
}

.habit-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.habit-best-streak {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.habit-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================
   Tarjetas de Tareas (Task Card)
   ========================================== */
.task-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  border-left-width: 4px;
}

.task-card.priority-alta {
  border-left-color: var(--danger);
}

.task-card.priority-media {
  border-left-color: var(--warning);
}

.task-card.priority-baja {
  border-left-color: var(--info);
}

.task-card.completed {
  opacity: 0.65;
  background-color: rgba(17, 24, 39, 0.4);
  border-left-color: var(--success);
}

/* Custom Checkbox */
.custom-checkbox {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  margin-top: 2px;
  user-select: none;
}

.custom-checkbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.checkbox-indicator {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border-color);
  background-color: var(--bg-surface-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all var(--transition-fast);
}

.checkbox-indicator svg {
  width: 14px;
  height: 14px;
}

.custom-checkbox input:checked ~ .checkbox-indicator {
  background-color: var(--success);
  border-color: var(--success);
  color: #ffffff;
}

.task-content {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-word;
}

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

.task-description {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
  word-break: break-word;
}

.task-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.badge-priority {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
}

.badge-priority.alta {
  background-color: var(--danger-bg);
  color: var(--danger);
}
.badge-priority.media {
  background-color: var(--warning-bg);
  color: var(--warning);
}
.badge-priority.baja {
  background-color: var(--info-bg);
  color: var(--info);
}

.category-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-elevated);
  color: var(--text-muted);
  text-transform: capitalize;
}

.badge-due {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.badge-due .badge-icon {
  width: 13px;
  height: 13px;
}

.badge-due.overdue {
  color: var(--danger);
  font-weight: 700;
}

.task-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ==========================================
   Filtros y Búsqueda de Tareas
   ========================================== */
.tasks-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.search-input-wrapper {
  position: relative;
  width: 100%;
}

.search-input-wrapper input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-input-wrapper input:focus {
  border-color: var(--primary);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-dim);
}

.filters-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.task-filter-tabs {
  display: flex;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.task-filter-tab {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.task-filter-tab .filter-count {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-elevated);
}

.task-filter-tab.active {
  background-color: var(--primary);
  color: #ffffff;
}

.task-filter-tab.active .filter-count {
  background-color: rgba(255, 255, 255, 0.25);
}

.filter-selects {
  display: flex;
  gap: 8px;
}

.filter-select {
  padding: 6px 10px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.8rem;
  outline: none;
}

/* ==========================================
   Pestaña Estadísticas y Ajustes
   ========================================== */
.stats-overview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

@media (min-width: 640px) {
  .stats-overview-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.stat-box-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 2px;
}

.stat-box-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Gráfico Semanal */
.chart-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 24px;
}

.chart-bars-wrapper {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 140px;
  padding-top: 20px;
  gap: 8px;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.chart-bar-track {
  flex: 1;
  width: 100%;
  max-width: 32px;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.chart-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  transition: height 0.4s var(--transition-smooth);
}

.chart-bar-fill.today {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
}

.bar-value {
  font-size: 0.65rem;
  font-weight: 700;
  color: #ffffff;
  margin-top: 2px;
}

.chart-day-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.chart-day-label.today {
  color: var(--success);
  font-weight: 700;
}

/* Lista de Ajustes */
.settings-group {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 24px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-info {
  display: flex;
  flex-direction: column;
}

.settings-label {
  font-size: 0.95rem;
  font-weight: 600;
}

.settings-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Switch Toggle iOS style */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 34px;
  transition: var(--transition-fast);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* ==========================================
   Botones y Controles Reutilizables
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  color: var(--text-main);
  background-color: var(--bg-surface-elevated);
}

.btn-icon.danger:hover {
  color: var(--danger);
  background-color: var(--danger-bg);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-installed {
  background-color: var(--success-bg) !important;
  color: var(--success) !important;
  border: 1px solid var(--success) !important;
  cursor: default;
}

/* Floating Action Button (FAB) */
.fab-btn {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 18px);
  right: 18px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px var(--primary-glow);
  z-index: 40;
  transition: transform var(--transition-fast);
}

.fab-btn:hover {
  transform: scale(1.08);
}

.fab-btn svg {
  width: 26px;
  height: 26px;
}

@media (min-width: 768px) {
  .fab-btn {
    bottom: 28px;
    right: 28px;
  }
}

/* ==========================================
   Navegación Inferior Móvil (Bottom Bar)
   ========================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background-color: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 45;
}

[data-theme="light"] .bottom-nav {
  background-color: rgba(255, 255, 255, 0.95);
}

.bottom-nav .nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.bottom-nav .nav-btn svg {
  width: 22px;
  height: 22px;
}

.bottom-nav .nav-btn.active {
  color: var(--primary);
}

@media (min-width: 768px) {
  .bottom-nav {
    display: none;
  }
}

/* ==========================================
   Banner de Instalación PWA (Prominente y Fluido)
   ========================================== */
.install-banner {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 12px);
  left: 14px;
  right: 14px;
  max-width: 480px;
  margin: 0 auto;
  background-color: var(--bg-surface);
  border: 1px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  z-index: 44;
  animation: slideUp 0.35s var(--transition-smooth);
}

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

@media (min-width: 768px) {
  .install-banner {
    bottom: 24px;
    left: 24px;
    margin: 0;
  }
}

.install-banner-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 10px var(--primary-glow);
}

.install-banner-text {
  flex: 1;
}

.install-banner-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.install-banner-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.install-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================
   Modales y Diálogos
   ========================================== */
.modal-wrapper {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-wrapper.active {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform var(--transition-smooth);
}

.modal-wrapper.active .modal-card {
  transform: scale(1);
}

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

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close-btn {
  font-size: 1.5rem;
  color: var(--text-muted);
  line-height: 1;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Selector de Emojis */
.emoji-picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.emoji-choice-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-elevated);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  transition: all var(--transition-fast);
}

.emoji-choice-btn.selected {
  border-color: var(--primary);
  background-color: var(--primary-light);
  transform: scale(1.1);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ==========================================
   Toasts y Notificaciones Emergentes
   ========================================== */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 12px);
  right: 16px;
  left: 16px;
  max-width: 420px;
  margin: 0 auto;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

@media (min-width: 640px) {
  .toast-container {
    left: auto;
    right: 20px;
  }
}

.toast-card {
  pointer-events: auto;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: slideDown 0.25s ease;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-fade-out {
  opacity: 0;
  transform: translateY(-8px);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-icon-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.toast-success .toast-icon-circle {
  background-color: var(--success-bg);
  color: var(--success);
}

.toast-info .toast-icon-circle {
  background-color: var(--info-bg);
  color: var(--info);
}

.toast-warning .toast-icon-circle {
  background-color: var(--warning-bg);
  color: var(--warning);
}

.toast-error .toast-icon-circle {
  background-color: var(--danger-bg);
  color: var(--danger);
}

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 0.88rem;
  font-weight: 700;
  display: block;
}

.toast-message {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.toast-close-btn {
  font-size: 1.2rem;
  color: var(--text-muted);
}

/* ==========================================
   Estados Vacíos (Empty States)
   ========================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 36px 16px;
  background-color: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  margin: 10px 0;
}

.empty-icon {
  font-size: 2.8rem;
  margin-bottom: 8px;
}

.empty-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.empty-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 340px;
  margin-bottom: 16px;
}

/* ==========================================
   Guía Modal para iOS
   ========================================== */
.ios-instruction-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 16px 0;
}

.ios-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}

.step-content {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.step-content strong {
  color: var(--text-main);
}

