/**
 * Estilos canónicos para la Calculadora de horas frío y acumulación térmica para frutales
 * Diseño Midnight Slate prémium, responsive, temas claro/oscuro y print
 */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta oscura Midnight Slate */
  --bg-page: #0b0f17;
  --bg-card: #111827;
  --bg-card-sub: #162032;
  --bg-card-hover: #1e293b;
  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: #3b82f6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-sub: #64748b;

  --primary: #10b981;
  --primary-hover: #059669;
  --primary-light: rgba(16, 185, 129, 0.15);

  --accent: #3b82f6;
  --accent-light: rgba(59, 130, 246, 0.15);

  /* Semáforo RAG agronómico */
  --status-verde: #10b981;
  --status-verde-bg: rgba(16, 185, 129, 0.15);
  --status-amarillo: #f59e0b;
  --status-amarillo-bg: rgba(245, 158, 11, 0.15);
  --status-rojo: #ef4444;
  --status-rojo-bg: rgba(239, 68, 68, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-sub: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --border-color: #cbd5e1;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-sub: #64748b;

  --primary: #059669;
  --primary-hover: #047857;
  --primary-light: rgba(5, 150, 105, 0.12);

  --accent: #2563eb;
  --accent-light: rgba(37, 99, 235, 0.12);

  --status-verde: #059669;
  --status-verde-bg: rgba(5, 150, 105, 0.12);
  --status-amarillo: #d97706;
  --status-amarillo-bg: rgba(217, 119, 6, 0.12);
  --status-rojo: #dc2626;
  --status-rojo-bg: rgba(220, 38, 38, 0.12);

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.08);
}

/* Reset y estructura básica */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.tool-title {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
}

.mono, code, .stat-number, .chart-val {
  font-family: var(--font-mono);
}

/* Layout canónico fijate.com */
.main-wrapper.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
  width: 100%;
}

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

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

/* Hero y cabecera de la herramienta */
.tool-hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
}

.hero-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero-title-group h2 {
  font-size: 1.6rem;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.hero-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Botones genéricos */
.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  transition: background-color 0.2s, transform 0.1s;
}

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

.btn-secondary {
  background-color: var(--bg-card-sub);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  transition: background-color 0.2s, border-color 0.2s;
}

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

.btn-mode-toggle {
  display: inline-flex;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
  gap: 0.25rem;
}

.btn-mode-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.45rem 0.9rem;
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-mode-tab.active {
  background: var(--accent);
  color: #ffffff;
}

/* Tarjetas de sección */
.card-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
}

.card-section-title {
  font-size: 1.25rem;
  color: var(--text-main);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Grids de formulario */
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.form-grid-6 {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .form-grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .form-grid-6 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-label-hint {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  min-height: 40px;
  background-color: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  font-size: 0.92rem;
  color: var(--text-main);
  font-family: var(--font-main);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

select.form-control {
  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;
  padding-right: 2.25rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Badges e insignias */
.badge-alt-info {
  display: inline-flex;
  align-items: center;
  font-size: 0.78rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  margin-top: 0.35rem;
  font-weight: 600;
  width: fit-content;
}

.badge-alt-info.neutral {
  background: var(--bg-card-sub);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.badge-alt-info.positive {
  background: var(--status-verde-bg);
  color: var(--status-verde);
}

.badge-alt-info.negative {
  background: var(--status-amarillo-bg);
  color: var(--status-amarillo);
}

.badges-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.badge-pill {
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  background: var(--bg-card-sub);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* KPIs principales */
.kpi-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.kpi-card-header {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-value-kpi {
  font-size: 2rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-main);
  line-height: 1.1;
}

.stat-value-kpi.status-verde {
  color: var(--status-verde);
}

.stat-value-kpi.status-amarillo {
  color: var(--status-amarillo);
}

.stat-value-kpi.status-rojo {
  color: var(--status-rojo);
}

.kpi-subtext {
  font-size: 0.82rem;
  color: var(--text-sub);
}

/* Diagnóstico y semáforo RAG */
.diagnostic-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
}

.diag-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.diag-badge {
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.diag-badge.diag-verde {
  background: var(--status-verde-bg);
  color: var(--status-verde);
  border: 1px solid var(--status-verde);
}

.diag-badge.diag-amarillo {
  background: var(--status-amarillo-bg);
  color: var(--status-amarillo);
  border: 1px solid var(--status-amarillo);
}

.diag-badge.diag-rojo {
  background: var(--status-rojo-bg);
  color: var(--status-rojo);
  border: 1px solid var(--status-rojo);
}

.diagnostic-title {
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.diagnostic-desc {
  font-size: 0.98rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.advice-section {
  background: var(--bg-card-sub);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--primary);
  margin-bottom: 1rem;
}

.advice-section h4 {
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.advice-list {
  padding-left: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.frost-alert-box {
  background: var(--status-rojo-bg);
  border: 1px solid var(--status-rojo);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.15rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  color: #ffffff;
  font-size: 0.88rem;
}

.frost-alert-icon {
  flex-shrink: 0;
  color: var(--status-rojo);
}

/* Barra de progreso visual de frío */
.progress-container {
  margin: 1.25rem 0 1.75rem;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-family: var(--font-mono);
}

.progress-track {
  width: 100%;
  height: 22px;
  background: var(--bg-card-sub);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border-color);
}

.progress-bar-inner {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.4s ease-in-out;
}

.progress-bar-inner.bg-verde {
  background: linear-gradient(90deg, #059669, #10b981);
}

.progress-bar-inner.bg-amarillo {
  background: linear-gradient(90deg, #d97706, #f59e0b);
}

.progress-bar-inner.bg-rojo {
  background: linear-gradient(90deg, #dc2626, #ef4444);
}

/* Gráfico mensual SVG */
.monthly-chart-box {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1.25rem;
}

.monthly-svg-chart {
  width: 100%;
  height: auto;
  max-height: 190px;
  display: block;
}

.chart-bar {
  fill: var(--accent);
  transition: fill 0.2s, height 0.3s;
}

.chart-bar:hover {
  fill: var(--primary);
}

.chart-val {
  fill: var(--text-main);
  font-size: 11px;
  font-weight: 700;
}

.chart-lbl {
  fill: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

/* Pistacho polinizador card */
.pistachio-sync-card {
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.pistachio-sync-card.sync-optimo {
  background: var(--status-verde-bg);
  border-color: var(--status-verde);
  color: var(--text-main);
}

.pistachio-sync-card.sync-aceptable {
  background: var(--status-amarillo-bg);
  border-color: var(--status-amarillo);
  color: var(--text-main);
}

.pistachio-sync-card.sync-incompatible {
  background: var(--status-rojo-bg);
  border-color: var(--status-rojo);
  color: var(--text-main);
}

/* Tabla comparativa */
.compare-table-wrapper {
  overflow-x: auto;
  margin-top: 1rem;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.compare-table th {
  background: var(--bg-card-sub);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.compare-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.badge-status-pill {
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-block;
}

.badge-status-pill.status-verde {
  background: var(--status-verde-bg);
  color: var(--status-verde);
}

.badge-status-pill.status-amarillo {
  background: var(--status-amarillo-bg);
  color: var(--status-amarillo);
}

.badge-status-pill.status-rojo {
  background: var(--status-rojo-bg);
  color: var(--status-rojo);
}

.btn-icon-sm {
  background: transparent;
  border: none;
  color: var(--text-sub);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-sm:hover {
  background: var(--bg-card-hover);
  color: var(--status-rojo);
}

/* Modales accesibles */
.fijate-modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.fijate-modal-overlay.active {
  display: flex;
}

.fijate-modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.fijate-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fijate-modal-title {
  font-size: 1.25rem;
  color: var(--text-main);
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
}

.btn-modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.fijate-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  font-size: 0.92rem;
  color: var(--text-main);
  line-height: 1.6;
}

.fijate-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.report-text-pre {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  color: var(--text-main);
  max-height: 380px;
  overflow-y: auto;
}

/* Toast modal */
.toast-dialog {
  max-width: 400px;
  padding: 1.25rem 1.5rem;
  text-align: center;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  color: var(--text-main);
}

/* Acordeón y contenido SEO agronómico */
.guide-accordion-section {
  margin-top: 2rem;
}

.guide-article {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}

.guide-article h2 {
  font-size: 1.45rem;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.guide-article h3 {
  font-size: 1.15rem;
  color: var(--text-main);
  margin: 1.25rem 0 0.5rem;
}

.guide-article p {
  color: var(--text-muted);
  margin-bottom: 0.9rem;
  font-size: 0.95rem;
}

.guide-article ul {
  padding-left: 1.5rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-size: 0.93rem;
}

.guide-article li {
  margin-bottom: 0.4rem;
}

.faq-card-item {
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
}

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

.faq-question {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.faq-answer {
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Media print */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .app-header,
  .tool-ad-sidebar,
  .tools-ad-banner-section,
  .fijate-footer,
  .hero-actions,
  .btn-mode-toggle,
  .btn-primary,
  .btn-secondary,
  .btn-add-compare,
  .guide-accordion-section,
  .affiliate-section {
    display: none !important;
  }

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

  .tool-with-sidebar {
    display: block !important;
  }

  .tool-hero-card,
  .card-section,
  .diagnostic-container {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    page-break-inside: avoid;
  }

  .stat-value-kpi {
    color: #000000 !important;
  }
}
