/* ========================================
   FitFinder - Modern Fitness UI
   Diseño limpio, profesional y responsive
   ======================================== */
:root {
    --primary: #ff6b35;
    --primary-dark: #e85a2b;
    --primary-light: #ff8c5a;
    --secondary: #2563eb;
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-input: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --font-main: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --transition: all 0.2s ease-in-out;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font-main); background: var(--bg-body); color: var(--text-main); line-height: 1.6; min-height: 100vh; -webkit-font-smoothing: antialiased; }

header { background: var(--bg-surface); padding: 1.5rem 1rem; text-align: center; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow-sm); }
header h1 { font-size: 1.8rem; font-weight: 800; color: var(--text-main); margin-bottom: 0.2rem; letter-spacing: -0.5px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.subtitle { font-size: 1rem; color: var(--text-muted); font-weight: 400; max-width: 500px; margin: 0 auto; }
.container { max-width: 720px; margin: 0 auto; padding: 2rem 1.5rem 3rem; }

.routine-form { background: var(--bg-surface); padding: 2rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: grid; gap: 1.5rem; border: 1px solid var(--border); }
.form-label { display: flex; flex-direction: column; gap: 0.5rem; font-weight: 600; color: var(--text-main); font-size: 0.95rem; }
.form-label span { display: flex; align-items: center; gap: 0.3rem; }
.form-label small { font-weight: 400; color: var(--text-muted); font-size: 0.85rem; margin-left: auto; }
.required { color: var(--primary); }

select, input[type="text"], input[type="number"], textarea { padding: 0.85rem 1rem; border: 2px solid var(--bg-input); border-radius: var(--radius-md); font-size: 1rem; background: var(--bg-input); color: var(--text-main); transition: var(--transition); font-family: inherit; width: 100%; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.1); }
textarea { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.8rem; margin-top: 0.5rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.6rem; font-weight: 500; font-size: 0.9rem; cursor: pointer; padding: 0.6rem 0.8rem; background: var(--bg-input); border: 2px solid transparent; border-radius: var(--radius-md); transition: var(--transition); color: var(--text-main); }
.checkbox-label:hover { background: #e2e8f0; }
.checkbox-label:has(input:checked) { background: rgba(255, 107, 53, 0.1); border-color: var(--primary); color: var(--primary-dark); }
.checkbox-label input[type="checkbox"] { accent-color: var(--primary); width: 18px; height: 18px; cursor: pointer; }
.custom-input { background: #fff !important; border: 2px dashed var(--primary) !important; font-weight: 500; }

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; padding: 1rem; border: none; border-radius: var(--radius-full); font-size: 1.1rem; font-weight: 700; cursor: pointer; transition: var(--transition); margin-top: 0.5rem; box-shadow: 0 4px 14px rgba(255, 107, 53, 0.4); width: 100%; text-transform: uppercase; letter-spacing: 0.5px; }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(255, 107, 53, 0.6); }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--secondary); color: white; padding: 0.7rem 1.2rem; border-radius: var(--radius-full); cursor: pointer; font-weight: 600; border: none; transition: var(--transition); }
.btn-secondary:hover { background: #1d4ed8; transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--secondary); border: 2px solid var(--secondary); padding: 0.7rem 1.2rem; border-radius: var(--radius-full); cursor: pointer; font-weight: 600; transition: var(--transition); }
.btn-outline:hover { background: rgba(37, 99, 235, 0.05); }
.form-hint { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-top: -0.5rem; }

.result-section { margin-top: 2.5rem; }
.routine-card { background: var(--bg-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 2rem; border: 1px solid var(--border); animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.routine-header { border-bottom: 2px solid var(--bg-body); padding-bottom: 1.2rem; margin-bottom: 1.5rem; text-align: center; }
.routine-header h2 { font-size: 1.6rem; color: var(--text-main); margin-bottom: 0.4rem; }
.routine-meta { color: var(--text-muted); font-size: 0.9rem; }

.exercises-list { list-style: none; display: grid; gap: 1.2rem; }
.exercise-item { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.2rem; transition: var(--transition); border-left: 4px solid var(--primary); }
.exercise-item:hover { box-shadow: var(--shadow-md); transform: translateX(4px); border-color: var(--primary); }
.exercise-header { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.exercise-number { background: var(--primary); color: white; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem; flex-shrink: 0; }
.exercise-header h3 { flex: 1; font-size: 1.15rem; color: var(--text-main); font-weight: 700; }
.badge { padding: 0.3rem 0.7rem; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-warmup { background: #fef3c7; color: #d97706; }
.badge-strength { background: #dbeafe; color: #2563eb; }
.badge-cardio { background: #fee2e2; color: #dc2626; }
.badge-cooling { background: #d1fae5; color: #059669; }

.exercise-description { margin: 0.6rem 0; color: var(--text-main); line-height: 1.6; opacity: 0.9; font-size: 0.95rem; }
.exercise-details { display: flex; gap: 1rem; margin: 0.8rem 0; font-size: 0.9rem; color: var(--text-muted); font-weight: 500; flex-wrap: wrap; }
.exercise-details span { display: flex; align-items: center; gap: 4px; background: var(--bg-body); padding: 4px 10px; border-radius: var(--radius-sm); }
.exercise-equipment, .exercise-tips { margin: 0.6rem 0 0; color: var(--text-muted); font-size: 0.85rem; }
.exercise-tips { background: #f8fafc; padding: 0.8rem; border-radius: var(--radius-sm); margin-top: 0.8rem; }
.exercise-tips li { margin: 0.3rem 0; list-style: none; padding-left: 1.4rem; position: relative; }
.exercise-tips li::before { content: '✨'; position: absolute; left: 0; }

.routine-footer { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); text-align: center; }
.affiliate-disclosure { background: #fffbeb; border-left: 4px solid var(--warning); padding: 1rem; margin-bottom: 1.2rem; font-size: 0.85rem; color: #92400e; text-align: left; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.routine-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }

.error-card { background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius-md); padding: 1.5rem; text-align: center; color: #991b1b; }
.error-card h3 { font-weight: 700; margin-bottom: 0.5rem; }
.error-card .btn-outline { margin-top: 1rem; border-color: #ef4444; color: #ef4444; }

.disclaimer { background: #fffbeb; border: 1px solid #fcd34d; border-radius: var(--radius-md); padding: 1.2rem; margin: 2rem 0; font-size: 0.9rem; color: #92400e; line-height: 1.5; text-align: center; }
.links { text-align: center; padding: 2rem 0 1rem; border-top: 1px solid var(--border); margin-top: 2rem; display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap; }
.links a { color: var(--secondary); text-decoration: none; font-weight: 600; transition: var(--transition); font-size: 0.95rem; }
.links a:hover { color: var(--primary); text-decoration: underline; }
footer { text-align: center; padding: 2rem 1rem; color: var(--text-muted); font-size: 0.85rem; border-top: 1px solid var(--border); margin-top: auto; background: #fff; }
footer a { color: var(--secondary); text-decoration: none; }

@media (max-width: 680px) { .form-row { grid-template-columns: 1fr; } .checkbox-grid { grid-template-columns: 1fr 1fr; } .routine-form { padding: 1.5rem; } header h1 { font-size: 1.5rem; } .routine-actions { flex-direction: column; width: 100%; } .btn-secondary, .btn-outline { width: 100%; } }
@media (max-width: 480px) { .exercise-header { flex-direction: column; align-items: flex-start; } .exercise-details { flex-direction: column; align-items: flex-start; gap: 0.5rem; } .checkbox-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ========================================
   🖨️ PDF / IMPRESIÓN PROFESIONAL
   ======================================== */
@media print {
    * { background: transparent !important; color: #000 !important; box-shadow: none !important; text-shadow: none !important; }
    body { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 10.5pt; line-height: 1.35; margin: 0; padding: 0; }
    header, footer, .links, form, button, .btn-primary, .btn-secondary, .btn-outline, .form-hint, .disclaimer, .affiliate-disclosure, .routine-actions, nav, .checkbox-grid, .form-row, .result-section[style*="display: none"] { display: none !important; }
    .container { max-width: 100%; margin: 0; padding: 0 5mm; }
    .routine-form { display: none !important; }
    .result-section { display: block !important; margin: 0; }
    .routine-card { background: white !important; border: none !important; padding: 0 !important; box-shadow: none !important; position: relative; page-break-inside: avoid; }
    .routine-card::before { content: "🏋️ FitFinder - " attr(data-doc-type); display: block; font-size: 16pt; font-weight: 800; text-align: center; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 2px solid #000; letter-spacing: -0.5px; }
    .routine-card::after { content: "Generado: " attr(data-date) " | " attr(data-url) " | Documento orientativo"; display: block; font-size: 8pt; color: #555; text-align: center; margin-top: 20px; padding-top: 6px; border-top: 1px solid #ccc; }
    .routine-header { display: none !important; }
    .exercises-list { list-style: none; padding: 0; margin: 0; }
    .exercise-item { background: white !important; border: none !important; border-left: none !important; padding: 10px 0 !important; margin-bottom: 14px !important; page-break-inside: avoid; border-bottom: 1px dashed #bbb; }
    .exercise-header { flex-wrap: nowrap; gap: 12px; margin-bottom: 4px; }
    .exercise-number { background: #eee !important; color: #000 !important; border: 1px solid #888; width: 22px; height: 22px; font-size: 9pt; border-radius: 50%; }
    .exercise-header h3 { font-size: 11.5pt; font-weight: 700; margin: 0; }
    .badge { display: inline-block; padding: 2px 8px; border: 1px solid #666; border-radius: 12px; font-size: 7.5pt; font-weight: 600; color: #000 !important; background: #f0f0f0 !important; margin-left: auto; text-transform: uppercase; }
    .exercise-description { font-size: 9.5pt; margin: 4px 0; color: #222 !important; }
    .exercise-details { display: flex; gap: 12px; font-size: 9pt; color: #444 !important; margin: 4px 0; flex-wrap: wrap; }
    .exercise-details span { background: transparent !important; padding: 0; font-weight: 500; }
    .exercise-tips { background: transparent !important; padding: 4px 0 0 16px; font-size: 8.5pt; color: #555 !important; margin-top: 4px; }
    .exercise-tips li { margin: 2px 0; list-style: none; position: relative; }
    .exercise-tips li::before { content: "• "; font-weight: bold; }
    
    /* Nutrición */
    .meal { background: white !important; border: none !important; padding: 10px 0 !important; margin-bottom: 14px !important; page-break-inside: avoid; border-bottom: 1px dashed #bbb; }
    .macros { display: flex; gap: 10px; font-size: 8.5pt; color: #333 !important; margin: 4px 0; flex-wrap: wrap; }
    .tag { background: #f5f5f5 !important; border: 1px solid #ccc; padding: 2px 6px; border-radius: 8px; }
    .totals { background: #f9fafb !important; border: 1px solid #ddd; padding: 8px; border-radius: 6px; margin-top: 10px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; font-size: 9pt; }
    @page { size: A4; margin: 1.8cm 1.5cm; }
    h2, h3, h4 { page-break-after: avoid; }
}
/* Autocomplete dropdown - compatible con grid/flex */
.ff-city-dd {
  position: fixed !important;
  z-index: 9999 !important;
  background: #fff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 8px !important;
  padding: 4px 0 !important;
  list-style: none !important;
  max-height: 200px !important;
  overflow-y: auto !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important;
  font-size: 0.9rem !important;
  min-width: 200px !important;
  max-width: 400px !important;
}
.ff-city-dd li {
  padding: 9px 12px !important;
  cursor: pointer !important;
  transition: background 0.15s !important;
  border-radius: 4px !important;
  margin: 0 4px !important;
}
.ff-city-dd li:hover,
.ff-city-dd li.active {
  background: #f1f5f9 !important;
}
.ff-city-dd mark {
  background: #dbeafe !important;
  color: #1e40af !important;
  padding: 0 2px !important;
  border-radius: 3px !important;
  font-weight: 600 !important;
}
/* Contacto - FitFinder */
.contact-form { max-width: 500px; margin: 2rem auto; background: #fff; padding: 2rem; border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.contact-form .form-label { margin-bottom: 1rem; }
.contact-form textarea { min-height: 120px; resize: vertical; }
.contact-form .btn-primary { margin-top: 1rem; }
.form-hint { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }
.success-msg { background: #dcfce7; color: #166534; padding: 1rem; border-radius: 8px; margin-bottom: 1rem; border-left: 4px solid #16a34a; }
.error-msg { background: #fef2f2; color: #dc2626; padding: 1rem; border-radius: 8px; margin-bottom: 1rem; border-left: 4px solid #dc2626; }
.hp-field { position: absolute; left: -9999px; top: -9999px; visibility: hidden; }