/*
 * Weight: the monthly calendar of the weight tab (moved from style.css,
 * specs/009 Ondata G). Only the declarations that were still winning moved:
 * what style-redesign.css overrode stayed out, since this sheet loads after it.
 */

/* Variazione del peso, calendario e storico (da style.css): prima delle
   regole del calendario qui sotto, come nell'ordine di prima. */
.weight-increase {
  color: var(--trend-up);
}

.weight-decrease {
  color: var(--trend-down);
}

.weight-neutral {
  color: var(--trend-flat);
}

.weight-change-good {
  color: var(--trend-down);
}

.weight-change-bad {
  color: var(--trend-up);
}

.weight-calendar-day:hover:not(.future) {
  transform: scale(1.15) translateY(-2px);
  z-index: var(--z-dropdown);
  border-color: var(--brand-300);
  box-shadow: var(--elevation-2);
}

.weight-calendar-day.future {
  background: var(--surface-sunken);
  /* --neutral-300 su questo fondo faceva 1.76:1: un numero di calendario e'
     contenuto, non decorazione, e a quel contrasto non si legge. Il grigio
     resta il segnale che il giorno non e' ancora arrivato, insieme al corsivo
     e all'assenza di bordo pieno. */
  color: var(--neutral-600);
  border: 2px solid var(--surface-sunken);
  cursor: default;
  font-style: italic;
}

.weight-calendar-day.no-data {
  background: var(--surface-card);
  color: var(--neutral-600);
  border: 2px solid var(--border-subtle);
}

.weight-calendar-day.today {
  font-weight: 800;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.history-weight {
  font-weight: bold;
  font-size: 1.1rem;
  margin-right: 0.5rem;
  white-space: nowrap;
  color: var(--neutral-900);
  font-family: var(--font-sans);
}

/* Advanced Insights Section */
.advanced-insights-section {
  background: var(--surface-card);
  backdrop-filter: blur(20px);
  padding: 32px;
  border-radius: 20px;
  box-shadow:
    var(--elevation-2);
  margin-bottom: 30px;
  border: 1px solid var(--border-subtle);
  position: relative;
}

.advanced-insights-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-hairline);
  background-size: 200% 100%;
  animation: gradientShift 3s ease infinite;
  border-radius: 20px 20px 0 0;
}

.advanced-insights-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Weight Calendar Section */
.weight-calendar-section {
  margin-bottom: 30px;
  backdrop-filter: blur(20px);
  position: relative;
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--elevation-2);
  border: 1px solid var(--neutral-200);
}

.weight-calendar-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-hairline);
  background-size: 200% 100%;
  animation: gradientShift 3s ease infinite;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.weight-month-selector {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--neutral-900);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 200px;
  box-shadow: var(--elevation-1);
  border: 2px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
}

.weight-month-selector:hover {
  background-color: var(--neutral-50);
  transform: translateY(-2px);
  box-shadow: var(--elevation-2);
  border-color: var(--brand-400);
}

.weight-month-selector:focus {
  outline: none;
  /* The indicator that replaces the outline (was in style-redesign.css). */
  border-color: var(--brand-500);
  box-shadow: var(--focus-ring);
}

.weight-calendar-container {
  backdrop-filter: blur(10px);
  padding: 20px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  box-shadow: var(--elevation-2);
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-xl);
}

.weight-calendar-header-month {
  text-align: center;
  margin-bottom: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--neutral-900);
  letter-spacing: 0.5px;
}

/* Sette colonne che dividono lo spazio invece di 40px fissi: a 375px il
   contenitore lascia ~270px utili e sette celle fisse da 38px piu' i gap ne
   chiedevano 284, cosi' la griglia usciva dalla card. */
.weight-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.weight-calendar-day-header {
  text-align: center;
  padding: 6px 2px;
  font-size: 0.7rem;
  border-radius: 8px;
  height: 28px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Le celle sono <button>: si aprono col dettaglio del giorno e devono stare
   nel giro della tabulazione. `font-family: inherit` perche' il browser darebbe
   loro il proprio font, e la griglia lo mostrerebbe subito. */
.weight-calendar-day {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  min-width: 0;
  aspect-ratio: 1;
  backdrop-filter: blur(5px);
  box-sizing: border-box;
  flex-shrink: 0;
  box-shadow: var(--elevation-1);
  flex-direction: column;
  gap: 1px;
  line-height: 1;
}

/* Giorni con dati */
.weight-calendar-day:not(.future):not(.no-data):not(.today) {
  font-weight: 700;
  box-shadow: var(--elevation-2);
}

/* Numero del giorno e variazione in colonna. La variazione e' testo col segno
   e sta a 0.6rem: a 38 px di cella l'unita' non entra, per questo la cella
   mostra "-0,4" e il nome accessibile dice "-0,4 kg". */

/* I giorni prima dell'1 tengono il posto nella griglia ma non si vedono:
   disegnati come cella vuota sembravano un giorno senza dati. */
.weight-calendar-day.is-blank {
  visibility: hidden;
}

.weight-calendar-delta {
  font-size: 0.6rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Lo stato lo dichiara la cella (data-trend), il colore lo legge dai token
   semantici: in scuro i token success e danger hanno i loro valori, nessuna
   regola da duplicare. --cell-strength (0.2..1) mescola il fondo semantico
   col fondo della scheda: l'intensita' e' un numero, non un colore. */
.weight-calendar-day[data-trend="toward"],
.weight-calendar-swatch[data-trend="toward"] {
  --trend-surface: var(--success-surface);
  --trend-border: var(--success-border);
  --trend-text: var(--success-text);
}

.weight-calendar-day[data-trend="away"],
.weight-calendar-swatch[data-trend="away"] {
  --trend-surface: var(--danger-surface);
  --trend-border: var(--danger-border);
  --trend-text: var(--danger-text);
}

.weight-calendar-day[data-trend="steady"],
.weight-calendar-swatch[data-trend="steady"] {
  --trend-surface: var(--surface-sunken);
  --trend-border: var(--border-subtle);
  --trend-text: var(--neutral-700);
}

.weight-calendar-day[data-trend] {
  --cell-strength: 1;
  background-color: color-mix(in srgb, var(--trend-surface) calc(var(--cell-strength) * 100%), var(--surface-card));
  border-color: color-mix(in srgb, var(--trend-border) calc(var(--cell-strength) * 100%), var(--border-subtle));
  color: var(--trend-text);
}

.weight-calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
  color: var(--neutral-700);
}

.weight-calendar-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.weight-calendar-legend-note {
  flex-basis: 100%;
}

.weight-calendar-swatch {
  width: 14px;
  height: 14px;
  box-sizing: border-box;
  border-radius: 4px;
  border: 2px solid var(--trend-border);
  background-color: var(--trend-surface);
}

/* Today's cell keeps its own border over the trend colours of the rules
   above (from style-redesign.css, where it came after them). */
.weight-calendar-day.today {
  border: 2px solid var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
  animation: none; /* Remove annoying pulse */
}

/* History Section */
.history-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

/* Custom scrollbar per la lista storico */
.history-list::-webkit-scrollbar {
  width: 8px;
}

.history-list::-webkit-scrollbar-track {
  background: var(--surface-sunken);
  border-radius: 10px;
}

.history-list::-webkit-scrollbar-thumb {
  border-radius: 10px;
  background-color: var(--brand-800);
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 18px 20px;
  margin-bottom: 10px;
  backdrop-filter: blur(10px);
  box-shadow: var(--elevation-1);
  position: relative;
  overflow: hidden;
  background: var(--surface-card);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-xl);
  transition: all var(--transition-base);
}

.history-item > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}

.history-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  /* Longhand: the shorthand would reset the background-color that
     style-redesign.css sets for this pseudo-element. */
  background-image: var(--gradient-brand);
  opacity: 0;
  transition: opacity 0.3s ease;
  background-color: var(--ink-400);
}

.history-item:hover {
  background-color: var(--surface-sunken);
  transform: translateX(6px);
  border-color: var(--brand-200);
  box-shadow: var(--elevation-2);
}

.history-item:hover::before {
  opacity: 1;
}

.history-item:last-child {
  margin-bottom: 0;
}

.history-date {
  font-size: 0.95rem;
  letter-spacing: 0.3px;
  white-space: nowrap;
  color: var(--neutral-900);
  font-weight: var(--font-semibold);
}

.history-change {
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: var(--elevation-1);
  transition: all 0.3s ease;
  white-space: nowrap;
  display: inline-block;
  width: fit-content;
}

.history-change:hover {
  transform: scale(1.08);
  box-shadow: var(--elevation-2);
}

/* Target Weight Modal Styles */
.target-weight-modal {
  background: var(--surface-card);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  width: 90%;
  max-width: 470px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow:
    var(--elevation-3);
  border: 1px solid var(--border-subtle);
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.target-weight-modal::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-hairline);
  background-size: 200% 100%;
  animation: gradientShift 3s ease infinite;
  border-radius: 20px 20px 0 0;
}

.target-weight-modal .form-group {
  margin-bottom: 20px;
}

.target-weight-modal .form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--neutral-700);
  font-weight: 500;
  font-size: 14px;
}

.target-weight-modal .form-group input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--neutral-200);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface-card);
  transition: border-color 0.3s;
}

.target-weight-modal .form-group input:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--focus-ring);
}

.target-weight-modal .form-hint {
  display: block;
  margin-top: 5px;
  color: var(--neutral-600);
  font-size: 12px;
}

.target-weight-success {
  background: var(--success-surface);
  border: 1px solid var(--success-surface);
  color: var(--success-text);
  padding: 12px;
  border-radius: 8px;
  margin-top: 15px;
  text-align: center;
}

/* Weight Day Details Modal — allineato al design system v2.0 */
.weight-day-modal {
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 420px;
  overflow: hidden;
  box-shadow: var(--elevation-3);
  border: 1px solid var(--neutral-200);
  animation: slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.weight-day-modal .modal-content {
  padding: var(--space-6);
}

.weight-day-info {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.weight-day-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--neutral-200);
}

.weight-day-stat:last-child {
  border-bottom: none;
}

.weight-day-stat .stat-label {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--neutral-600);
}

.weight-day-stat .stat-value {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--neutral-900);
}

/* Narrow screens: after the base rules above, as they were in style.css. */
@media (max-width: 768px) {
  .weight-month-selector {
    width: 100%;
  }

  .weight-calendar-container {
    padding: 12px;
  }

  .weight-calendar-grid {
    gap: 3px;
  }

  .weight-calendar-day {
    font-size: 0.75rem;
    border-radius: 8px;
  }

  .weight-calendar-day-header {
    height: 26px;
    font-size: 0.65rem;
    padding: 4px 1px;
    border-radius: 6px;
  }
}

/* Da style-redesign.css */

.weight-calendar-day-header {
  color: var(--brand-700);
  background: var(--brand-50);
  font-weight: var(--font-semibold);
}

.weight-calendar-day {
  border: 1px solid var(--neutral-200);
  background: var(--surface-card);
  transition: all var(--transition-base);
}

.history-change.positive,
.history-change.good {
  background: var(--success-surface);
  color: var(--success-text);
  border: 1px solid var(--success);
}

.history-change.negative,
.history-change.bad {
  background: var(--danger-surface);
  color: var(--danger-text);
  border: 1px solid var(--danger);
}

.history-change.neutral {
  background: var(--neutral-100);
  color: var(--neutral-600);
  border: 1px solid var(--neutral-300);
}

/* BARRA DI SCORRIMENTO DELLO STORICO (da style-redesign.css) */

.history-list::-webkit-scrollbar-thumb:hover {
  background-color: var(--brand-700);
}
