/**
 * Calculadora de temperatura de servicio y enfriador • Estilos prémium
 * Fijate Tools
 */

:root {
  color-scheme: dark;
  --chill-blue: #0284c7;
  --chill-cyan: #06b6d4;
  --chill-surface: #0b1320;
  --chill-card: #132238;
  --chill-border: rgba(6, 182, 212, 0.2);
  --wine-red: #9e1b32;
  --beer-gold: #d97706;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --danger-red: #ef4444;
  --success-green: #10b981;
  --card-bg: rgba(19, 34, 56, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --transition-fast: 0.2s ease;
}

[data-theme="light"] {
  color-scheme: light;
  --chill-blue: #0284c7;
  --chill-cyan: #0891b2;
  --chill-surface: #f0f7fc;
  --chill-card: #ffffff;
  --chill-border: rgba(2, 132, 199, 0.18);
  --text-main: #0f172a;
  --text-muted: #475569;
  --card-bg: #ffffff;
  --card-border: rgba(0, 0, 0, 0.08);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-main);
  background-color: var(--chill-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;
}

/* Panel de control superior */
.chill-dashboard {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 2rem;
  margin-bottom: 2.5rem;
}

.chill-config-panel {
  background: var(--chill-card);
  border: 1px solid var(--chill-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.chill-timer-panel {
  background: var(--chill-card);
  border: 1px solid var(--chill-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
}

.chill-timer-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--chill-cyan), var(--chill-blue));
}

.timer-kicker {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--chill-cyan);
  letter-spacing: 0.03em;
  display: block;
}

/* Formularios y selectores */
.form-group {
  margin-bottom: 1.3rem;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 6px;
  color: var(--text-main);
}

.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 40px 0 14px;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--chill-border);
  background-color: #0b1320;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  -moz-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='%2306b6d4' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 14px) center;
  background-size: 16px 16px;
}

.form-select:focus {
  border-color: var(--chill-cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
}

.form-select option {
  background-color: #132238;
  color: #f8fafc;
  padding: 10px 12px;
  font-size: 0.95rem;
}

.form-select optgroup {
  background-color: #0b1320;
  color: var(--chill-cyan);
  font-weight: 700;
  font-style: normal;
  padding: 8px 6px 4px;
}

.form-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  box-sizing: border-box;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--chill-border);
  background: #0b1320;
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-input:focus {
  border-color: var(--chill-cyan);
}

.temp-sliders-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}

.slider-box {
  background: rgba(0, 0, 0, 0.08);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.slider-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--chill-cyan);
}

.slider-range {
  width: 100%;
  accent-color: var(--chill-cyan);
  cursor: pointer;
}

/* Temporizador digital grande */
.timer-display-box {
  margin: 1.5rem 0;
}

.timer-digits {
  font-family: 'JetBrains Mono', monospace;
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-main);
  line-height: 1;
  text-shadow: 0 0 25px rgba(6, 182, 212, 0.3);
}

.timer-subtext {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.timer-controls {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 340px;
}

.btn-timer {
  flex: 1;
  height: 44px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.btn-timer-start {
  background: var(--chill-blue);
  color: #fff;
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.3);
}

.btn-timer-start:hover {
  background: var(--chill-cyan);
}

.btn-timer-reset {
  background: rgba(0, 0, 0, 0.15);
  color: var(--text-muted);
  border: 1px solid var(--card-border);
}

.btn-timer-reset:hover {
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-main);
}

/* Alerta de congelación */
.freeze-alert-card {
  margin-top: 1.5rem;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 0.85rem;
  line-height: 1.45;
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-sizing: border-box;
}

/* Termómetro interactivo y botella SVG */
.visual-thermo-section {
  background: var(--chill-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2.5rem;
}

.thermo-visual-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 2rem;
  align-items: center;
}

.bottle-thermo-art {
  display: flex;
  justify-content: center;
  align-items: center;
}

.thermo-diagnosis-box {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.diagnosis-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 5px 14px;
  border-radius: 20px;
  width: fit-content;
}

.badge-optimal {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-excess-cold {
  background: rgba(6, 182, 212, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.badge-excess-warm {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-cold {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-warm {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.diagnosis-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

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

/* Guía de temperaturas enológicas */
.enology-guide-section {
  margin-top: 2.5rem;
}

.section-header-box {
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1.4rem;
  margin: 0 0 0.4rem 0;
}

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

/* Pastillas de filtro de categoría */
.category-filters-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 1.2rem;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.btn-filter-pill {
  background: rgba(0, 0, 0, 0.15);
  color: var(--text-muted);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 8px 16px;
  min-height: 40px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.btn-filter-pill:hover {
  background: rgba(6, 182, 212, 0.12);
  color: var(--text-main);
  border-color: var(--chill-cyan);
}

.btn-filter-pill.active {
  background: var(--chill-blue);
  color: #ffffff;
  border-color: var(--chill-blue);
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.35);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
}

.enology-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.enology-table th,
.enology-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--card-border);
  vertical-align: middle;
}

.enology-table th {
  background: rgba(0, 0, 0, 0.12);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: var(--chill-cyan);
}

.enology-table tr:last-child td {
  border-bottom: none;
}

.enology-table tbody tr {
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.enology-table tbody tr:hover {
  background: rgba(6, 182, 212, 0.08);
}

.enology-table tbody tr.selected-row {
  background: rgba(6, 182, 212, 0.16) !important;
  position: relative;
}

.enology-table tbody tr.selected-row td:first-child {
  border-left: 4px solid var(--chill-cyan);
  font-weight: 600;
}

.btn-table-select {
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: rgba(6, 182, 212, 0.12);
  color: var(--chill-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-table-select:hover,
.selected-row .btn-table-select {
  background: var(--chill-blue);
  color: #ffffff;
  border-color: var(--chill-blue);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

/* Animación de pulso visual de confirmación */
@keyframes highlightPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.7);
  }
  40% {
    box-shadow: 0 0 0 10px rgba(6, 182, 212, 0.3);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(6, 182, 212, 0);
  }
}

.highlight-pulse {
  animation: highlightPulse 0.85s ease-out;
}

/* Modal canónico */
.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(--chill-card);
  border: 1px solid var(--chill-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.8rem;
  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(--chill-blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-modal-close:hover {
  background: var(--chill-cyan);
}

/* Ajustes para tema claro: accesibilidad y contraste */
[data-theme="light"] .freeze-alert-card {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.35);
  color: #991b1b;
}

[data-theme="light"] .freeze-alert-card svg {
  stroke: #b91c1c;
}

[data-theme="light"] .form-select {
  background-color: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  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='%230284c7' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

[data-theme="light"] .form-select:focus {
  border-color: var(--chill-blue);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

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

[data-theme="light"] .form-select optgroup {
  background-color: #f1f5f9;
  color: #0369a1;
}

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

[data-theme="light"] .slider-box {
  background: #f1f5f9;
  border-color: #e2e8f0;
}

[data-theme="light"] .enology-table th {
  background: #e2e8f0;
  color: #0369a1;
}

[data-theme="light"] .btn-filter-pill {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

[data-theme="light"] .btn-filter-pill.active {
  background: var(--chill-blue);
  color: #ffffff;
  border-color: var(--chill-blue);
}

[data-theme="light"] .enology-table tbody tr.selected-row {
  background: rgba(2, 132, 199, 0.12) !important;
}

[data-theme="light"] .btn-timer-reset {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

[data-theme="light"] .btn-timer-reset:hover {
  background: #e2e8f0;
  color: #0f172a;
}

@media (max-width: 900px) {
  .chill-dashboard {
    grid-template-columns: 1fr;
  }
  .thermo-visual-layout {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .diagnosis-badge {
    margin: 0 auto;
  }
}

@media (max-width: 600px) {
  .temp-sliders-grid {
    grid-template-columns: 1fr;
  }
  .timer-digits {
    font-size: 3rem;
  }
  .chill-config-panel,
  .chill-timer-panel,
  .visual-thermo-section {
    padding: 1.25rem;
  }
}
