/**
 * Rueda de aromas y generador de fichas de cata • Estilos prémium canónicos
 * Fijate Tools
 */

:root {
  --tasting-burgundy: #881337;
  --tasting-burgundy-hover: #9f1239;
  --tasting-rose: #be123c;
  --tasting-surface: #0b0f17;
  --tasting-card: #131a26;
  --tasting-border: rgba(190, 18, 60, 0.28);
  --gold-accent: #d4af37;
  --gold-light: #fef3c7;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --card-bg: rgba(19, 26, 38, 0.85);
  --card-border: rgba(255, 255, 255, 0.09);
  --surface-subtle: rgba(255, 255, 255, 0.04);
  --surface-subtle-hover: rgba(255, 255, 255, 0.08);
  --prose-bg: rgba(0, 0, 0, 0.22);
  --select-bg: #101622;
  --select-opt-bg: #141c2c;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --transition-fast: 0.2s ease;
}

[data-theme="light"] {
  --tasting-burgundy: #9f1239;
  --tasting-burgundy-hover: #881337;
  --tasting-rose: #be123c;
  --tasting-surface: #fdf8f8;
  --tasting-card: #ffffff;
  --tasting-border: rgba(159, 18, 57, 0.22);
  --gold-accent: #b45309;
  --gold-light: #fffbeb;
  --text-main: #0f172a;
  --text-muted: #475569;
  --card-bg: #ffffff;
  --card-border: rgba(0, 0, 0, 0.1);
  --surface-subtle: #f8fafc;
  --surface-subtle-hover: #f1f5f9;
  --prose-bg: #fff1f2;
  --select-bg: #ffffff;
  --select-opt-bg: #ffffff;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-main);
  background-color: var(--tasting-surface);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}

h1, h2, h3, h4, .font-heading {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.01em;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

.tool-layout {
  max-width: 1240px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  box-sizing: border-box;
}

/* Selector de modo dual (Vino vs Cerveza) */
.mode-toggle-container {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
}

.mode-toggle-group {
  display: inline-flex;
  background: var(--tasting-card);
  padding: 4px;
  border-radius: 40px;
  border: 1px solid var(--card-border);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
}

.btn-mode {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 30px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-mode.active {
  background: var(--tasting-burgundy);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(136, 19, 55, 0.4);
}

/* Rueda sensorial interactiva */
.aroma-wheel-section {
  background: var(--tasting-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2.5rem;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.aroma-wheel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.aroma-wheel-split {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 2rem;
  align-items: start;
}

.wheel-canvas-container {
  background: var(--surface-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

#aroma-wheel-svg {
  width: 100%;
  max-width: 300px;
  height: auto;
  aspect-ratio: 1 / 1;
  display: block;
}

.wheel-sector {
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
  transform-origin: 200px 200px;
}

.wheel-sector:hover {
  filter: brightness(1.2);
}

.wheel-sector.active {
  filter: drop-shadow(0 0 8px rgba(212, 175, 55, 0.6));
}

.wheel-legend-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 10px;
}

/* Pestañas de familias */
.family-tabs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1.5rem;
}

.family-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--surface-subtle);
  color: var(--text-muted);
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.family-tab-btn:hover {
  border-color: var(--gold-accent);
  color: var(--text-main);
  background: var(--surface-subtle-hover);
}

.family-tab-btn.active {
  background: var(--tasting-burgundy);
  color: #ffffff;
  border-color: var(--tasting-burgundy);
  box-shadow: 0 2px 8px rgba(136, 19, 55, 0.35);
}

.subfamily-container {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.subfamily-group {
  background: var(--surface-subtle);
  border: 1px solid var(--card-border);
  padding: 1rem;
  border-radius: var(--radius-md);
}

.subfamily-name {
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gold-accent);
  margin-bottom: 8px;
}

.aroma-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.aroma-chip {
  background: var(--tasting-card);
  border: 1px solid var(--card-border);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 0.84rem;
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.aroma-chip:hover {
  border-color: var(--tasting-rose);
  transform: translateY(-1px);
}

.aroma-chip.selected {
  background: var(--tasting-burgundy);
  color: #ffffff;
  border-color: var(--tasting-burgundy);
  box-shadow: 0 2px 8px rgba(136, 19, 55, 0.35);
}

/* Aromas seleccionados activos */
.selected-aromas-bar {
  background: var(--surface-subtle);
  border: 1px solid var(--card-border);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.selected-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--tasting-burgundy);
  color: #fff;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.82rem;
  font-weight: 500;
}

.selected-tag-remove {
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
  font-weight: 700;
  margin-left: 2px;
}

.selected-tag-remove:hover {
  opacity: 1;
}

/* Layout de trabajo: Editor de cata (izquierda) + Ficha sommelier en vivo (derecha) */
.tasting-workspace-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 2rem;
  margin-bottom: 2.5rem;
  align-items: start;
}

.tasting-editor-card {
  background: var(--tasting-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

/* Ficha sommelier fijada (Sticky) */
.tasting-sheet-preview {
  background: var(--tasting-card);
  border: 1px solid var(--tasting-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

@media (min-width: 991px) {
  .tasting-sheet-preview {
    position: sticky;
    top: 1.5rem;
    align-self: start;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
  }
}

.tasting-sheet-preview::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--tasting-burgundy), var(--gold-accent));
}

/* Pulso luminoso para confirmar actualización reactiva */
@keyframes tastingPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.65);
    border-color: var(--gold-accent);
  }
  50% {
    box-shadow: 0 0 22px 4px rgba(212, 175, 55, 0.38);
    border-color: var(--gold-accent);
  }
  100% {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    border-color: var(--tasting-border);
  }
}

.highlight-pulse {
  animation: tastingPulse 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Cabecera de la ficha y puntuación */
.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 1.25rem;
  gap: 1rem;
}

.score-badge-box {
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid var(--gold-accent);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  text-align: center;
  min-width: 90px;
  flex-shrink: 0;
}

.score-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  font-weight: 800;
  color: var(--gold-accent);
  line-height: 1;
}

.score-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 3px;
}

/* Medalla OIV y desglose por fases */
.score-medal-pill {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(212, 175, 55, 0.18);
  color: var(--gold-accent);
  margin-top: 4px;
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.score-breakdown-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: var(--surface-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 1.25rem;
  text-align: center;
}

.score-sub-item {
  display: flex;
  flex-direction: column;
}

.score-sub-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.score-sub-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

/* Nota en prosa del sommelier */
.prose-section {
  background: var(--prose-bg);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--tasting-burgundy);
  margin-bottom: 1.5rem;
  font-size: 0.94rem;
  line-height: 1.65;
  color: var(--text-main);
  font-style: italic;
  white-space: pre-line;
}

/* Fases del editor de cata */
.step-accordion-item {
  margin-bottom: 1.5rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  background: var(--surface-subtle);
}

.step-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.12rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  color: var(--text-main);
}

.step-number {
  background: var(--tasting-burgundy);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
}

.editor-inputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group {
  margin-bottom: 0.8rem;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 5px;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  box-sizing: border-box;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background-color: var(--select-bg);
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.form-input:focus {
  border-color: var(--tasting-rose);
}

/* Estándar canónico estricto de desplegables (<select>, option y optgroup) */
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 40px 0 12px;
  box-sizing: border-box;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background-color: var(--select-bg);
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  appearance: none;
  -webkit-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='%23d4af37' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 14px) center;
  color-scheme: dark;
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--tasting-rose);
}

.form-select option {
  background-color: var(--select-opt-bg);
  color: #f8fafc;
  padding: 10px 12px;
}

.form-select optgroup {
  background-color: var(--tasting-surface);
  color: var(--gold-accent);
  font-weight: 700;
}

[data-theme="light"] .form-select {
  background-color: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
  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='%23b45309' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: light;
}

[data-theme="light"] .form-select option {
  background-color: #ffffff;
  color: #0f172a;
}

[data-theme="light"] .form-select optgroup {
  background-color: #f8fafc;
  color: #b45309;
}

/* Botones de acción */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  background: var(--tasting-burgundy);
  color: #fff;
  transition: all var(--transition-fast);
  height: 44px;
  width: 100%;
  box-sizing: border-box;
}

.btn-action:hover {
  background: var(--tasting-burgundy-hover);
  transform: translateY(-1px);
}

/* Botón flotante para móvil */
.btn-scroll-to-sheet {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  background: var(--surface-subtle);
  color: var(--gold-accent);
  border: 1px dashed var(--gold-accent);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 1rem;
  cursor: pointer;
}

/* Modales */
.fijate-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 1rem;
}

.fijate-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.fijate-modal {
  background: var(--tasting-card);
  border: 1px solid var(--tasting-border);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 2rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.modal-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.modal-title {
  font-size: 1.4rem;
  margin: 0 0 8px 0;
}

.modal-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 1.5rem 0;
  line-height: 1.5;
}

.btn-modal-close {
  width: 100%;
  height: 44px;
  background: var(--tasting-burgundy);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-modal-close:hover {
  background: var(--tasting-burgundy-hover);
}

/* Adaptabilidad responsive */
@media (max-width: 990px) {
  .aroma-wheel-split {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .tasting-workspace-grid {
    grid-template-columns: 1fr;
  }
  .btn-scroll-to-sheet {
    display: flex;
  }
}

@media (max-width: 600px) {
  .tool-layout {
    padding: 0 0.75rem;
  }
  .editor-inputs-grid {
    grid-template-columns: 1fr;
  }
  .score-breakdown-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .tasting-editor-card,
  .tasting-sheet-preview,
  .aroma-wheel-section {
    padding: 1.25rem;
  }
}
