/*
 * Copyright (c) 2025 Davide Guerri <davide.guerri@gmail.com>
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial 4.0
 * International License. To view a copy of this license, visit
 * http://creativecommons.org/licenses/by-nc/4.0/
 */

/* ========================================
   PAIRING TOOL STYLES
   ======================================== */

.pairing-tool {
  padding: 1.5rem;
  min-height: 100px;
}

/* Metadata Form */
.pairing-metadata {
  width: 100%;
  max-width: 100%;
}

.pairing-metadata .row {
  margin-left: 0 !important;
  margin-right: 0 !important;
  width: 100%;
  max-width: 100%;
}

.pairing-metadata [class*="col-"] {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.pairing-metadata .form-label {
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

#dishTempLabel {
  font-weight: 500;
}

/* Chart and Inputs Layout */
.pairing-chart-layout {
  margin-top: 2rem;
}

/* Custom column widths for chart layout on xl screens */
@media screen and (min-width: 1200px) {
  .slider-panel-col {
    flex: 0 0 22%;
    max-width: 22%;
  }

  .chart-col {
    flex: 0 0 56%;
    max-width: 56%;
  }
}

/* Sliders Panels */
.sliders-panel {
  padding: 1rem 2rem;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  height: 100%;
  max-height: 850px;
}

.sliders-panel h5 {
  font-weight: 600;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid currentColor;
  font-size: 1rem;
}

/* Radar Chart */
.pairing-chart {
  padding: 0.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

#pairingChart {
  display: block;
  margin: 0 auto;
  background: #fafafa;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  max-width: 100%;
  max-height: 840px;
}

/* Characteristic Inputs */
.pairing-inputs h5 {
  font-weight: 600;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid currentColor;
}

.characteristic-input {
  margin-bottom: 1.5rem;
}

.characteristic-input label {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
  color: #495057;
}

.input-group-pairing {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.input-group-pairing input[type="range"] {
  flex: 1;
  height: 7px;
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
}

.input-group-pairing input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: currentColor;
  cursor: pointer;
  border: 1px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.input-group-pairing input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: currentColor;
  cursor: pointer;
  border: 1px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.input-group-pairing input[type="number"] {
  width: 60px;
  height: 25px;
  padding: 0.375rem 0.5rem;
  text-align: center;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  font-weight: 400;
  font-size: 0.8rem;
}

/* Food characteristics - Blue theme */
.characteristic-input.food-char input[type="range"] {
  background: linear-gradient(to right, #e3f2fd 0%, #1976d2 100%);
  color: #1976d2;
}

.characteristic-input.food-char input[type="number"] {
  border-color: #1976d2;
  color: #1976d2;
}

.characteristic-input.food-char input[type="number"]:focus {
  outline: none;
  border-color: #1565c0;
  box-shadow: 0 0 0 0.2rem rgba(25, 118, 210, 0.25);
}

/* Wine characteristics - Red theme */
.characteristic-input.wine-char input[type="range"] {
  background: linear-gradient(to right, #ffebee 0%, #c62828 100%);
  color: #c62828;
}

.characteristic-input.wine-char input[type="number"] {
  border-color: #c62828;
  color: #c62828;
}

.characteristic-input.wine-char input[type="number"]:focus {
  outline: none;
  border-color: #b71c1c;
  box-shadow: 0 0 0 0.2rem rgba(198, 40, 40, 0.25);
}

/* Osservazioni Section */
.pairing-observations {
  margin-top: 2rem;
}

.pairing-observations textarea {
  resize: vertical;
  min-height: 80px;
}

/* Pairing Selectors (structure, affinity, pairing sliders) */
.pairing-selectors .form-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.pairing-selectors .form-label small {
  font-weight: 400;
  font-size: 0.85rem;
}

/* Wine Structure - Red theme */
#wineStructure,
#wineStructure-num {
  border-color: #c62828;
  color: #c62828;
}

#wineStructure {
  background: linear-gradient(to right, #ffebee 0%, #c62828 100%);
}

#wineStructure-num:focus {
  outline: none;
  border-color: #b71c1c;
  box-shadow: 0 0 0 0.2rem rgba(198, 40, 40, 0.25);
}

/* Food Structure - Blue theme */
#foodStructure,
#foodStructure-num {
  border-color: #1976d2;
  color: #1976d2;
}

#foodStructure {
  background: linear-gradient(to right, #e3f2fd 0%, #1976d2 100%);
}

#foodStructure-num:focus {
  outline: none;
  border-color: #1565c0;
  box-shadow: 0 0 0 0.2rem rgba(25, 118, 210, 0.25);
}

/* Aromatic Affinity and Pairing - Dynamic colors based on value */
#aromaticAffinity,
#pairing {
  transition: background 0.3s ease;
}

/* Default neutral theme for aromatic affinity and pairing */
.pairing-selectors .input-group-pairing input[type="range"] {
  background: linear-gradient(to right, #e0e0e0 0%, #333 100%);
  color: #333;
}

.pairing-selectors .input-group-pairing input[type="number"] {
  border-color: #6c757d;
  color: #495057;
  transition: border-color 0.3s ease, color 0.3s ease;
}

.pairing-selectors .input-group-pairing input[type="number"]:focus {
  outline: none;
  border-color: #495057;
  box-shadow: 0 0 0 0.2rem rgba(108, 117, 125, 0.25);
}

/* Dynamic color classes for affinity (2-4 range = red/low) */
#aromaticAffinity.affinity-0 {
  background: linear-gradient(to right, #ffebee 0%, #e57373 100%);
  color: #d32f2f;
}

#aromaticAffinity-num.affinity-0 {
  border-color: #d32f2f;
  color: #d32f2f;
}

/* Medium affinity (5-7 range = orange/medium) */
#aromaticAffinity.affinity-1 {
  background: linear-gradient(to right, #fff3e0 0%, #ffb74d 100%);
  color: #f57c00;
}

#aromaticAffinity-num.affinity-1 {
  border-color: #f57c00;
  color: #f57c00;
}

/* High affinity (8-10 range = green/high) */
#aromaticAffinity.affinity-2 {
  background: linear-gradient(to right, #e8f5e9 0%, #66bb6a 100%);
  color: #2e7d32;
}

#aromaticAffinity-num.affinity-2 {
  border-color: #2e7d32;
  color: #2e7d32;
}

/* Dynamic color classes for pairing harmony (2-4 range = red/low) */
#pairing.harmony-0 {
  background: linear-gradient(to right, #ffebee 0%, #e57373 100%);
  color: #d32f2f;
}

#pairing-num.harmony-0 {
  border-color: #d32f2f;
  color: #d32f2f;
}

/* Medium harmony (5-7 range = orange/medium) */
#pairing.harmony-1 {
  background: linear-gradient(to right, #fff3e0 0%, #ffb74d 100%);
  color: #f57c00;
}

#pairing-num.harmony-1 {
  border-color: #f57c00;
  color: #f57c00;
}

/* High harmony (8-10 range = green/high) */
#pairing.harmony-2 {
  background: linear-gradient(to right, #e8f5e9 0%, #66bb6a 100%);
  color: #2e7d32;
}

#pairing-num.harmony-2 {
  border-color: #2e7d32;
  color: #2e7d32;
}

/* Slider value labels (dynamically added by JS) */
.slider-value-label {
  display: inline-block;
  margin-left: 0.5rem;
  font-style: italic;
}

/* Dynamic color classes for affinity and pairing labels */
#aromaticAffinityLabel {
  transition: color 0.3s ease;
}

#aromaticAffinityLabel.affinity-0 {
  color: #d32f2f !important;
  font-weight: 600;
}

#aromaticAffinityLabel.affinity-1 {
  color: #f57c00 !important;
  font-weight: 600;
}

#aromaticAffinityLabel.affinity-2 {
  color: #2e7d32 !important;
  font-weight: 600;
}

#pairingLabel {
  transition: color 0.3s ease;
}

#pairingLabel.harmony-0 {
  color: #d32f2f !important;
  font-weight: 600;
}

#pairingLabel.harmony-1 {
  color: #f57c00 !important;
  font-weight: 600;
}

#pairingLabel.harmony-2 {
  color: #2e7d32 !important;
  font-weight: 600;
}

/* Action Buttons */
.pairing-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* Mobile Responsive */
@media screen and (max-width: 767px) {
  .pairing-tool {
    padding: 1rem;
  }

  .pairing-metadata .form-label {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .pairing-metadata .form-control,
  .pairing-metadata .form-select {
    font-size: 0.9rem;
  }

  .pairing-chart-layout {
    margin-top: 1rem;
  }

  .pairing-chart {
    padding: 0.5rem 0;
  }

  .sliders-panel {
    padding: 0.75rem;
    margin-bottom: 1rem;
  }

  .sliders-panel h5 {
    font-size: 1rem;
    margin-bottom: 1rem;
  }

  .pairing-inputs h5 {
    font-size: 1.1rem;
  }

  .characteristic-input {
    margin-bottom: 1rem;
  }

  .characteristic-input label {
    font-size: 0.85rem;
  }

  .input-group-pairing {
    gap: 0.75rem;
  }

  .input-group-pairing input[type="number"] {
    width: 50px;
    font-size: 0.9rem;
  }

  .pairing-actions {
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
  }
}

/* Tablet */
@media screen and (min-width: 768px) and (max-width: 991px) {
  .pairing-chart {
    padding: 1rem 0.5rem;
  }

  .sliders-panel {
    padding: 0.875rem;
  }

  .sliders-panel h5 {
    font-size: 0.95rem;
  }
}

/* Desktop - Optimize slider panels for side layout */
@media screen and (min-width: 1200px) {
  .sliders-panel {
    overflow-y: auto;
    overflow-x: hidden;
  }

  .sliders-panel::-webkit-scrollbar {
    width: 6px;
  }

  .sliders-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
  }

  .sliders-panel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
  }

  .sliders-panel::-webkit-scrollbar-thumb:hover {
    background: #555;
  }

  .characteristic-input {
    margin-bottom: 1.25rem;
  }
}