/* =============================================
   IFM Timeline — Medicina Funcional
   Plugin Styles v1.0.0
   ============================================= */

:root {
  --ifm-bg: #F7F5F0;
  --ifm-bg-card: #FFFFFF;
  --ifm-bg-section: #FAFAF7;
  --ifm-text: #1A1A1A;
  --ifm-text-sec: #5A5A5A;
  --ifm-text-muted: #9A9A9A;
  --ifm-accent: #2D6A4F;
  --ifm-accent-light: #D8F3DC;
  --ifm-accent-dark: #1B4332;
  --ifm-trigger: #E07A5F;
  --ifm-trigger-light: #FFE8E0;
  --ifm-mediator: #457B9D;
  --ifm-mediator-light: #DAE9F2;
  --ifm-prenatal: #7B2D8B;
  --ifm-prenatal-light: #F0DAF5;
  --ifm-border: #E8E5DD;
  --ifm-radius: 12px;
  --ifm-radius-sm: 8px;
}

/* === WRAPPER === */
.ifm-wrap {
  font-family: 'DM Sans', sans-serif;
  color: var(--ifm-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  max-width: 820px;
  margin: 0 auto;
  padding-bottom: 40px;
}
.ifm-wrap *, .ifm-wrap *::before, .ifm-wrap *::after {
  box-sizing: border-box;
}

/* === HEADER === */
.ifm-header {
  background: linear-gradient(135deg, var(--ifm-accent-dark) 0%, var(--ifm-accent) 50%, #40916C 100%);
  color: #fff;
  padding: 40px 28px 32px;
  text-align: center;
  border-radius: var(--ifm-radius) var(--ifm-radius) 0 0;
  position: relative;
  overflow: hidden;
}
.ifm-header::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.08) 0%, transparent 50%);
}
.ifm-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.9rem;
  font-weight: 400;
  margin: 0;
  position: relative;
  color: #fff;
}
.ifm-header p {
  font-size: 0.9rem;
  opacity: 0.8;
  margin: 6px 0 0;
  font-weight: 300;
  position: relative;
}
.ifm-header .ifm-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 14px;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  font-size: 0.75rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  position: relative;
}

/* === PROGRESS === */
.ifm-progress-bar-wrap {
  background: var(--ifm-bg-card);
  border-bottom: 1px solid var(--ifm-border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.ifm-progress-track {
  flex: 1;
  height: 6px;
  background: var(--ifm-border);
  border-radius: 3px;
  overflow: hidden;
}
.ifm-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ifm-accent), #52B788);
  border-radius: 3px;
  transition: width 0.5s ease;
  width: 0%;
}
.ifm-progress-label {
  font-size: 0.8rem;
  color: var(--ifm-text-sec);
  font-weight: 500;
  white-space: nowrap;
}

/* === STEPS NAV === */
.ifm-steps-nav {
  display: flex;
  gap: 6px;
  padding: 12px 24px;
  background: var(--ifm-bg-card);
  border-bottom: 1px solid var(--ifm-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: wrap;
  justify-content: center;
}
.ifm-step-dot {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  flex-shrink: 0;
  border: 2px solid var(--ifm-border);
  background: #fff;
  color: var(--ifm-text-muted);
}
.ifm-step-dot.active {
  border-color: var(--ifm-accent);
  background: var(--ifm-accent);
  color: #fff;
  transform: scale(1.1);
}
.ifm-step-dot.completed {
  border-color: var(--ifm-accent-light);
  background: var(--ifm-accent-light);
  color: var(--ifm-accent);
}

/* === FORM CONTAINER === */
.ifm-form-container {
  padding: 24px 20px;
  background: var(--ifm-bg);
  border-radius: 0 0 var(--ifm-radius) var(--ifm-radius);
}

/* === SECTIONS === */
.ifm-section {
  display: none;
  animation: ifmFadeIn 0.4s ease;
}
.ifm-section.active { display: block; }

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

.ifm-section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.ifm-section-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--ifm-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.ifm-section-icon.green { background: var(--ifm-accent-light); }
.ifm-section-icon.orange { background: var(--ifm-trigger-light); }
.ifm-section-icon.blue { background: var(--ifm-mediator-light); }
.ifm-section-icon.purple { background: var(--ifm-prenatal-light); }

.ifm-section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  font-weight: 400;
  margin: 0;
  color: var(--ifm-text);
}
.ifm-section-subtitle {
  font-size: 0.85rem;
  color: var(--ifm-text-sec);
  margin-top: 2px;
}

/* === CARDS === */
.ifm-card {
  background: var(--ifm-bg-card);
  border-radius: var(--ifm-radius);
  padding: 24px;
  margin-bottom: 16px;
  border: 1px solid var(--ifm-border);
  transition: box-shadow 0.3s;
}
.ifm-card:hover {
  box-shadow: 0 2px 20px rgba(0,0,0,0.06);
}
.ifm-card-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--ifm-text-muted);
  font-weight: 600;
  margin-bottom: 12px;
}

/* === FORM ELEMENTS === */
.ifm-form-group {
  margin-bottom: 20px;
}
.ifm-form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 8px;
  font-size: 0.95rem;
  color: var(--ifm-text);
}
.ifm-form-group label .ifm-hint {
  display: block;
  font-weight: 300;
  font-size: 0.82rem;
  color: var(--ifm-text-muted);
  margin-top: 2px;
}

.ifm-wrap input[type="text"],
.ifm-wrap input[type="date"],
.ifm-wrap input[type="number"],
.ifm-wrap input[type="email"],
.ifm-wrap textarea,
.ifm-wrap select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--ifm-border);
  border-radius: var(--ifm-radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  background: var(--ifm-bg-section);
  transition: border-color 0.2s, box-shadow 0.2s;
  color: var(--ifm-text);
  -webkit-appearance: none;
}
.ifm-wrap input:focus,
.ifm-wrap textarea:focus,
.ifm-wrap select:focus {
  outline: none;
  border-color: var(--ifm-accent);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.1);
}
.ifm-wrap textarea {
  resize: vertical;
  min-height: 100px;
}
.ifm-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* === CHIPS === */
.ifm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.ifm-chip {
  padding: 8px 16px;
  border-radius: 24px;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1.5px solid var(--ifm-border);
  background: #fff;
  transition: all 0.2s;
  user-select: none;
  font-family: 'DM Sans', sans-serif;
  color: var(--ifm-text);
}
.ifm-chip:hover { border-color: var(--ifm-accent); }
.ifm-chip.selected {
  background: var(--ifm-accent-light);
  border-color: var(--ifm-accent);
  color: var(--ifm-accent-dark);
  font-weight: 500;
}

/* === DYNAMIC ENTRIES === */
.ifm-entry-list { margin-top: 12px; }
.ifm-entry-item {
  background: var(--ifm-bg-section);
  border: 1px solid var(--ifm-border);
  border-radius: var(--ifm-radius-sm);
  padding: 16px;
  margin-bottom: 10px;
  position: relative;
}
.ifm-entry-item .ifm-remove-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--ifm-text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.ifm-entry-item .ifm-remove-btn:hover { color: #E63946; }

.ifm-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1.5px dashed var(--ifm-accent);
  border-radius: var(--ifm-radius-sm);
  background: transparent;
  color: var(--ifm-accent);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}
.ifm-add-btn:hover { background: var(--ifm-accent-light); }

/* === NAV BUTTONS === */
.ifm-nav-buttons {
  display: flex;
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--ifm-border);
}
.ifm-btn {
  padding: 14px 28px;
  border-radius: var(--ifm-radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
.ifm-btn-primary {
  background: var(--ifm-accent);
  color: #fff;
  flex: 1;
}
.ifm-btn-primary:hover { background: var(--ifm-accent-dark); }
.ifm-btn-secondary {
  background: var(--ifm-bg-section);
  color: var(--ifm-text-sec);
  border: 1px solid var(--ifm-border);
}
.ifm-btn-secondary:hover { background: var(--ifm-border); }
.ifm-btn-generate {
  background: linear-gradient(135deg, var(--ifm-accent-dark), var(--ifm-accent));
  color: #fff;
  flex: 1;
}
.ifm-btn-generate:hover { opacity: 0.9; }

/* === RESULTS === */
.ifm-results-page { display: none; }
.ifm-results-page.active { display: block; }

.ifm-results-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--ifm-bg-card);
  border-radius: var(--ifm-radius);
  border: 1px solid var(--ifm-border);
}
.ifm-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--ifm-radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid;
  transition: all 0.2s;
  background: #fff;
}
.ifm-action-btn.download { border-color: var(--ifm-accent); color: var(--ifm-accent); }
.ifm-action-btn.download:hover { background: var(--ifm-accent-light); }
.ifm-action-btn.print { border-color: var(--ifm-mediator); color: var(--ifm-mediator); }
.ifm-action-btn.print:hover { background: var(--ifm-mediator-light); }
.ifm-action-btn.share { border-color: var(--ifm-trigger); color: var(--ifm-trigger); }
.ifm-action-btn.share:hover { background: var(--ifm-trigger-light); }
.ifm-action-btn.restart { border-color: var(--ifm-text-muted); color: var(--ifm-text-sec); }
.ifm-action-btn.restart:hover { background: var(--ifm-bg-section); }

/* === TIMELINE RESULT === */
.ifm-timeline-result {
  background: #fff;
  border-radius: var(--ifm-radius);
  overflow: hidden;
  border: 1px solid var(--ifm-border);
}
.ifm-tl-header {
  background: linear-gradient(135deg, var(--ifm-accent-dark), var(--ifm-accent));
  color: #fff;
  padding: 32px 28px 24px;
}
.ifm-tl-header h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.6rem;
  font-weight: 400;
  margin: 0;
  color: #fff;
}
.ifm-patient-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  margin-top: 14px;
  font-size: 0.85rem;
  opacity: 0.9;
}
.ifm-patient-info span { font-weight: 300; }
.ifm-patient-info strong { font-weight: 500; }

.ifm-tl-body { padding: 28px; }

/* Complaint */
.ifm-complaint-box {
  background: #FFF8F0;
  border-left: 4px solid var(--ifm-trigger);
  border-radius: 0 var(--ifm-radius-sm) var(--ifm-radius-sm) 0;
  padding: 20px;
  margin-bottom: 28px;
}
.ifm-complaint-box h4 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  color: var(--ifm-trigger);
  margin: 0 0 8px;
}
.ifm-complaint-box p {
  font-size: 0.9rem;
  color: var(--ifm-text-sec);
  line-height: 1.7;
  margin: 0;
}

/* Timeline */
.ifm-timeline {
  position: relative;
  padding-left: 40px;
}
.ifm-timeline::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--ifm-prenatal), var(--ifm-accent), var(--ifm-trigger), var(--ifm-mediator));
  border-radius: 2px;
}
.ifm-tl-event {
  position: relative;
  margin-bottom: 24px;
  padding-bottom: 4px;
}
.ifm-tl-event::before {
  content: '';
  position: absolute;
  left: -32px;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid;
  background: #fff;
}
.ifm-tl-event.type-trigger::before { border-color: var(--ifm-trigger); }
.ifm-tl-event.type-mediator::before { border-color: var(--ifm-mediator); }
.ifm-tl-event.type-antecedent::before { border-color: var(--ifm-accent); }
.ifm-tl-event.type-prenatal::before { border-color: var(--ifm-prenatal); }

.ifm-event-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ifm-text-muted);
  margin-bottom: 4px;
}
.ifm-event-cat {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 6px;
}
.ifm-cat-trigger { background: var(--ifm-trigger-light); color: var(--ifm-trigger); }
.ifm-cat-mediator { background: var(--ifm-mediator-light); color: var(--ifm-mediator); }
.ifm-cat-antecedent { background: var(--ifm-accent-light); color: var(--ifm-accent); }
.ifm-cat-prenatal { background: var(--ifm-prenatal-light); color: var(--ifm-prenatal); }

.ifm-event-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}
.ifm-event-detail {
  font-size: 0.85rem;
  color: var(--ifm-text-sec);
  line-height: 1.6;
}

/* Symptoms */
.ifm-signs-section {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 2px solid var(--ifm-border);
}
.ifm-signs-section h4 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  color: var(--ifm-mediator);
  margin: 0 0 14px;
}
.ifm-symptom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ifm-symptom-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--ifm-text-sec);
  padding: 6px 10px;
  background: var(--ifm-bg-section);
  border-radius: 6px;
}
.ifm-symptom-tag::before {
  content: '\2022';
  color: var(--ifm-mediator);
  font-weight: bold;
}

/* Family */
.ifm-family-box {
  margin-top: 20px;
  padding: 16px;
  background: #F5F5F0;
  border-radius: 8px;
}
.ifm-family-box strong {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ifm-accent-dark);
  display: block;
  margin-bottom: 6px;
}
.ifm-family-box p {
  font-size: 0.85rem;
  color: var(--ifm-text-sec);
  line-height: 1.6;
  margin: 0;
}

/* Legend */
.ifm-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--ifm-border);
}
.ifm-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--ifm-text-sec);
}
.ifm-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* Footer */
.ifm-tl-footer {
  padding: 16px 28px;
  background: var(--ifm-bg-section);
  border-top: 1px solid var(--ifm-border);
  font-size: 0.75rem;
  color: var(--ifm-text-muted);
  text-align: center;
}

/* === LOADING === */
.ifm-loading {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(247,245,240,0.95);
  z-index: 99999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.ifm-loading.active { display: flex; }
.ifm-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--ifm-border);
  border-top-color: var(--ifm-accent);
  border-radius: 50%;
  animation: ifmSpin 0.8s linear infinite;
}
@keyframes ifmSpin { to { transform: rotate(360deg); } }

/* === PRINT === */
@media print {
  .ifm-header, .ifm-progress-bar-wrap, .ifm-steps-nav,
  .ifm-results-actions, .ifm-nav-buttons, .ifm-form-container { display: none !important; }
  .ifm-results-page { display: block !important; }
  .ifm-timeline-result { border: none; box-shadow: none; }
  .ifm-tl-header { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* === RESPONSIVE === */
@media (max-width: 600px) {
  .ifm-header h2 { font-size: 1.4rem; }
  .ifm-form-container { padding: 16px 12px; }
  .ifm-card { padding: 18px; }
  .ifm-grid-2 { grid-template-columns: 1fr; }
  .ifm-symptom-grid { grid-template-columns: 1fr; }
  .ifm-patient-info { grid-template-columns: 1fr; }
  .ifm-results-actions { flex-direction: column; }
}
