@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Couleurs de base */
  --bg-primary: #0f1114;
  --bg-secondary: #141414;
  --bg-card: #18181b;
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-hover: rgba(255, 255, 255, 0.08);
  
  /* Couleur accent principale (changeable pour thèmes) */
  --accent: #7C8CFF;
  --accent-hover: #A2B2FF;
  --accent-dark: #5B6DE6;
  --accent-light: rgba(124, 140, 255, 0.18);
  --accent-subtle: rgba(124, 140, 255, 0.08);
  --accent-bg-dark: rgba(124, 140, 255, 0.015);
  
  /* Couleurs sémantiques (basées sur l'accent) */
  --success: #30d158;
  --success-bg: var(--accent-subtle);
  --warning: #ffd60a;
  --warning-bg: rgba(251, 191, 36, 0.1);
  --error: #ff453a;
  --error-bg: rgba(248, 113, 113, 0.1);
  
  /* Texte */
  --text-primary: #f5f5f5;
  --text-secondary: #b8b8b8;
  --text-muted: #8a8a8a;
  
  /* Bordures et ombres */
  --border: rgba(255, 255, 255, 0.10);
  --border-light: rgba(255, 255, 255, 0.05);
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 32px rgba(0, 0, 0, 0.45);
  
  /* Tableaux */
  --table-header-bg: rgba(255, 255, 255, 0.05);
  --table-row-hover: rgba(255, 255, 255, 0.03);
  --table-border: rgba(255, 255, 255, 0.08);
  
  /* Espacements et tailles */
  --radius: clamp(8px, 1.5vw, 12px);
  --radius-sm: clamp(6px, 1vw, 8px);
  --spacing: clamp(12px, 2vw, 20px);
  --font-size-base: clamp(14px, 1.5vw, 16px);
  --font-size-sm: clamp(12px, 1.3vw, 14px);
  --font-size-lg: clamp(18px, 2.5vw, 24px);
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.wrap {
  max-width: min(1400px, 95vw);
  margin: clamp(16px, 4vw, 40px) auto;
  padding: var(--spacing);
}

header {
  margin-bottom: clamp(20px, 3vw, 32px);
}

.appbar { display:flex; align-items:center; justify-content: space-between; gap:12px; padding:8px 4px 4px 4px; background: transparent; border-bottom: none; border-radius: 0; margin-bottom: 0; }
.appbar .brand { display:flex; align-items:center; gap:10px; }
.appbar .brand h1 { margin:0; font-size: 32px; font-weight: 600; letter-spacing:-0.02em; }
.appbar .tagline { font-size: 12px; color: var(--text-muted); }

.logo {
  width: clamp(40px, 8vw, 56px);
  height: clamp(40px, 8vw, 56px);
  border-radius: 10px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: clamp(20px, 4vw, 28px);
  color: var(--accent);
  flex-shrink: 0;
}

h1 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.small {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
  gap: var(--spacing);
}

.grid.single-column {
  grid-template-columns: 1fr;
  max-width: 100%;
}

.grid.single-column > * {
  min-width: 0;
  max-width: 100%;
}

.card { background: transparent; border: none; border-radius: var(--radius); padding: clamp(16px, 2.5vw, 24px); box-shadow: none; overflow: hidden; }

.card:hover {
  border-color: rgba(212, 165, 116, 0.25);
}

h3 {
  font-size: clamp(20px, 2.6vw, 26px);
  font-weight: 700;
  margin: 0 0 8px 0;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}
h3::before {
  content: '';
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  filter: drop-shadow(0 0 10px rgba(124,140,255,0.35));
}
/* Remove bullet for h3 with icons */
h3:has(.icon)::before {
  display: none;
}

label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Hydration label recommendation styling */
label[for="targetHydro"] { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }
label[for="targetHydro"] .reco { color: var(--accent); font-weight: 700; white-space: nowrap; }

input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: none;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 400;
  font-family: inherit;
  transition: all 0.2s ease;
  outline: none;
  min-height: 40px;
  color-scheme: dark;
}

/* Force calendar picker to match theme */
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

/* Input avec suffixe (%, h, °C) */
.input-with-suffix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-suffix input {
  padding-right: 45px;
}

.input-suffix {
  position: absolute;
  right: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
  user-select: none;
}

/* Hide spin buttons for cleaner look */
input[type="number"] {
  text-align: left;
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.input-with-suffix input[type="number"] {
  padding-right: 35px;
  padding-left: 12px;
  text-align: left;
}

/* Conteneur pour les flèches custom */
.input-with-suffix::after {
  content: '';
  position: absolute;
  right: 35px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 32px;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

input:focus, select:focus {
  border-color: transparent;
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 0 2px var(--accent-light);
}

input:hover, select:hover {
  border-color: var(--accent);
}

input[type="time"] {
  color-scheme: dark;
}

/* Masquer les flèches des inputs number */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

button {
  background: var(--accent);
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  color: var(--bg-primary);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: scale(0.98);
}

.flex-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  .flex-inputs {
    grid-template-columns: 1fr;
  }
}

/* Mettre les 6 paramètres (hydratation/levain/sel + date/durée/temp) SUR UNE LIGNE */
.flex-inputs.parameters-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 16px;
  width: 100%;
  margin-top: 32px;
}

@media (max-width: 1200px) {
  .flex-inputs.parameters-row {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }
}

@media (max-width: 980px) {
  .flex-inputs.parameters-row {
    grid-template-columns: repeat(2, minmax(200px, 1fr));
  }
}

@media (max-width: 640px) {
  .flex-inputs.parameters-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

.flex-inputs > div {
  display: flex;
  flex-direction: column;
}

.flex-inputs.add-flour {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}

.flex-inputs.add-flour select {
  flex: 1 1 150px;
  min-width: 120px;
}

.flex-inputs.add-flour input {
  flex: 0 1 90px;
}

.flex-inputs.add-flour input:last-of-type {
  flex: 0 1 110px;
}

.flex-inputs.add-flour button {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 10px 16px;
}

/* Utilitaire pour pousser les boutons Options/Aide à droite sur desktop */
.flex-inputs.add-flour .spacer { flex: 1 1 auto; min-width: 0; }

/* Toast notifications responsive */
@media (max-width: 768px) {
  #toast-container {
    top: 10px !important;
    right: 10px !important;
    left: 10px !important;
    max-width: calc(100vw - 20px) !important;
  }
  
  .toast {
    min-width: auto !important;
    max-width: 100% !important;
  }
}

/* Mobile: réduire la taille du tableau des farines */
@media (max-width: 640px) {
  .flours-list table {
    font-size: 12px;
  }
  
  .flours-list th,
  .flours-list td {
    padding: 6px 4px;
  }
  
  .flours-list button {
    padding: 4px 8px;
    font-size: 11px;
  }
}

@media (max-width: 720px) {
  .flex-inputs.add-flour {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: stretch;
  }

  .flex-inputs.add-flour select,
  .flex-inputs.add-flour button,
  .flex-inputs.add-flour input {
    width: 100%;
    min-width: 0;
  }

  .flex-inputs.add-flour select,
  #addFlourBtn {
    grid-column: span 2;
  }

  #flourWeightInput,
  #flourProteinInput {
    grid-column: span 1;
  }

  .flex-inputs.add-flour input:last-of-type {
    grid-column: span 1;
  }

  .flex-inputs.add-flour .spacer {
    display: none;
  }

  #saveRecipeBtn,
  #loadRecipeBtn,
  #flourSettingsBtn,
  #helpBtn {
    grid-column: span 1;
  }

  .flex-inputs.add-flour button {
    justify-content: center;
    font-size: 13px;
    padding: 10px 14px;
  }
}

.controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 16px;
  align-items: center;
}

@media (max-width: 640px) {
  .controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 12px;
  }
  
  .controls > div,
  .controls > label {
    width: 100%;
  }
}

.controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0;
  text-transform: none;
  font-size: 11px;
  letter-spacing: 0;
  font-weight: 400;
}

.controls input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Ligne d'actions sous les cases à cocher */
.actions-row { display:flex; gap:12px; flex-wrap:wrap; align-items:center; margin-top: 20px; }
.actions-note { 
  margin-top: 12px; 
  padding: 12px 16px;
  background: var(--accent-bg-dark);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: clamp(12px, 2vw, 16px);
  font-size: var(--font-size-sm);
  background: var(--accent-bg-dark);
  border: none;
  border-radius: 12px;
  overflow: hidden;
}

th, td {
  padding: clamp(10px, 1.6vw, 14px);
  text-align: left;
  border-bottom: 1px solid var(--table-border);
}

th {
  background: var(--table-header-bg);
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: clamp(11px, 1.2vw, 12px);
}

tbody tr:hover {
  background: var(--table-row-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Flours table column alignment & widths */
.table-flours { table-layout: auto; }
.table-flours th:nth-child(2),
.table-flours td:nth-child(2),
.table-flours th:nth-child(3),
.table-flours td:nth-child(3),
.table-flours th:nth-child(4),
.table-flours td:nth-child(4),
.table-flours th:nth-child(5),
.table-flours td:nth-child(5) { text-align: right; white-space: nowrap; }
.table-flours th:nth-child(1) { width: 40%; }
.table-flours th:nth-child(2) { width: 100px; }
.table-flours th:nth-child(3) { width: 110px; }
.table-flours th:nth-child(4) { width: 130px; }
.table-flours th:nth-child(5) { width: 120px; }
.table-flours th:nth-child(6),
.table-flours td:nth-child(6) { text-align: right; width: 1%; white-space: nowrap; }

/* Recipe table column alignment & widths */
.table-recipe th:nth-child(2),
.table-recipe td:nth-child(2),
.table-recipe th:nth-child(3),
.table-recipe td:nth-child(3) { text-align: right; white-space: nowrap; }
.table-recipe th:nth-child(1) { width: 50%; }
.table-recipe th:nth-child(2) { width: 160px; }
.table-recipe th:nth-child(3) { width: 120px; }
/* Themed divider before TOTAL row */
.table-recipe .total-row td { border-top: 1px solid var(--border); }

.flours-list {
  max-height: 300px;
  overflow-y: auto;
  overflow-x: auto;
  margin-top: clamp(12px, 2vw, 16px);
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

.flours-list::-webkit-scrollbar {
  width: 6px;
}

.flours-list::-webkit-scrollbar-track {
  background: transparent;
}

.flours-list::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

.result {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius);
  padding: clamp(16px, 2.5vw, 24px);
  margin-top: 12px;
  animation: slideIn 0.3s ease;
}

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

h4 {
  font-size: clamp(18px, 2.2vw, 22px);
  font-weight: 700;
  margin: 8px 0 12px 0;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 8px;
}

h4 .icon { margin-right: 6px; opacity: .9; }

.note { background: transparent; border: none; border-radius: 8px; padding: 10px 12px; }
.debug-block { background: transparent; border: none; border-radius: 8px; padding: 10px 12px; }

.footer {
  margin-top: var(--spacing);
  padding-top: clamp(12px, 2vw, 16px);
  border-top: none;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

hr {
  border: none;
  border-top: none;
  margin: var(--spacing) 0;
}

@media (max-width: 640px) {
  .flex-inputs > * {
    min-width: 100%;
  }
  
  .controls button {
    width: 100%;
  }
  
  .actions-row {
    margin-top: 16px;
  }
  
  /* Section Chat IA - meilleurs espacements sur mobile */
  .card h3 {
    margin-bottom: 12px;
  }
  
  .card .small {
    margin-bottom: 12px;
  }
  
  .card textarea {
    margin-bottom: 12px;
  }
}

.planning-step {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-bottom: none;
  transition: background 0.2s ease;
}

@media (max-width: 640px) {
  .planning-step {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
  }
}

.planning-step:hover {
  background: transparent;
}

.planning-step.completed {
  opacity: 0.5;
}

.planning-step input[type="checkbox"] {
  width: 15px;
  height: 15px;
  min-width: 15px;
  min-height: 15px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 2px;
  position: relative;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
}

.planning-step input[type="checkbox"]:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

.planning-step input[type="checkbox"]:checked::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 1px;
  width: 3px;
  height: 7px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.planning-step .step-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.planning-step .step-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.planning-step .step-time {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.planning-step .step-time-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.planning-step .step-time-value {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}

.planning-step .step-time-edit {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.planning-step .step-time-edit input[type="time"] {
  background: var(--accent-subtle);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.planning-step .step-time-edit input[type="time"]:focus {
  box-shadow: 0 0 0 2px var(--accent-light);
}

.planning-step .step-time-edit button.step-time-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-bg-dark);
  color: var(--accent);
  border-radius: 999px;
  border: 1px solid var(--accent-light);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.planning-step .step-time-edit button.step-time-save:hover {
  background: var(--accent-light);
}

.planning-step .step-time-edit button.step-time-save .icon {
  width: 14px;
  height: 14px;
}

.planning-step .step-time-edit .edit-hint {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--text-muted);
}

.planning-step .step-time-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.planning-step .step-time-edit-btn .icon {
  width: 16px;
  height: 16px;
}

.planning-step .step-time-edit-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.planning-step.editing {
  background: var(--accent-subtle);
  border-radius: 12px;
}

.planning-step .step-time-edit .edit-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.planning-step .step-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.timer-btn {
  background: var(--accent);
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--bg-primary);
  font-weight: 600;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: center;
  opacity: 0.9;
}

.timer-btn:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.timer-btn.active {
  background: var(--accent);
  color: var(--bg-primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 1;
  animation: pulse-timer 2s ease-in-out infinite;
}

@keyframes pulse-timer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

.timer-btn.finished {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: default;
  pointer-events: none;
  opacity: 0.6;
}

.timer-btn.finished:hover {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transform: none;
  box-shadow: none;
}

.timer-stop-btn {
  background: #ef4444;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0.9;
}

.timer-stop-btn:hover {
  background: #dc2626;
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

.timer-stop-btn .icon {
  width: 14px;
  height: 14px;
}

@media (max-width: 640px) {
  .planning-step {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
  }
  
  .timer-btn {
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: center;
    font-size: 11px;
    padding: 6px 10px;
  }
  
  .timer-stop-btn {
    grid-column: 3;
    grid-row: 2;
    align-self: start;
    font-size: 11px;
    padding: 4px 8px;
    margin-left: 0;
  }
}
.action-buttons {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.action-buttons button {
    padding: 4px 8px;
    border-radius: 6px;
    border: none;
    font-size: 12px;
    cursor: pointer;
}

.delete-flour-btn {
    background: rgba(255, 80, 80, 0.2);
    color: rgb(255, 123, 123);
}

.reset-flour-btn {
    background: rgba(80, 126, 255, 0.2);
    color: rgb(123, 156, 255);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --bg-card: #ffffff;
    --text-primary: #1b1b1b;
    --text-secondary: #3f3f3f;
    --text-muted: #6b6b6b;
    --border: rgba(0,0,0,0.08);
    --accent-bg-dark: rgba(124, 140, 255, 0.01);
  }
}

:where(button, [role="button"], input, select, textarea, a):focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px rgba(212,165,116,0.35);
}

.btn {
  background: var(--accent);
  border: 1px solid transparent;
  color: var(--bg-primary);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  font-family: 'Manrope', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .05s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: .6; pointer-events: none; }

.btn--primary { background: var(--accent); color: var(--bg-primary); }
.btn--secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); }
.btn--secondary:hover { background: var(--bg-hover); color: var(--accent); }
.btn--subtle {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn--subtle:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn--ghost:hover { color: var(--text-primary); background: var(--bg-hover); }
.btn--danger { background: rgba(255,80,80,0.2); color: rgb(255,123,123); }
.btn--danger:hover { background: rgba(255,80,80,0.3); }

.btn--icon { padding: 6px 8px; font-size: 18px; line-height: 1; }
.btn--sm { padding: 8px 12px; font-size: 13px; }
.btn--xs { padding: 4px 8px; font-size: 12px; }

.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.125em; fill: currentColor; }
.btn .icon { margin-right: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.banner { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 2000; background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%); color: #ffffff; padding: 16px; box-shadow: none; }
.banner__inner { max-width: 800px; margin: 0 auto; display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.banner__label { font-weight: 600; font-size: 15px; }

.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 1000; overflow-y: auto; }
.modal__dialog { width: calc(100% - 32px); max-width: 700px; margin: 40px auto; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(25, 29, 38, 0.55) 0%, rgba(20, 24, 32, 0.60) 100%);
  border: none;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(28px) saturate(1.5);
  -webkit-backdrop-filter: blur(28px) saturate(1.5);
}
.modal--md .modal__dialog { max-width: 600px; }
.modal__header { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: none; }
.modal__body { padding: 16px 24px; overflow-x: auto; }

/* Fix table overflow in modal on mobile */
@media (max-width: 768px) {
  .modal__body {
    padding: 12px 8px;
  }
  
  .modal__dialog {
    width: calc(100% - 16px);
    margin: 20px auto;
  }
  
  .modal__body table {
    width: 100%;
    font-size: 12px;
  }
  
  .modal__body table th,
  .modal__body table td {
    padding: 6px 3px;
    white-space: nowrap;
  }
  
  .modal__body table input {
    width: 100%;
    max-width: 45px;
    padding: 4px 2px;
    font-size: 12px;
    text-align: center;
  }
  
  .modal__body table th {
    font-size: 11px;
  }
}
.modal__footer { display: flex; justify-content: flex-end; gap: 12px; padding: 20px 24px; border-top: none; }

.segmented { display: inline-flex; align-items: center; gap: 6px; padding: 0; background: transparent; border: none; border-radius: 0; font-size: 11px; }
.segmented label { display: inline-flex; align-items: center; gap: 0; padding: 0; border-radius: 999px; cursor: pointer; margin: 0; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--text-secondary); }
.segmented input[type="radio"] { appearance: none; position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.segmented span { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; border: none; transition: all .15s ease; }
.segmented input[type="radio"]:checked + span { color: var(--bg-primary); background: var(--accent); border-color: transparent; }

.input-affix { position: relative; display: inline-flex; align-items: center; }
.input-affix input { padding-right: 28px; padding-left: 8px; text-align: left; }
.input-affix .suffix { position: absolute; right: 8px; color: var(--text-secondary); font-size: 13px; pointer-events: none; }

/* Inputs compacts pour gagner de la place dans les options (frigo/fermentolyse) */
.options-inline .input-affix input { width: 50px; padding: 4px 22px 4px 6px; font-size: 13px; }
#frigoOptions .input-affix input { width: 45px; }
#fermentolyseOptions .input-affix input { width: 50px; padding-right: 26px; }
.options-inline .input-affix .suffix { right: 6px; font-size: 11px; pointer-events: none; }

/* Hide spin buttons on small inputs too */
.options-inline input[type="number"]::-webkit-outer-spin-button,
.options-inline input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

/* Space the planning title after the recipe table */
.result table + h4 { margin-top: 16px; }

.hidden { display: none !important; }
.options-inline { display: flex; align-items: center; gap: 4px; }
.nums { font-variant-numeric: tabular-nums; }

.sticky-actions {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  display: none;
  gap: 8px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(20,20,20,0.9) 40%);
  border-top: 1px solid var(--border);
  backdrop-filter: saturate(1.2) blur(6px);
}
@media (max-width: 640px) {
  .sticky-actions { display: none !important; }
}

/* Pulse animation for notification focus */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 var(--accent);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 0 0 10px rgba(212, 165, 116, 0);
  }
}

/* Custom header - professional and classy */
.custom-header {
  background: transparent;
  border: none;
  padding: 16px 0 20px 0;
  margin-bottom: 20px;
  margin-left: calc(-1 * var(--wrap-padding, 20px));
  margin-right: calc(-1 * var(--wrap-padding, 20px));
  position: relative;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: none;
  margin: 0;
  padding: 0 clamp(16px, 3vw, 24px);
  position: relative;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 24px;
}

.bread-icon {
  width: 140px;
  height: 140px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
}

.header-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.header-title {
  font-family: 'Brush Script MT', 'Segoe Script', cursive, sans-serif;
  font-size: 72px;
  font-weight: 400;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.1;
  letter-spacing: 1px;
}

.header-subtitle {
  font-family: 'Brush Script MT', 'Segoe Script', cursive, sans-serif;
  font-size: 30px;
  color: var(--text-secondary);
  margin: 0;
  font-weight: 300;
  font-style: italic;
}

/* Header actions container - 2 rows layout */
.header-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.header-actions-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .custom-header {
    padding: 12px 0 16px 0;
    margin-bottom: 16px;
  }
  
  .header-content {
    padding: 0 12px;
  }
  
  .header-logo {
    gap: 12px;
  }
  
  .bread-icon {
    width: 70px;
    height: 70px;
  }
  
  .header-title {
    font-size: 38px;
  }
  
  .header-subtitle {
    font-size: 17px;
  }
  
  .header-actions {
    gap: 4px;
  }
  
  .header-actions-row {
    gap: 6px;
  }
}

/* Theme toggle buttons */
.theme-toggle-btn {
  opacity: 0.7;
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

.theme-toggle-btn svg {
  display: block;
}

/* Donate button with pulsing heart animation */
.donate-btn {
  position: relative;
}

.donate-btn svg {
  animation: heartbeat 2s ease-in-out infinite;
}

.donate-btn:hover svg {
  animation: heartbeat-fast 0.6s ease-in-out infinite;
}

/* Donate tooltip message */
.donate-tooltip {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  background: var(--accent);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  animation: showDonateMessage 5s ease-in-out;
  z-index: 10000;
}

.donate-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 12px;
  border: 6px solid transparent;
  border-top-color: var(--accent);
}

@keyframes showDonateMessage {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  10%, 90% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes heartbeat {
  0%, 100% {
    transform: scale(1);
  }
  10% {
    transform: scale(1.2);
  }
  20% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.2);
  }
  40% {
    transform: scale(1);
  }
}

@keyframes heartbeat-fast {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
}

/* Donate modal message styling */
.donate-message {
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 20px;
}

/* Tooltips */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  padding: 10px 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease 1s, transform 0.3s ease 1s;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  line-height: 1.5;
  max-width: 250px;
  text-align: center;
}

[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* Disable tooltips on mobile/touch devices */
@media (max-width: 768px), (hover: none) {
  [data-tooltip]::before {
    display: none !important;
  }
  
  [data-tooltip]:hover::before {
    display: none !important;
  }
}

/* Chat container styling */
.chat-container {
  background: var(--bg-card);
  box-shadow: var(--shadow);
  padding: clamp(16px, 2.5vw, 24px);
}

.chat-textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.chat-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* Custom notifications */
.custom-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  min-width: 300px;
  max-width: 500px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10000;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-notification.show {
  opacity: 1;
  transform: translateY(0);
}

.custom-notification__icon {
  font-size: 24px;
  flex-shrink: 0;
}

.custom-notification__message {
  flex: 1;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

.custom-notification__close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.custom-notification__close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.custom-notification--success {
  border-left: 3px solid var(--success);
}

.custom-notification--error {
  border-left: 3px solid var(--error);
}

.custom-notification--warning {
  border-left: 3px solid var(--warning);
}

.custom-notification--info {
  border-left: 3px solid var(--accent);
}

/* Custom confirm dialog */
.custom-confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.custom-confirm-overlay.show {
  opacity: 1;
}

.custom-confirm {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-confirm.show {
  opacity: 1;
  transform: scale(1);
}

.custom-confirm__message {
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.custom-confirm__buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .actions-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .actions-row .btn,
  .sticky-actions .btn {
    font-size: 14px;
    padding: 12px 16px;
  }

  .actions-row .btn:last-child {
    grid-column: span 2;
  }
}

/* Session Tabs */
.session-tabs-container {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 clamp(12px, 3vw, 24px);
}

.session-tabs-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.session-tabs-wrapper::-webkit-scrollbar {
  display: none;
}

.session-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.session-tabs::-webkit-scrollbar {
  display: none;
}

.session-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-width: fit-content;
}

.session-tab:hover {
  background: var(--bg-hover);
}

.session-tab.active {
  border-bottom-color: var(--accent);
  background: var(--accent-subtle);
}

.session-tab-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  cursor: pointer;
}

.session-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.session-tab.active .session-name {
  color: var(--accent);
}

.session-flours {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.session-tab-menu {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
  opacity: 0;
}

.session-tab:hover .session-tab-menu {
  opacity: 1;
}

.session-tab-menu:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.session-new-btn {
  background: var(--accent-subtle);
  border: 1px dashed var(--accent);
  color: var(--accent);
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.session-new-btn:hover {
  background: var(--accent-light);
  border-style: solid;
}

/* Session Context Menu */
.session-context-menu {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  padding: 4px;
  z-index: 1000;
  min-width: 180px;
}

.session-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 14px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.session-menu-item:hover {
  background: var(--bg-hover);
}

.session-menu-item.danger {
  color: var(--error);
}

.session-menu-item.danger:hover {
  background: var(--error-bg);
}

.session-menu-item .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Notification options styling */
.notification-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 12px;
}

.notification-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.notification-option input[type="checkbox"] {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  position: relative;
  flex-shrink: 0;
  margin-top: 4px;
  transition: all 0.2s ease;
}

.notification-option input[type="checkbox"]:hover {
  border-color: var(--accent);
}

.notification-option input[type="checkbox"]:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

.notification-option input[type="checkbox"]:checked::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.notification-option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notification-option-text label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

.notification-option-text p {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}


@media (max-width: 640px) {
  .session-tabs-container {
    padding: 0 12px;
  }
  
  .session-tab {
    padding: 8px 10px;
  }
  
  .session-name {
    font-size: 13px;
  }
  
  .session-flours {
      font-size: 10px;
    }
  }
  
  /* --- Multi-Session Toggle --- */
  #multiSessionToggle {
      position: absolute;
      top: 15px;
      left: 15px;
      width: 20px;
      height: 20px;
      background: transparent;
      border: none;
      cursor: pointer;
      z-index: 10000;
      opacity: 0;
  }
  
  #multiSessionToggle:hover {
      opacity: 0.8;
  }
  
  #sessionTabs {
      display: none; /* Caché par défaut */
  }
  
  body.multi-session-active #sessionTabs {
      display: block; /* Affiché si le mode est actif */
  }