/* ==========================================================================
   Fijate Tools - Planificador de huerto y bancales con asociaciones y rotación
   Tokens corporativos, layout canónico y cuadrícula interactiva
   ========================================================================== */

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

  /* Paleta agronómica: tierra fértil, verde brote y follaje */
  --earth-900: #271c19;
  --earth-800: #44302b;
  --earth-700: #62463e;
  --crop-green: #15803d;
  --crop-green-hover: #166534;
  --crop-green-light: #dcfce7;
  --crop-green-dark: #14532d;
  --crop-green-text: #14532d;
  --crop-green-title: #052e16;
  --crop-amber: #d97706;
  --crop-amber-light: #fef3c7;
  --crop-bad: #dc2626;
  --crop-bad-light: #fee2e2;
  --crop-bad-text: #991b1b;
  --crop-bad-title: #450a0a;

  --bg-page: #f8faf8;
  --card-bg: #ffffff;
  --card-border: #e2e8e2;
  --card-border-hover: #cbd5cb;
  --card-shadow: 0 4px 20px -2px rgba(20, 83, 45, 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.03);

  --text-main: #1f2923;
  --text-muted: #4b5d52;
  --text-subtle: #73877b;

  --primary: #15803d;
  --primary-hover: #166534;
  --primary-light: #f0fdf4;
  --primary-text: #ffffff;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --bg-page: #0a0f0c;
  --card-bg: #121c16;
  --card-border: #1f2f25;
  --card-border-hover: #2e4738;
  --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.6);

  --text-main: #f0f5f1;
  --text-muted: #b9cdc0;
  --text-subtle: #8ea596;

  --primary: #22c55e;
  --primary-hover: #16a34a;
  --primary-light: #13281c;
  --primary-text: #05140a;

  --crop-green: #22c55e;
  --crop-green-light: rgba(34, 197, 94, 0.16);
  --crop-green-text: #86efac;
  --crop-green-title: #f0fdf4;
  --crop-amber-light: rgba(245, 158, 11, 0.16);
  --crop-bad-light: rgba(239, 68, 68, 0.16);
  --crop-bad-text: #fca5a5;
  --crop-bad-title: #fef2f2;
}

body {
  font-family: var(--font-main);
  background: var(--bg-page);
  color: var(--text-main);
  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, .hero-title {
  font-family: var(--font-heading);
}

.mono, code {
  font-family: var(--font-mono);
}

/* Suite banner switcher */
.suite-nav-strip {
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  padding: 0.6rem 1rem;
}
.suite-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.suite-nav-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.suite-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.suite-link-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-muted);
  background: var(--bg-page);
  border: 1px solid var(--card-border);
  transition: var(--transition);
}
.suite-link-item:hover {
  color: var(--primary);
  border-color: var(--primary);
}
.suite-link-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 700;
}

/* Tool main layout */
.tool-layout {
  max-width: 1240px;
  margin: 1.25rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
}
.tool-with-sidebar {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}
.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* Hero card */
.hero-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.5rem;
}
.hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.hero-title-group h1 {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 0.35rem;
  color: var(--text-main);
}
.hero-tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

/* Control bar */
.planner-controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--card-border);
}
.control-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.control-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}
.control-field select,
.control-field input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--bg-page);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}
.control-field select {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  padding-right: 36px;
}
.control-field select:focus,
.control-field input:focus {
  border-color: var(--primary);
}

/* Main workspace: palette + bed canvas */
.workspace-grid {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 992px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Crop palette */
.palette-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  max-height: 720px;
}
.palette-head {
  margin-bottom: 0.75rem;
}
.palette-head h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}
.palette-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}
.crop-search-input {
  width: 100%;
  height: 38px;
  padding: 0 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--bg-page);
  color: var(--text-main);
  font-size: 0.85rem;
  margin: 0.5rem 0;
}
.crop-palette-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-right: 0.25rem;
  flex: 1;
}
.crop-palette-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-page);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.crop-palette-item:hover,
.crop-palette-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateX(3px);
}
.crop-icon-lg {
  font-size: 1.4rem;
  line-height: 1;
}
.crop-info {
  flex: 1;
  min-width: 0;
}
.crop-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}
.crop-family-badge {
  font-size: 0.72rem;
  color: var(--text-subtle);
}

/* Bed canvas card */
.canvas-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
}
.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--card-border);
}
.toolbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-tool {
  height: 38px;
  padding: 0 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
}
.btn-tool:hover {
  background: var(--bg-page);
  border-color: var(--primary);
  color: var(--primary);
}
.btn-tool.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}
.btn-tool.btn-primary:hover {
  background: var(--primary-hover);
}

/* Interactive bed grid */
.bed-container {
  overflow-x: auto;
  padding: 1rem 0;
  display: flex;
  justify-content: center;
}
.bed-grid {
  display: grid;
  gap: 6px;
  background: #3b2820;
  padding: 12px;
  border-radius: var(--radius-md);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
  border: 4px solid #62463e;
}
.bed-cell {
  width: 90px;
  height: 90px;
  background: #50382f;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  padding: 4px;
}
.bed-cell:hover {
  background: #64463a;
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.03);
  z-index: 2;
}
.bed-cell.has-crop {
  background: #234327;
  border-style: solid;
  border-color: #3b7e41;
}
.bed-cell.has-crop.compat-bad {
  background: #532020;
  border-color: #dc2626;
  animation: pulse-danger 2s infinite ease-in-out;
}
.bed-cell.has-crop.compat-good {
  background: #144927;
  border-color: #22c55e;
}
.cell-crop-icon {
  font-size: 1.8rem;
  line-height: 1;
}
.cell-crop-name {
  font-size: 0.68rem;
  font-weight: 700;
  color: #f0fdf4;
  margin-top: 3px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-crop-count {
  font-size: 0.6rem;
  color: #bbf7d0;
  font-family: var(--font-mono);
}
.cell-remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  font-size: 10px;
  line-height: 1;
  display: none;
  cursor: pointer;
}
.bed-cell:hover .cell-remove-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes pulse-danger {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

/* Diagnosis and metrics panel */
.metrics-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.metric-box {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
}
.metric-box-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.compat-alert-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 240px;
  overflow-y: auto;
}
.compat-alert-item {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.compat-alert-item.bad {
  background: var(--crop-bad-light);
  color: var(--crop-bad-text);
  border: 1px solid rgba(220, 38, 38, 0.28);
  border-left: 4px solid #ef4444;
}
.compat-alert-item.bad strong {
  color: var(--crop-bad-title);
  font-weight: 700;
}
.compat-alert-item.good {
  background: var(--crop-green-light);
  color: var(--crop-green-text);
  border: 1px solid rgba(34, 197, 94, 0.28);
  border-left: 4px solid #22c55e;
}
.compat-alert-item.good strong {
  color: var(--crop-green-title);
  font-weight: 700;
}

/* Rotation plan card */
.rotation-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.5rem;
}
.rotation-timeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}
@media (max-width: 768px) {
  .rotation-timeline {
    grid-template-columns: 1fr;
  }
}
.rotation-step {
  background: var(--bg-page);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  position: relative;
}
.rotation-step.active-year {
  border-color: var(--primary);
  background: var(--primary-light);
}
.year-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  margin-bottom: 0.4rem;
  font-family: var(--font-mono);
}
.rotation-group-title {
  font-size: 0.98rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}
.rotation-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-overlay.open {
  display: flex;
}
.modal-box {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  padding: 1.5rem;
  position: relative;
}
.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
}

/* Editorial guide */
.seo-guide-section {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--card-shadow);
  margin-top: 2rem;
}
.seo-guide-section h2 {
  font-size: 1.35rem;
  margin-top: 1.5rem;
  margin-bottom: 0.6rem;
}
.seo-guide-section h2:first-of-type {
  margin-top: 0;
}
.seo-guide-section p, .seo-guide-section li {
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 0.95rem;
}
.guide-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.88rem;
}
.guide-table th, .guide-table td {
  padding: 0.75rem;
  border: 1px solid var(--card-border);
  text-align: left;
}
.guide-table th {
  background: var(--bg-page);
  font-weight: 700;
}
