/* ============================================
   Figuras Planas Study App — Tema 9 Geometría 📐
   Principal=#3498db  Accent=#9b59b6
   Correct=#27ae60    Incorrect=#e74c3c
   Formula=#f39c12    SVG=#2c3e50
   ============================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', 'Arial Rounded MT Bold', Arial, sans-serif;
  background: linear-gradient(135deg, #eaf6ff 0%, #fff 50%, #fef9e7 100%);
  color: #222;
  min-height: 100vh;
  padding: 16px;
  font-size: 18px;
  line-height: 1.5;
}

/* ---- Views ---- */
.view {
  display: none;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}
.view.active {
  display: block;
}

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

/* ---- Hidden Utility ---- */
.hidden {
  display: none !important;
}

/* ---- Typography ---- */
h1 {
  font-size: 2.2rem;
  text-align: center;
  color: #2c3e50;
  margin-bottom: 8px;
}
h2 {
  font-size: 1.6rem;
  text-align: center;
  color: #2c3e50;
  margin-bottom: 16px;
}
h3 {
  font-size: 1.25rem;
  margin: 20px 0 8px;
  padding-bottom: 4px;
}
h4 {
  font-size: 1.05rem;
  color: #555;
  margin: 12px 0 6px;
}
.subtitle {
  text-align: center;
  font-size: 1.15rem;
  color: #555;
  margin-bottom: 24px;
}

/* ---- Main Menu Grid ---- */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 8px;
}
.menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  color: #fff;
  min-height: 44px;
  min-width: 44px;
}
.menu-btn:hover,
.menu-btn:focus {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  outline: 3px solid #2c3e50;
}
.menu-btn--tema1 { background: linear-gradient(135deg, #3498db, #5dade2); }
.menu-btn--tema2 { background: linear-gradient(135deg, #9b59b6, #af7ac5); }
.menu-btn--tema3 { background: linear-gradient(135deg, #27ae60, #2ecc71); }
.menu-btn--tema4 { background: linear-gradient(135deg, #e74c3c, #ec7063); }
.menu-btn--tema5 { background: linear-gradient(135deg, #f39c12, #f1c40f); }
.menu-btn--tema6 { background: linear-gradient(135deg, #1abc9c, #48c9b0); }
.menu-btn--tema7 { background: linear-gradient(135deg, #e67e22, #f0b27a); }
.menu-btn--tema8 { background: linear-gradient(135deg, #8e44ad, #bb8fce); }
.menu-emoji { font-size: 2.5rem; }
.menu-title { font-size: 1.1rem; font-weight: 700; text-align: center; }

/* ---- Tema View Buttons ---- */
.tema-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}
.tema-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 220px;
  padding: 24px 16px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  color: #fff;
  min-height: 44px;
  min-width: 44px;
}
.tema-btn:hover,
.tema-btn:focus {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  outline: 3px solid #2c3e50;
}
.tema-btn--guide {
  background: linear-gradient(135deg, #3498db, #5dade2);
}
.tema-btn--practice {
  background: linear-gradient(135deg, #e74c3c, #ec7063);
}

/* ---- Exercise Menu Grid ---- */
.exercise-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 8px;
}
.exercise-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  color: #fff;
  min-height: 44px;
  min-width: 44px;
}
.exercise-btn:hover,
.exercise-btn:focus {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  outline: 3px solid #2c3e50;
}
.exercise-btn--identificar {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
}
.exercise-btn--clasificar {
  background: linear-gradient(135deg, #8e44ad, #a569bd);
}
.exercise-btn--calcular {
  background: linear-gradient(135deg, #f39c12, #f1c40f);
}
.exercise-btn--completar {
  background: linear-gradient(135deg, #1abc9c, #48c9b0);
}

/* ---- Back Button ---- */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid #3498db;
  border-radius: 10px;
  background: transparent;
  color: #3498db;
  cursor: pointer;
  margin-bottom: 12px;
  min-height: 44px;
  min-width: 44px;
  transition: background 0.15s, color 0.15s;
}
.btn-back:hover,
.btn-back:focus {
  background: #3498db;
  color: #fff;
  outline: none;
}

/* ---- Guide Content ---- */
.guide-content {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.guide-intro {
  font-size: 1.1rem;
  color: #444;
  margin-bottom: 20px;
  padding: 16px;
  background: #eaf4fc;
  border-radius: 12px;
  border-left: 5px solid #3498db;
}
.guide-section {
  margin-bottom: 24px;
  border-radius: 12px;
  padding: 18px;
  background: #f8f9fa;
  border-left: 5px solid #3498db;
}
.guide-section h3 {
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
}

/* ---- Formula Cards ---- */
.formula-card {
  background: linear-gradient(135deg, #fef9e7, #fdebd0);
  border: 2px solid #f39c12;
  border-radius: 12px;
  padding: 16px 20px;
  margin: 12px 0;
  box-shadow: 0 2px 8px rgba(243,156,18,0.15);
}
.formula-card h4 {
  color: #e67e22;
  margin-bottom: 8px;
  font-size: 1.1rem;
}
.formula-card .formula-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: #2c3e50;
  text-align: center;
  padding: 8px;
  background: rgba(255,255,255,0.7);
  border-radius: 8px;
  margin: 8px 0;
}
.formula-card .formula-example {
  font-size: 1rem;
  color: #555;
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.5);
  border-radius: 8px;
}

/* ---- Classification Tables ---- */
.classification-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 20px;
  font-size: 1rem;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.classification-table th {
  background: #3498db;
  color: #fff;
  padding: 10px 14px;
  text-align: center;
  font-weight: 600;
}
.classification-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #ddd;
  text-align: center;
}
.classification-table tr:nth-child(even) td {
  background: #f0f8ff;
}
.classification-table .cell-possible {
  background: #eafaf1;
  color: #27ae60;
  font-weight: 600;
}
.classification-table .cell-impossible {
  background: #fdedec;
  color: #e74c3c;
  font-style: italic;
}

/* ---- SVG Diagram Containers ---- */
.svg-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 16px 0;
  padding: 12px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #eee;
}
.svg-container svg {
  max-width: 100%;
  height: auto;
}

/* SVG inline styles */
svg text {
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  fill: #2c3e50;
}
svg line,
svg polyline,
svg polygon,
svg path,
svg circle,
svg rect {
  stroke-width: 2.5px;
}
svg .svg-fill-primary { fill: #3498db; fill-opacity: 0.15; stroke: #3498db; }
svg .svg-fill-accent { fill: #9b59b6; fill-opacity: 0.15; stroke: #9b59b6; }
svg .svg-fill-success { fill: #27ae60; fill-opacity: 0.15; stroke: #27ae60; }
svg .svg-fill-warning { fill: #f39c12; fill-opacity: 0.15; stroke: #f39c12; }
svg .svg-fill-danger { fill: #e74c3c; fill-opacity: 0.15; stroke: #e74c3c; }
svg .svg-fill-teal { fill: #1abc9c; fill-opacity: 0.15; stroke: #1abc9c; }
svg .svg-stroke-primary { stroke: #3498db; fill: none; }
svg .svg-stroke-accent { stroke: #9b59b6; fill: none; }
svg .svg-stroke-success { stroke: #27ae60; fill: none; }
svg .svg-stroke-warning { stroke: #f39c12; fill: none; }
svg .svg-stroke-danger { stroke: #e74c3c; fill: none; }
svg .svg-stroke-teal { stroke: #1abc9c; fill: none; }
svg .svg-vertex {
  fill: #2c3e50;
  stroke: #2c3e50;
  stroke-width: 1px;
}
svg .svg-label {
  font-size: 12px;
  font-weight: 600;
}
svg .svg-dimension {
  font-size: 11px;
  fill: #e67e22;
  font-weight: 700;
}

/* ---- Score Display ---- */
.score-display {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: #3498db;
  background: #eaf4fc;
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 16px;
}

/* ---- Exercise Area ---- */
.exercise-area {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

/* ---- Figure Selection Grid (Identificar polígonos) ---- */
.figure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.figure-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  border: 3px solid #ddd;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  background: #fff;
  min-height: 44px;
}
.figure-item:hover {
  border-color: #3498db;
  transform: translateY(-2px);
}
.figure-item.selected {
  border-color: #3498db;
  background: #eaf4fc;
  box-shadow: 0 2px 8px rgba(52,152,219,0.2);
}
.figure-item.correct {
  border-color: #27ae60;
  background: #eafaf1;
}
.figure-item.incorrect {
  border-color: #e74c3c;
  background: #fdedec;
}
.figure-item.omitted {
  border-color: #f39c12;
  background: #fef9e7;
}

/* ---- Option Buttons (Multiple Choice) ---- */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.option-btn {
  padding: 14px 18px;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 600;
  border: 2px solid #3498db;
  border-radius: 12px;
  background: #fff;
  color: #3498db;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: background 0.15s, color 0.15s, transform 0.1s, border-color 0.15s;
}
.option-btn:hover,
.option-btn:focus {
  background: #eaf4fc;
  transform: translateY(-2px);
  outline: none;
}
.option-btn:disabled {
  cursor: default;
  transform: none;
  opacity: 0.7;
}
.option-btn.option-correct {
  border-color: #27ae60 !important;
  background: #eafaf1 !important;
  color: #27ae60 !important;
}
.option-btn.option-incorrect {
  border-color: #e74c3c !important;
  background: #fdedec !important;
  color: #e74c3c !important;
}
.option-btn.option-selected {
  background: #3498db;
  color: #fff;
}

/* ---- Radio Button Groups (Clasificar triángulos) ---- */
.radio-group {
  margin-bottom: 16px;
}
.radio-group-title {
  font-size: 1rem;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 8px;
}
.radio-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.radio-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: 2px solid #ddd;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  min-height: 44px;
  transition: border-color 0.2s, background 0.2s;
}
.radio-option:hover {
  border-color: #3498db;
  background: #eaf4fc;
}
.radio-option.selected {
  border-color: #3498db;
  background: #eaf4fc;
  font-weight: 600;
}
.radio-option input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: #3498db;
}

/* ---- Form Inputs ---- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}
.form-group label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #444;
}
.form-input,
.form-select {
  padding: 10px 14px;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid #ccc;
  border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
  min-height: 44px;
}
.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}

/* Correct / Incorrect field states */
.field-correct {
  border-color: #27ae60 !important;
  background: #eafaf1 !important;
}
.field-incorrect {
  border-color: #e74c3c !important;
  background: #fdedec !important;
}

/* Expected answer hint */
.expected-hint {
  font-size: 0.85rem;
  color: #c0392b;
  margin-top: 2px;
  font-style: italic;
}

/* ---- Exercise Table (Completar tabla) ---- */
.exercise-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 1rem;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.exercise-table th {
  background: #3498db;
  color: #fff;
  padding: 10px 12px;
  text-align: center;
  font-weight: 600;
}
.exercise-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #ddd;
  text-align: center;
}
.exercise-table tr:nth-child(even) td {
  background: #f8f9fa;
}
.exercise-table input {
  width: 60px;
  padding: 6px 10px;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid #3498db;
  border-radius: 8px;
  text-align: center;
  min-height: 36px;
}
.exercise-table input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(52,152,219,0.2);
}
.exercise-table .cell-correct {
  background: #eafaf1 !important;
  border-color: #27ae60;
}
.exercise-table .cell-incorrect {
  background: #fdedec !important;
  border-color: #e74c3c;
}

/* ---- Feedback ---- */
.feedback {
  min-height: 24px;
  margin-bottom: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  border-radius: 10px;
  padding: 10px;
}
.feedback-correct {
  color: #27ae60;
  background: #eafaf1;
}
.feedback-incorrect {
  color: #c0392b;
  background: #fdedec;
}
.feedback-warning {
  color: #e67e22;
  background: #fef9e7;
}

/* Explanation text below feedback */
.explanation {
  font-size: 0.95rem;
  color: #555;
  margin-top: 6px;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 3px solid #3498db;
}

/* ---- Buttons ---- */
.btn-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}
.btn-primary {
  padding: 12px 28px;
  font-size: 1.15rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: #3498db;
  color: #fff;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover,
.btn-primary:focus {
  background: #2980b9;
  outline: none;
}
.btn-primary:active {
  transform: scale(0.97);
}
.btn-next {
  padding: 12px 28px;
  font-size: 1.15rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: #27ae60;
  color: #fff;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: background 0.15s, transform 0.1s;
}
.btn-next:hover,
.btn-next:focus {
  background: #1e8449;
  outline: none;
}
.btn-next:active {
  transform: scale(0.97);
}
.btn-retry {
  padding: 12px 28px;
  font-size: 1.15rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: #f39c12;
  color: #fff;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: background 0.15s, transform 0.1s;
}
.btn-retry:hover,
.btn-retry:focus {
  background: #d68910;
  outline: none;
}
.btn-retry:active {
  transform: scale(0.97);
}

/* ---- Completion Message ---- */
.completion-message {
  text-align: center;
  font-size: 1.3rem;
  padding: 24px;
  color: #27ae60;
}

/* ---- Drag & Drop / Association ---- */
.association-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 2px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}
.association-row .polygon-name {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 600;
  color: #2c3e50;
}
.association-row .form-select {
  min-width: 80px;
}
.association-row.item-correct {
  border-color: #27ae60;
  background: #eafaf1;
}
.association-row.item-incorrect {
  border-color: #e74c3c;
  background: #fdedec;
}

/* ============================================
   Responsive Design
   ============================================ */

/* Mobile: ≤ 768px */
@media (max-width: 768px) {
  body {
    padding: 10px;
    font-size: 16px;
  }
  h1 { font-size: 1.7rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }

  .menu-grid {
    grid-template-columns: 1fr;
  }
  .menu-btn {
    width: 100%;
  }

  .tema-actions {
    flex-direction: column;
    align-items: center;
  }
  .tema-btn {
    width: 100%;
    max-width: 300px;
  }

  .exercise-grid {
    grid-template-columns: 1fr;
  }

  .guide-content {
    padding: 14px;
  }
  .guide-section {
    padding: 12px;
  }

  .formula-card {
    padding: 12px 14px;
  }

  .exercise-area {
    padding: 16px;
  }

  .figure-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }

  .radio-options {
    flex-direction: column;
  }

  .btn-row {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-primary,
  .btn-next,
  .btn-retry {
    width: 100%;
    text-align: center;
  }

  .classification-table,
  .exercise-table {
    font-size: 0.9rem;
  }
  .classification-table th,
  .classification-table td,
  .exercise-table th,
  .exercise-table td {
    padding: 6px 8px;
  }

  .association-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .svg-container {
    padding: 8px;
  }
}

/* Tablet: 769px - 1024px */
@media (min-width: 769px) and (max-width: 1024px) {
  .menu-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .menu-btn {
    padding: 20px 14px;
  }
  .exercise-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .figure-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Desktop: > 1024px */
@media (min-width: 1025px) {
  .menu-grid {
    grid-template-columns: repeat(4, 1fr);
    max-width: 900px;
    margin: 8px auto 0;
  }
  .figure-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .view {
    max-width: 900px;
  }
}
