/* Estilos de Agenda Visual y Secuenciador de Rutinas - Fijate Tools */

:root {
  --bg-app: #0a0f1d;
  --bg-card: #131b2e;
  --bg-card-secondary: #1a253c;
  --bg-card-hover: #233252;
  --border-color: #273756;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-color: #0ea5e9;
  --accent-hover: #0284c7;
  --accent-glow: rgba(14, 165, 233, 0.2);
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-secondary: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --border-color: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --accent-color: #0284c7;
  --accent-hover: #0369a1;
  --accent-glow: rgba(2, 132, 199, 0.15);
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

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

body {
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
}

/* Reglas móviles canónicas para desplegables e inputs */
select, .form-control {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

select {
  background-color: var(--bg-card-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem 2.5rem 0.6rem 0.85rem;
  font-size: 0.9rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  cursor: pointer;
}

select option, select optgroup {
  background-color: var(--bg-card);
  color: var(--text-main);
}

/* Layout */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

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

/* Tarjeta Principal */
.card-main {
  max-width: 860px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 2rem;
  margin-bottom: 2rem;
}

/* Barra superior de configuración de rutina */
.routine-top-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.input-text-dark {
  width: 100%;
  min-height: 42px;
  background: var(--bg-card-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 600;
}

.input-text-dark:focus {
  outline: none;
  border-color: var(--accent-color);
}

/* Selector de vista interactiva vs lista */
.view-tabs-bar {
  display: flex;
  background: var(--bg-card-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.35rem;
  gap: 0.4rem;
  margin-bottom: 1.75rem;
}

.btn-tab-view {
  flex: 1;
  min-height: 42px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn-tab-view.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* MODO INTERACTIVO (Paso a paso) */
.step-interactive-card {
  text-align: center;
  padding: 1rem 0;
}

.step-progress-wrapper {
  margin-bottom: 1.5rem;
}

.step-progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.step-progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg-card-secondary);
  border-radius: 4px;
  overflow: hidden;
}

.step-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-color), #38bdf8);
  width: 0%;
  transition: width 0.3s ease;
}

/* Caja de pictograma grande */
.interactive-picto-container {
  width: 160px;
  height: 160px;
  margin: 0 auto 1.5rem;
  background: var(--bg-card-secondary);
  border: 3px solid var(--accent-color);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px var(--accent-glow);
}

.interactive-picto-container svg {
  width: 96px;
  height: 96px;
  stroke: var(--accent-color);
}

.interactive-step-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-main);
}

/* Temporizador */
.interactive-timer-box {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 1.25rem;
  margin-bottom: 2rem;
}

.timer-digits {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-color);
}

.btn-timer-action {
  min-height: 36px;
  padding: 0 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

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

/* Botón gigante ¡Hecho! */
.btn-huge-done {
  width: 100%;
  max-width: 480px;
  margin: 0 auto 1.5rem;
  min-height: 60px;
  background: var(--accent-color);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
  transition: all 0.2s ease;
}

.btn-huge-done:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.btn-huge-done.is-done {
  background: var(--color-success);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Navegación paso a paso */
.interactive-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 480px;
  margin: 0 auto;
}

.next-step-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

/* MODO LISTA */
.list-view-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  transition: background 0.15s ease;
}

.task-row.is-completed {
  opacity: 0.65;
  border-color: rgba(16, 185, 129, 0.4);
}

.task-row.is-completed .task-name {
  text-decoration: line-through;
}

.btn-task-checkbox {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
  color: #ffffff;
}

.btn-task-checkbox.checked {
  background: var(--color-success);
  border-color: var(--color-success);
}

.task-picto-mini {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.task-picto-mini svg {
  width: 24px;
  height: 24px;
  stroke: var(--accent-color);
}

.task-info-box {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.task-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.task-row-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.btn-icon-row {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-icon-row:hover:not(:disabled) {
  color: var(--text-main);
  border-color: var(--accent-color);
}

.btn-icon-row:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Botones inferiores de acción */
.bottom-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.btn-primary {
  min-height: 42px;
  padding: 0 1.25rem;
  background: var(--accent-color);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.15s ease;
}

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

.btn-secondary {
  min-height: 40px;
  padding: 0 1rem;
  background: var(--bg-card-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

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

/* Cuadrícula de selección de pictogramas en Modal */
.picto-select-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  max-height: 260px;
  overflow-y: auto;
  margin: 1rem 0;
  padding: 0.5rem;
  background: var(--bg-card-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.picto-select-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.picto-select-item:hover {
  border-color: var(--accent-color);
}

.picto-select-item.selected {
  border-color: var(--accent-color);
  background: var(--accent-glow);
}

.picto-thumb svg {
  width: 28px;
  height: 28px;
  stroke: var(--accent-color);
}

.picto-label {
  font-size: 0.68rem;
  color: var(--text-main);
  text-align: center;
  line-height: 1.2;
}

/* Ventanas modales */
.custom-modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.custom-modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  padding: 1.75rem;
}

.custom-modal-card h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Responsividad móvil */
@media (max-width: 768px) {
  .routine-top-toolbar {
    grid-template-columns: 1fr;
  }

  .interactive-picto-container {
    width: 130px;
    height: 130px;
  }

  .interactive-picto-container svg {
    width: 72px;
    height: 72px;
  }

  .interactive-step-title {
    font-size: 1.4rem;
  }

  .picto-select-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .bottom-actions-bar {
    flex-direction: column;
  }

  .bottom-actions-bar button {
    width: 100%;
  }
}

/* Estilos de impresión para tarjetas recortables físicas (PDF / Impresora) */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .app-header,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .fijate-footer,
  .routine-top-toolbar,
  .view-tabs-bar,
  .bottom-actions-bar,
  .interactive-nav-bar,
  .interactive-timer-box,
  .btn-huge-done,
  .step-progress-wrapper,
  .task-row-actions,
  .custom-modal-backdrop {
    display: none !important;
  }

  .tool-layout {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .card-main {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  #interactive-step-view {
    display: none !important;
  }

  #list-sequence-view {
    display: block !important;
  }

  /* Formato de tarjetas recortables */
  .list-view-container {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 15px !important;
  }

  .task-row {
    flex-direction: column !important;
    text-align: center !important;
    border: 2px dashed #64748b !important;
    border-radius: 10px !important;
    padding: 15px !important;
    break-inside: avoid;
    background: #ffffff !important;
  }

  .task-picto-mini {
    width: 70px !important;
    height: 70px !important;
    border: none !important;
  }

  .task-picto-mini svg {
    width: 50px !important;
    height: 50px !important;
    stroke: #0284c7 !important;
  }

  .task-name {
    font-size: 1rem !important;
    color: #000000 !important;
    white-space: normal !important;
    margin-top: 8px !important;
  }

  .task-meta {
    color: #475569 !important;
    font-size: 0.8rem !important;
  }

  .btn-task-checkbox {
    border: 2px solid #000000 !important;
    background: #ffffff !important;
  }
}
