/* ============================================
   CREAIMPRIME — CSS HERRAMIENTA (editor + preview)
   Reutilizable por planificador-semanal, horario-semanal, planificador-diario
   ============================================ */

.tool-hero {
  text-align: center;
  padding: 56px 0 32px;
}
.tool-hero h1 {
  font-size: 2.1rem;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.tool-hero p {
  color: var(--color-ink-soft);
  font-size: 1.05rem;
  max-width: 560px;
  margin: 0 auto;
}
.tool-hero-preview {
  display: block;
  max-width: 320px;
  width: 100%;
  height: auto;
  margin: 24px auto 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.tool-workspace {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 32px;
  align-items: start;
  margin-bottom: 24px;
}

/* ---------- EDITOR PANEL ---------- */
.editor-panel {
  background: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: sticky;
  top: 88px;
}
.editor-group { margin-bottom: 22px; }
.editor-group:last-child { margin-bottom: 0; }
.editor-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-ink);
}
.editor-group input[type="text"],
.editor-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 0.9rem;
}
.editor-group input[type="text"]:focus,
.editor-group select:focus {
  outline: none;
  border-color: var(--color-primary);
}

.segmented {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.segmented button {
  flex: 1;
  padding: 8px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  background: white;
  color: var(--color-ink-soft);
  transition: all .15s;
}
.segmented button.active {
  background: var(--color-primary);
  color: white;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.9rem;
}
.switch {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--color-border);
  border-radius: 999px;
  transition: background .15s;
  flex-shrink: 0;
}
.switch.on { background: var(--color-primary); }
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform .15s;
}
.switch.on::after { transform: translateX(18px); }

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.template-option {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  background: white;
  transition: all .15s;
}
.template-option .swatch {
  height: 36px;
  border-radius: 4px;
  margin-bottom: 6px;
}
.template-option.active {
  border-color: var(--color-primary);
  background: #eff6ff;
}

.color-row { display: flex; gap: 10px; }
.color-swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.color-swatch.active { border-color: var(--color-ink); }

.export-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
}
.export-buttons .btn { justify-content: center; width: 100%; }

/* ---------- PREVIEW PANEL ---------- */
.preview-panel {
  display: flex;
  justify-content: center;
}
.preview-frame {
  background: #e8edf3;
  border-radius: var(--radius-lg);
  padding: 32px;
  display: flex;
  justify-content: center;
  width: 100%;
}
#printable-canvas {
  background: white;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 794px; /* A4 @ 96dpi */
  min-height: 1123px;
  padding: 48px;
}

/* ---------- PLANIFICADOR SEMANAL: estructura de grid ---------- */
.planner-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 24px;
  letter-spacing: -0.01em;
}
.planner-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.planner-grid.vertical { grid-template-columns: 1fr; }
.planner-day {
  border-radius: 8px;
  padding: 12px;
  min-height: 160px;
}
.planner-day .day-name {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.planner-extra {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.planner-extra .extra-box {
  border-radius: 8px;
  padding: 12px;
  min-height: 80px;
}
.planner-extra .extra-box .extra-title {
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 6px;
  text-transform: uppercase;
}

/* Plantilla: minimalista */
.tpl-minimal .planner-day { background: #fff; border: 1px solid #e2e8f0; }
.tpl-minimal .day-name { color: #1e293b; }

/* Plantilla: colorido */
.tpl-colorful .planner-day { background: #eef2ff; }
.tpl-colorful .day-name { color: #4338ca; }

/* Plantilla: profesional */
.tpl-professional .planner-day { background: #f8fafc; border-left: 3px solid #334155; }
.tpl-professional .day-name { color: #334155; }

/* Plantilla: aesthetic */
.tpl-aesthetic .planner-day { background: #fdf4ff; border: 1px solid #f3e8ff; }
.tpl-aesthetic .day-name { color: #a21caf; font-style: italic; }

/* ---------- HORARIO SEMANAL: tabla horaria ---------- */
.schedule-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.schedule-table th, .schedule-table td {
  border: 1px solid #e2e8f0;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
.schedule-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
  text-align: center;
}
.schedule-table .hour-col {
  width: 64px;
  font-size: 0.7rem;
  color: #94a3b8;
  text-align: center;
  white-space: nowrap;
}
.schedule-table td.block {
  min-width: 90px;
  height: 34px;
  cursor: text;
  outline: none;
}
.schedule-table td.block:focus {
  box-shadow: inset 0 0 0 2px var(--accent, #2563eb);
}
.schedule-table.horizontal-orientation { writing-mode: horizontal-tb; }

/* Plantillas para horario reutilizan las mismas clases tpl-* */
.tpl-minimal .schedule-table th { background: #f8fafc; color: #1e293b; }
.tpl-colorful .schedule-table th { background: #eef2ff; color: #4338ca; }
.tpl-professional .schedule-table th { background: #334155; color: #fff; }
.tpl-aesthetic .schedule-table th { background: #fdf4ff; color: #a21caf; font-style: italic; }

/* ---------- PLANIFICADOR DIARIO ---------- */
.daily-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}
.daily-title.has-date { margin-bottom: 4px; }
.daily-date {
  font-size: 0.95rem;
  color: #64748b;
  margin-bottom: 20px;
}
.daily-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.daily-block {
  border-radius: 8px;
  padding: 14px;
}
.daily-block .block-title {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
}
.daily-block.full-width { grid-column: 1 / -1; }

.daily-hours { display: flex; flex-direction: column; gap: 4px; }
.daily-hours .hour-row {
  display: flex;
  gap: 8px;
  font-size: 0.78rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding: 4px 0;
}
.daily-hours .hour-row .hour-label { width: 48px; color: #94a3b8; flex-shrink: 0; }

.priority-list { list-style: none; }
.priority-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  padding: 5px 0;
  line-height: 1.3;
}
.priority-list .priority-num {
  color: var(--accent, #2563eb);
  flex-shrink: 0;
  display: block;
}
.priority-list .priority-text { flex: 1; }

.task-list { list-style: none; }
.task-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  padding: 5px 0;
  line-height: 1.3;
}
.task-checkbox {
  width: 16px; height: 16px;
  border: 2px solid #94a3b8;
  border-radius: 4px;
  flex-shrink: 0;
  cursor: pointer;
}
.task-checkbox.checked {
  background: var(--accent, #2563eb);
  border-color: var(--accent, #2563eb);
  position: relative;
}
.task-checkbox.checked::after {
  content: '\2713';
  position: absolute;
  color: white;
  font-size: 11px;
  font-weight: 700;
  top: 50%; left: 50%;
  transform: translate(-50%, -55%);
}
.task-list .task-text { flex: 1; }

.notes-area { min-height: 70px; font-size: 0.85rem; }
.goal-text { font-size: 0.9rem; font-style: italic; }

.tpl-minimal .daily-block { background: #fff; border: 1px solid #e2e8f0; }
.tpl-colorful .daily-block { background: #eef2ff; }
.tpl-professional .daily-block { background: #f8fafc; border-left: 3px solid #334155; }
.tpl-aesthetic .daily-block { background: #fdf4ff; border: 1px solid #f3e8ff; }

/* ---------- HABIT TRACKER ---------- */
.habit-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.habit-subtitle {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 20px;
}
.habit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.68rem;
}
.habit-table th, .habit-table td {
  border: 1px solid #e2e8f0;
  text-align: center;
  padding: 3px 2px;
}
.habit-table th {
  font-weight: 700;
  color: #64748b;
}
.habit-table .habit-name-col {
  text-align: left;
  padding-left: 8px;
  font-weight: 600;
  font-size: 0.72rem;
  min-width: 110px;
  white-space: nowrap;
}
.habit-table .habit-day-cell {
  width: 22px;
  height: 22px;
  cursor: pointer;
  user-select: none;
}
.habit-table .habit-day-cell.checked {
  background: var(--accent, #2563eb);
  color: white;
  font-weight: 700;
}
.habit-table .habit-day-cell.checked::after { content: '\2713'; }

.tpl-minimal .habit-table th { background: #f8fafc; }
.tpl-colorful .habit-table th { background: #eef2ff; color: #4338ca; }
.tpl-professional .habit-table th { background: #334155; color: #fff; }
.tpl-aesthetic .habit-table th { background: #fdf4ff; color: #a21caf; }

/* ---------- LISTA DE LA COMPRA ---------- */
.shopping-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.shopping-subtitle {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 20px;
}
.shopping-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.shopping-category {
  border-radius: 8px;
  padding: 14px;
}
.shopping-category .block-title {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
}
.shopping-item-list { list-style: none; }
.shopping-item-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  padding: 4px 0;
  line-height: 1.3;
}
.shopping-checkbox {
  width: 14px; height: 14px;
  border: 2px solid #94a3b8;
  border-radius: 4px;
  flex-shrink: 0;
}

.tpl-minimal .shopping-category { background: #fff; border: 1px solid #e2e8f0; }
.tpl-colorful .shopping-category { background: #eef2ff; }
.tpl-professional .shopping-category { background: #f8fafc; border-left: 3px solid #334155; }
.tpl-aesthetic .shopping-category { background: #fdf4ff; border: 1px solid #f3e8ff; }

/* ---------- DIARIO DE GRATITUD ---------- */
.gratitude-days {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.gratitude-day {
  border-radius: 10px;
  padding: 18px 20px;
}
.gratitude-day-num {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 10px;
}
.gratitude-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 10px 0 8px;
}
.gratitude-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  color: #64748b;
}
.gratitude-fill {
  flex: 1;
  border-bottom: 1px solid #cbd5e1;
  height: 16px;
}
.gratitude-affirmation {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #e2e8f0;
  font-style: italic;
  font-size: 0.85rem;
  color: #64748b;
}

.tpl-minimal .gratitude-day { background: #fff; border: 1px solid #e2e8f0; }
.tpl-colorful .gratitude-day { background: #eef2ff; }
.tpl-professional .gratitude-day { background: #f8fafc; border-left: 3px solid #334155; }
.tpl-aesthetic .gratitude-day { background: #fdf4ff; border: 1px solid #f3e8ff; }

.editor-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
  min-height: 70px;
}
.editor-group textarea:focus { outline: none; border-color: var(--color-primary); }

/* ---------- PLAN DE COMIDAS ---------- */
.meals-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}
.meals-table { font-size: 0.75rem; }
.meals-table .meal-col { width: 90px; font-weight: 700; text-transform: uppercase; font-size: 0.68rem; color: #64748b; }

.tpl-minimal .meals-table th { background: #f8fafc; color: #1e293b; }
.tpl-colorful .meals-table th { background: #eef2ff; color: #4338ca; }
.tpl-professional .meals-table th { background: #334155; color: #fff; }
.tpl-aesthetic .meals-table th { background: #fdf4ff; color: #a21caf; font-style: italic; }

/* ---------- CONTROL DE GASTOS ---------- */
.budget-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.budget-subtitle {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 20px;
}
.budget-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.budget-summary .summary-box {
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.budget-summary .summary-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748b;
  margin-bottom: 6px;
}
.budget-summary .summary-value { font-size: 1.15rem; font-weight: 700; }
.budget-summary .summary-value.positive { color: #16a34a; }
.budget-summary .summary-value.negative { color: #dc2626; }

.budget-section { margin-bottom: 20px; }
.budget-section .block-title {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
}
.budget-list { list-style: none; }
.budget-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.budget-list .budget-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.budget-list .budget-name { flex: 1; }
.budget-list .budget-amount { font-weight: 600; white-space: nowrap; }

.tpl-minimal .budget-summary .summary-box, .tpl-minimal .budget-section { background: #fff; border: 1px solid #e2e8f0; }
.tpl-professional .budget-summary .summary-box, .tpl-professional .budget-section { background: #f8fafc; border-left: 3px solid #334155; }
.tpl-aesthetic .budget-summary .summary-box, .tpl-aesthetic .budget-section { background: #fdf4ff; border: 1px solid #f3e8ff; }
.tpl-colorful .budget-summary .summary-box, .tpl-colorful .budget-section { background: #eef2ff; }

.editor-group .amount-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.editor-group .amount-row input[type="text"] { flex: 1; }
.editor-group .amount-row input[type="number"] { width: 80px; padding: 10px 8px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 0.9rem; }

@media (max-width: 900px) {
  .shopping-grid { grid-template-columns: 1fr; }
  .budget-summary { grid-template-columns: 1fr; }
  .tool-workspace { grid-template-columns: 1fr; }
  .editor-panel { position: static; order: 2; }
  .preview-panel { order: 1; }
  .planner-grid { grid-template-columns: 1fr 1fr; }
  .planner-extra { grid-template-columns: 1fr; }
  .schedule-table { font-size: 0.68rem; }
  .daily-grid { grid-template-columns: 1fr; }
  .habit-table { font-size: 0.62rem; }
}

/* ---------- HORARIO ESCOLAR ---------- */
.school-info-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: #64748b;
  margin-bottom: 16px;
}
.school-info-row span { display: inline-block; }
.school-info-row span strong { color: #1e293b; margin-right: 4px; }

.school-table td.block.has-subject {
  font-weight: 600;
  font-size: 0.75rem;
}

.tpl-infantil .schedule-table th { background: #fef3c7; color: #92400e; font-family: 'Comic Sans MS', 'Segoe Print', cursive, sans-serif; }
.tpl-infantil .school-info-row strong { color: #92400e; }
.tpl-estudiante .schedule-table th { background: #1e293b; color: #f1f5f9; letter-spacing: 0.05em; }

/* ---------- CALENDARIO MENSUAL ---------- */
.calendar-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar-grid.orientation-vertical { grid-template-columns: 1fr; }
.calendar-weekday-header {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748b;
  padding-bottom: 4px;
}
.calendar-day-cell {
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  min-height: 76px;
  padding: 6px;
  position: relative;
}
.calendar-day-cell.empty { border: none; background: transparent; }
.calendar-day-cell .day-number {
  font-size: 0.78rem;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 4px;
}
.calendar-day-cell .day-event {
  font-size: 0.65rem;
  line-height: 1.3;
  outline: none;
  min-height: 24px;
  word-break: break-word;
}
.calendar-day-cell .day-event:focus { box-shadow: inset 0 0 0 1px var(--accent, #2563eb); border-radius: 3px; }

.calendar-notes {
  margin-top: 20px;
  border-radius: 8px;
  padding: 14px;
}
.calendar-notes .block-title {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}
.calendar-notes .notes-area { min-height: 60px; }

.tpl-minimal .calendar-day-cell { background: #fff; }
.tpl-minimal .calendar-notes { background: #f8fafc; border: 1px solid #e2e8f0; }
.tpl-colorful .calendar-day-cell { background: #eef2ff; border-color: #c7d2fe; }
.tpl-colorful .calendar-notes { background: #eef2ff; }
.tpl-professional .calendar-day-cell { background: #f8fafc; border-left: 2px solid #334155; }
.tpl-professional .calendar-notes { background: #f8fafc; border-left: 3px solid #334155; }
.tpl-aesthetic .calendar-day-cell { background: #fdf4ff; border-color: #f3e8ff; }
.tpl-aesthetic .calendar-notes { background: #fdf4ff; border: 1px solid #f3e8ff; }

/* ---------- PLANIFICADOR DE ESTUDIO ---------- */
.study-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}
.study-section {
  margin-bottom: 20px;
}
.study-section .block-title {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
}

.exam-list { list-style: none; }
.exam-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.exam-list .exam-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.exam-list .exam-name { font-weight: 600; flex: 1; }
.exam-list .exam-subject { color: #64748b; font-size: 0.78rem; }
.exam-list .exam-date { color: #64748b; font-size: 0.78rem; white-space: nowrap; }

.study-week-table {
  font-size: 0.7rem;
}
.study-week-table .hour-col { width: 52px; }

.tpl-minimal .study-section { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; }
.tpl-professional .study-section { background: #f8fafc; border-left: 3px solid #334155; border-radius: 8px; padding: 14px; }
.tpl-aesthetic .study-section { background: #fdf4ff; border: 1px solid #f3e8ff; border-radius: 8px; padding: 14px; }
.tpl-estudiante .study-section { background: #1e293b0d; border: 1px solid #1e293b22; border-radius: 8px; padding: 14px; }
.tpl-estudiante .study-week-table th { background: #1e293b; color: #f1f5f9; }
