/*
  Mémoire de Saveurs — Refonte visuelle complète
  Concept: Carnet d'atelier culinaire (papier, épices, notes)
*/

@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --font-sans: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --font-serif: "Fraunces", "Times New Roman", serif;

  --ink-900: #1f1a14;
  --ink-800: #2d251d;
  --ink-700: #3b3127;
  --ink-600: #54463a;
  --ink-500: #6b5b4e;
  --ink-400: #8c7a6c;
  --ink-300: #b9a899;

  --paper-100: #fff9f2;
  --paper-200: #fbf1e6;
  --paper-300: #f3e6d6;
  --paper-400: #eadbc9;

  --herb-700: #1f4638;
  --herb-600: #2c5c4a;
  --herb-500: #3d6f5a;
  --herb-200: #d7e7df;

  --spice-700: #a85a2c;
  --spice-600: #bf6a35;
  --spice-500: #d1793a;

  --clay-700: #8f3b2a;
  --clay-500: #b4513b;

  --shadow-sm: 0 6px 18px rgba(31, 26, 20, 0.08);
  --shadow-md: 0 16px 40px rgba(31, 26, 20, 0.12);
  --shadow-lg: 0 30px 80px rgba(31, 26, 20, 0.18);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --transition-fast: 150ms ease;
  --transition-med: 250ms ease;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink-900);
  background:
    radial-gradient(900px 480px at 0% -20%, rgba(255, 240, 220, 0.8), transparent 70%),
    radial-gradient(700px 400px at 100% 0%, rgba(213, 236, 225, 0.8), transparent 60%),
    repeating-linear-gradient(135deg, rgba(255,255,255,0.35), rgba(255,255,255,0.35) 6px, transparent 6px, transparent 12px),
    linear-gradient(160deg, #faf3ea 0%, #f6ecdf 40%, #f0e4d6 100%);
}

.app-signature {
  margin-top: 20px;
  padding: 0 16px 18px;
  font-size: 11px;
  opacity: 0.55;
  text-align: center;
  color: var(--ink-600);
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  margin: 0 0 10px;
  color: var(--ink-900);
  letter-spacing: 0.2px;
}

p { line-height: 1.6; color: var(--ink-700); }

.muted { color: var(--ink-500); }

::selection { background: rgba(209, 121, 58, 0.25); }

*:focus-visible {
  outline: 2px solid var(--spice-500);
  outline-offset: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: #fff;
  color: var(--ink-800);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-primary {
  background: linear-gradient(135deg, #1f4638 0%, #3d6f5a 100%);
  color: #fff;
}

.btn-secondary {
  background: #f5ecdf;
  color: var(--ink-800);
  border: 1px solid #eadbc9;
  box-shadow: none;
}

.btn-danger {
  background: linear-gradient(135deg, #8f3b2a 0%, #c15944 100%);
  color: #fff;
}

.btn-ghost {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  box-shadow: none;
}

.btn-small { padding: 8px 10px; font-size: 13px; }

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: #fff;
  border: 1px solid var(--paper-400);
  color: var(--ink-700);
  box-shadow: var(--shadow-sm);
}

.alert-success, .flash-success {
  background: #e6f3ec;
  border-color: #c4e0d0;
  color: #1f5c43;
}

.alert-error {
  background: #fde8e3;
  border-color: #f2b8aa;
  color: #8b2f1f;
}

/* Dialog */
.dialog {
  border: none;
  border-radius: var(--radius-md);
  padding: 0;
  max-width: 520px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.dialog-body {
  padding: 20px 22px;
  background: #fff;
  color: var(--ink-700);
}

.dialog-body h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.dialog-body p {
  margin: 0 0 16px;
}

/* Convertisseur modal */
.modal-open {
  overflow: hidden;
}

.modal-convertisseur {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
}

.modal-convertisseur.is-open {
  display: block;
}

.modal-convertisseur__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-convertisseur__panel {
  position: relative;
  margin: 4vh auto;
  width: min(980px, 94vw);
  height: min(80vh, 820px);
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-convertisseur__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #eee6dc;
  background: #fefaf5;
}

.modal-convertisseur__header h2 {
  margin: 0;
  font-size: 16px;
}

.modal-convertisseur__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-convertisseur__minimize {
  border: 1px solid #e1d3c1;
  background: #fff7ee;
  color: #3b2f25;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.modal-convertisseur__close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #3b2f25;
}

.modal-convertisseur__body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.modal-convertisseur__body iframe {
  flex: 1;
  width: 100%;
  border: 0;
}

.modal-convertisseur__fallback {
  padding: 10px 14px;
  font-size: 13px;
  background: #fbf6ef;
  border-top: 1px solid #eee6dc;
}

.modal-convertisseur.is-min {
  pointer-events: none;
}

.modal-convertisseur.is-min .modal-convertisseur__backdrop {
  display: none;
}

.modal-convertisseur.is-min .modal-convertisseur__panel {
  pointer-events: auto;
  position: fixed;
  right: 16px;
  bottom: 16px;
  margin: 0;
  width: min(360px, 92vw);
  height: auto;
  border-radius: 14px;
}

.modal-convertisseur.is-min .modal-convertisseur__body {
  display: none;
}

@media (max-width: 720px) {
  .modal-convertisseur__panel {
    width: 100vw;
    height: 92vh;
    margin: 4vh 0;
    border-radius: 0;
  }
}

/* Tags & badges */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid #eadbc9;
  background: #f9f1e7;
  font-size: 13px;
  color: var(--ink-700);
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  border-radius: 8px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.badge-base {
  background: #e7f0f7;
  color: #1f4f78;
  border: 1px solid #b9d7ef;
}

.badge-composant {
  background: #f7e6ef;
  color: #7b2a56;
  border: 1px solid #e6c2d6;
}

.badge-admin {
  background: #1f4638;
  color: #fff;
  border: 1px solid #1f4638;
}

/* Settings page */
.settings-page {
  max-width: 1180px;
  margin: 24px auto 40px;
  padding: 0 16px;
  display: grid;
  gap: 16px;
  scroll-behavior: smooth;
}

.settings-card {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid #eadbc9;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.settings-card[id] {
  scroll-margin-top: 100px;
}

.settings-card h2 {
  margin-bottom: 10px;
}

.table-wrap {
  overflow-x: auto;
}

.settings-inline-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.settings-inline-form select,
.settings-inline-form input,
.settings-row input {
  min-height: 38px;
  border: 1px solid #decdb9;
  border-radius: 10px;
  padding: 8px 10px;
  font-family: var(--font-sans);
}

.tutorial-page .tutorial-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink-700);
}

.tutorial-page .tutorial-list li {
  margin-bottom: 8px;
  line-height: 1.5;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.settings-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

.settings-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-group {
  border: 1px solid #eadbc9;
  border-radius: 14px;
  background: #fffdf9;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.settings-group h3 {
  margin: 0;
  font-size: 20px;
}

.settings-group-note {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-500);
}

.settings-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-rows {
  display: grid;
  gap: 8px;
}

.settings-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: center;
}

.settings-group-head .btn,
.settings-row .btn {
  justify-self: start;
  white-space: nowrap;
  flex: 0 0 auto;
}

.compact-table td {
  padding: 8px 10px;
}

.settings-click-row {
  cursor: pointer;
}

.settings-click-row td {
  transition: background-color 0.15s ease;
}

.settings-click-row:hover td,
.settings-click-row:focus-visible td {
  background: #f7efe6;
}

.stats-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stat-card {
  border: 1px solid #eadbc9;
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  min-height: 92px;
}

.stat-card span {
  color: var(--ink-500);
  font-size: 12px;
}

.stat-card strong {
  font-size: 24px;
  line-height: 1;
  color: var(--ink-900);
}

.stat-card-link {
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.stat-card-link:hover,
.stat-card-link:focus-visible {
  transform: translateY(-1px);
  border-color: #d7bfa3;
  box-shadow: 0 10px 22px rgba(47, 33, 15, 0.08);
  text-decoration: none;
}

.settings-actions-start {
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.dup-group {
  border: 1px solid #eadbc9;
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
}

.dup-group ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 980px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .settings-grid-2 {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .settings-group-head {
    align-items: stretch;
  }
  .settings-group-head .btn {
    width: 100%;
    justify-content: center;
  }
  .settings-row {
    grid-template-columns: 1fr;
  }
  .settings-actions {
    justify-content: stretch;
  }
  .settings-actions .btn {
    width: 100%;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Topbar */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: linear-gradient(135deg, rgba(31,70,56,0.98), rgba(44,92,74,0.98));
  border-bottom: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 30px rgba(18, 30, 24, 0.2);
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-topbar__left,
.app-topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-topbar__left {
  padding: 12px 18px;
  flex: 0 1 auto;
  min-width: 0;
}
.app-topbar__right {
  margin-left: auto;
  padding: 12px 18px;
  flex: 1 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.app-topbar__toggle {
  display: none;
  margin-left: auto;
  margin-right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 18px;
  box-shadow: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
}

.app-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 6px 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,248,236,0.35), rgba(255,255,255,0.08));
  border: 1px solid rgba(255,255,255,0.45);
  box-shadow:
    0 10px 24px rgba(0,0,0,0.28),
    inset 0 1px 0 rgba(255,255,255,0.5);
  transition: transform 160ms ease, box-shadow 160ms ease;
  line-height: 1;
  max-width: 100%;
}
.app-logo-link:hover {
  transform: translateY(-1px);
  box-shadow:
    0 14px 28px rgba(0,0,0,0.32),
    inset 0 1px 0 rgba(255,255,255,0.55);
}
.app-logo {
  width: clamp(54px, 5vw, 78px);
  height: auto;
  filter: drop-shadow(0 10px 22px rgba(0,0,0,0.4));
  display: block;
  flex: 0 0 auto;
}
.app-logo-text {
  display: inline-flex;
  flex-direction: column;
  line-height: 1;
  color: #fff;
  text-shadow: 0 3px 10px rgba(0,0,0,0.35);
  white-space: nowrap;
}
.app-logo-title {
  font-family: var(--font-title);
  font-size: clamp(20px, 2.6vw, 32px);
  letter-spacing: 0.5px;
}
.app-logo-sub {
  font-family: var(--font-title);
  font-size: clamp(14px, 1.8vw, 22px);
  color: rgba(255,244,226,0.9);
  letter-spacing: 0.4px;
}

@media (max-width: 1100px) {
  .app-logo-link { padding: 6px 10px; gap: 10px; }
  .app-logo { width: clamp(46px, 6vw, 64px); }
  .app-logo-title { font-size: clamp(18px, 2.2vw, 26px); }
  .app-logo-sub { font-size: clamp(12px, 1.6vw, 18px); }
}

@media (max-width: 900px) {
  .app-topbar { gap: 8px; }
  .app-topbar__left { padding-right: 8px; }
  .app-logo-text { white-space: normal; }
}

@media (max-width: 680px) {
  .app-logo-link { padding: 6px 8px; gap: 8px; }
  .app-logo { width: 48px; }
  .app-logo-title { font-size: 18px; }
  .app-logo-sub { font-size: 13px; }
}

.app-topbar a,
.app-topbar button,
.app-topbar .btn {
  font-family: var(--font-sans);
}

.view-switch { display: inline-flex; gap: 6px; }
.view-btn {
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15);
  color: #fff;
  padding: 8px 10px;
  border-radius: 10px;
}
.view-btn.active { background: #fff; color: var(--herb-700); }

.user-info { display: inline-flex; align-items: center; gap: 10px; color: #fff; }
.user-name { display: inline-flex; align-items: center; gap: 8px; }

/* Page wrapper */
.page {
  max-width: 1280px;
  margin: 26px auto 80px;
  padding: 0 20px;
  animation: page-fade 420ms ease both;
}

@keyframes page-fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-title { font-size: clamp(28px, 3vw, 40px); }
.page-subtitle { color: var(--ink-500); }

/* Panels */
.filters-panel,
.results-panel,
.recipe-sheet,
.courses-sheet,
.import-shell .card,
.page-import-preview .card {
  background: var(--paper-100);
  border-radius: var(--radius-lg);
  border: 1px solid var(--paper-400);
  box-shadow: var(--shadow-md);
}

.filters-panel {
  padding: 20px;
  margin-bottom: 22px;
  position: relative;
}

.filters-panel::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 18px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffd9a6, #f2a95a 70%);
  opacity: 0.35;
}

.filters-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.filters-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr;
  grid-template-areas:
    "query query category tags"
    "type author source tags"
    "cook flags submit tags"
    "dashboard dashboard dashboard tags";
  gap: 12px;
  align-items: start;
}

.filters-grid .filter-query { grid-area: query; }
.filters-grid .filter-categories { grid-area: category; }
.filters-grid .filter-type { grid-area: type; }
.filters-grid .filter-author { grid-area: author; }
.filters-grid .filter-source { grid-area: source; }
.filters-grid .filter-cook { grid-area: cook; }
.filters-grid .filter-dashboard { grid-area: dashboard; }
.filters-grid .filter-tags { grid-area: tags; }
.filters-grid .filter-flags { grid-area: flags; }
.filters-grid .filter-submit { grid-area: submit; justify-self: start; }

.filters-grid input[type="text"],
.filters-grid select,
.filters-grid textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #e6d7c7;
  background: #fffdf9;
  font-family: var(--font-sans);
  color: var(--ink-700);
}

.filters-grid .filter-tags {
  margin: 0;
  max-height: 140px;
  overflow: auto;
  padding: 8px 10px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #e6d7c7;
  background: #fffdf9;
}

.filter-flags {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-tags legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-600);
}

.tag-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--ink-700);
}

.favoris-filter,
.selection-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--ink-700);
}

.results-panel {
  padding: 10px 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* Table (list view) */
.table-shell { overflow-x: auto; }
.recettes-table {
  width: 100%;
  min-width: 1180px;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0 12px;
}

.recettes-table thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink-500);
  padding: 0 10px 6px;
  white-space: nowrap;
}

.recettes-table tbody tr {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.recettes-table td {
  padding: 12px 10px;
  vertical-align: middle;
}

.col-select { width: 46px; text-align: center; }
.col-photo { width: 92px; text-align: center; }
.col-favori { width: 44px; text-align: center; }
.col-title { width: 16%; }
.col-category { width: 10%; }
.col-author { width: 9%; }
.col-source { width: 20%; }
.col-cook { width: 10%; }
.col-type { width: 9%; }
.col-actions {
  width: 120px;
  text-align: center;
  white-space: nowrap;
  position: sticky;
  right: 0;
  z-index: 2;
  background: #fff;
}

.recettes-table th.col-actions {
  z-index: 3;
  background: #f6ecdf;
}

.recettes-table td.col-actions {
  box-shadow: -10px 0 18px rgba(31, 26, 20, 0.05);
}

.recettes-table .col-title,
.recettes-table .col-category,
.recettes-table .col-author,
.recettes-table .col-source,
.recettes-table .col-cook,
.recettes-table .col-type {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.recette-thumb {
  width: 70px;
  height: 70px;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid #eadbc9;
}

.recette-thumb.placeholder {
  background: #f3e7da;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-500);
  font-weight: 700;
}

td.actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #f6efe7;
  border: 1px solid #eadbc9;
  margin: 0 2px;
}

td.actions a:hover { background: #f0e7dc; }

/* Gallery view */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
  margin-top: 16px;
}

.gallery-card {
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid #efe3d6;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-med), box-shadow var(--transition-med);
  position: relative;
}

.gallery-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.gallery-card a { color: inherit; display: block; }

.gallery-thumb {
  position: relative;
  height: 180px;
  background: #f1e8de;
}

.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }

.gallery-placeholder {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-500);
  font-weight: 700;
}

.gallery-overlay {
  padding: 12px 14px 14px;
}

.gallery-title { margin: 0; font-size: 16px; }
.gallery-meta { color: var(--ink-500); font-size: 13px; }

.gallery-card .vignette-favori,
.gallery-card .vignette-select {
  position: absolute;
  top: 10px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  padding: 0;
  font-size: 14px;
  border: 1px solid rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.92);
  color: #d28b2c;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(15, 12, 9, 0.18);
  z-index: 2;
}

.gallery-card .vignette-select {
  left: 10px;
  color: #8c7a6c;
}

.gallery-card .vignette-favori { right: 10px; }

.gallery-card .vignette-select.is-selected {
  background: #ffffff;
  border-color: #cfe6da;
  color: #1f5c43;
}

.gallery-card .vignette-favori.is-favori {
  background: #fff6e8;
  border-color: #f0c89c;
}

.recettes-mobile-list {
  display: grid;
  gap: 12px;
}

.recette-mobile-card {
  background: #fff;
  border: 1px solid #efe3d6;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 14px;
}

.recette-mobile-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.recette-mobile-value {
  min-width: 0;
  color: var(--ink-800);
}

.recette-mobile-hero {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.recette-mobile-photo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.recette-mobile-main {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.recette-mobile-main-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.recette-mobile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 20px;
}

.recette-mobile-tools {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.recette-mobile-title-block {
  min-width: 0;
}

.recette-mobile-title-link {
  display: block;
  color: var(--ink-900);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
}

.recette-mobile-actions {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.recette-mobile-actions a,
.recette-mobile-tools .btn-selection,
.recette-mobile-tools .btn-favori {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #f6efe7;
  border: 1px solid #eadbc9;
  font-size: 18px;
  box-shadow: var(--shadow-sm);
}

.recette-mobile-actions a:hover,
.recette-mobile-tools .btn-selection:hover,
.recette-mobile-tools .btn-favori:hover {
  background: #f0e7dc;
}

.recette-mobile-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed #efe3d6;
}

.recette-mobile-meta-line {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.recette-mobile-meta-line--full {
  grid-column: 1 / -1;
}

.recette-mobile-value--text {
  display: block;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.recette-mobile-value--inline {
  display: inline;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.recette-mobile-value .recette-thumb {
  width: 84px;
  height: 84px;
  border-radius: 14px;
}

.recette-mobile-meta-line .recette-mobile-label {
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-700);
}

.recette-mobile-meta-line .recette-mobile-value {
  font-size: 15px;
  color: var(--ink-900);
}

/* Recipe detail */
.page-recette { font-family: var(--font-sans); }

.recipe-sheet {
  padding: 24px;
  position: relative;
}

.recipe-sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, rgba(255,255,255,0.4), transparent 30%, transparent 70%, rgba(255,255,255,0.4));
  pointer-events: none;
}

.fiche-header {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
}

.fiche-title h1 { font-size: clamp(26px, 3vw, 38px); }

.fiche-subtitle {
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-500);
  font-size: 12px;
  font-weight: 700;
}

.fiche-photo-zone {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid #efe3d6;
}

.fiche-photo-zone img { width: 100%; height: 100%; object-fit: cover; }

.photo-placeholder {
  min-height: 180px;
  background: #f1e8de;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-500);
  font-weight: 700;
}

.fiche-meta {
  border-left: 1px dashed #eadbc9;
  padding-left: 18px;
}

.meta-ligne { margin: 8px 0; color: var(--ink-600); }
.meta-ligne strong { display: inline-block; min-width: 110px; color: var(--ink-800); }
.meta-separator { height: 1px; background: #efe3d6; margin: 12px 0; }

.fiche-bas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 18px;
}

.fiche-bas h2 { margin-top: 0; }
.page-recette ul, .page-recette ol { padding-left: 18px; }

/* Edit page */
.edit-wrap {
  padding: 24px;
}

.edit-title { margin-bottom: 14px; }

.form-recette label {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  font-weight: 600;
  color: var(--ink-700);
}

.form-recette input,
.form-recette select,
.form-recette textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #e6d7c7;
  background: #fffdf9;
  font-family: var(--font-sans);
}

.form-recette textarea { min-height: 100px; }

.section-card {
  background: #fdf7f0;
  border: 1px solid #efe3d6;
  border-radius: var(--radius-lg);
  padding: 18px;
  margin: 16px 0;
}

.tags-edit { display: flex; flex-wrap: wrap; gap: 8px; }
.tags-edit .tag a { font-weight: 900; }

.tag-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.tag-form input[type="text"] { flex: 1; }

.photo-principale img,
.recette-photo-principale img {
  border-radius: var(--radius-lg);
  border: 1px solid #efe3d6;
}

.ai-preview img {
  width: min(240px, 100%);
}

.ai-preview-form {
  margin: 10px 0 16px;
}

.ai-preview-form button {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid #cfe2d6;
  background: #e6f3ec;
  color: #1f5c43;
  font-weight: 700;
  cursor: pointer;
}

.ai-preview-form button:hover {
  background: #d9ecdf;
}

.photo-upload-form {
  display: grid;
  gap: 10px;
  margin-bottom: 8px;
  max-width: 560px;
}

.photo-upload-form label {
  display: block;
  font-weight: 700;
  color: var(--ink-700);
}

.photo-upload-mobile-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.photo-upload-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #cfe2d6;
  background: #e6f3ec;
  color: #1f5c43;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.photo-upload-action:hover {
  background: #d9ecdf;
}

.photo-upload-hidden-input {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.desktop-only { display: block; }
.mobile-only { display: none; }

@media (max-width: 767px) {
  .desktop-only { display: none; }
  .mobile-only { display: block; }
}

.photos-secondaires {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.photo-vignette {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid #efe3d6;
  background: #fff;
}

.photo-actions {
  display: flex;
  gap: 8px;
  padding: 8px;
}

.photo-actions a {
  flex: 1;
  text-align: center;
  border-radius: 10px;
  padding: 8px;
  background: #f6efe7;
  border: 1px solid #eadbc9;
}

.photo-actions a:hover { background: #f0e7dc; }

/* Login pages */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: min(420px, 92vw);
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid #efe3d6;
  box-shadow: var(--shadow-lg);
  padding: 26px;
}

.login-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 8px;
  border-radius: 18px;
  background: radial-gradient(circle at 30% 20%, #fff1dc 0%, #f1e1cf 55%, #e7d3be 100%);
  border: 1px solid #e0c9b3;
  box-shadow: 0 12px 26px rgba(0,0,0,0.14);
}
.login-logo img {
  width: clamp(170px, 45vw, 260px);
  height: auto;
  filter: drop-shadow(0 10px 22px rgba(0,0,0,0.28));
}
.login-card h1 { text-align: center; }

.login-intro { text-align: center; color: var(--ink-500); }
.login-error {
  text-align: center;
  color: #8b2f1f;
  background: #fde8e3;
  border: 1px solid #f2b8aa;
  padding: 8px 10px;
  border-radius: 10px;
  margin: 10px 0;
}

.login-success {
  text-align: center;
  color: #1f5c43;
  background: #e6f3ec;
  border: 1px solid #c4e0d0;
  padding: 8px 10px;
  border-radius: 10px;
  margin: 10px 0;
}

.login-form { max-width: 320px; margin: 0 auto; }
.login-form label { display: block; margin: 12px 0 6px; font-weight: 600; color: var(--ink-700); text-align: left; }
.login-form input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #e6d7c7;
  background: #fffdf9;
}

.login-form button { width: 100%; margin-top: 12px; }

.login-links { display: flex; justify-content: space-between; margin-top: 12px; font-size: 13px; }
.login-links a { color: var(--herb-600); font-weight: 700; }

/* Import pages */
.page-import .card,
.page-import-preview .card {
  border-radius: var(--radius-lg) !important;
  border: 1px solid #efe3d6 !important;
  box-shadow: var(--shadow-md);
}

.page-import .nav-tabs .nav-link.active {
  background: var(--paper-200);
  border-color: #efe3d6;
  color: var(--ink-900);
  font-weight: 700;
}

.page-import .btn-success,
.page-import .btn-info,
.page-import .btn-warning {
  border: none;
}

.import-shell .card-body {
  background: var(--paper-100);
}

/* Liste de courses */
.courses-sheet .page-header-actions {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.courses-sheet h1 { margin-bottom: 6px; }
.courses-sheet .page-subtitle { color: var(--ink-500); }

.bloc {
  background: #fdf7f0;
  border-radius: var(--radius-lg);
  border: 1px solid #efe3d6;
  padding: 16px;
  margin-bottom: 18px;
}

.bloc textarea {
  width: 100%;
  min-height: 160px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #e6d7c7;
  background: #fffdf9;
}

.btn-copy {
  background: #f0e7dc;
  border: 1px solid #e1d6c9;
  box-shadow: none;
}

/* Favori button */
.btn-favori {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid #eadbc9;
  background: #fff;
  box-shadow: var(--shadow-sm);
  color: #b7a89a;
  font-size: 16px;
}

.btn-favori.is-favori {
  background: #fce8d7;
  border-color: #f1b58b;
  color: #f5a623;
}

.btn-favori:hover { color: #e39a1c; }

.btn-select-recette {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid #eadbc9;
  background: #fff;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.btn-select-recette.is-selected {
  background: #e6f3ec;
  border-color: #bfe0d0;
}

/* Print */
@media print {
  body { background: #fff; }
  .app-topbar,
  .app-menu,
  .btn,
  .btn-link { display: none !important; }
  .page { max-width: none; margin: 0; padding: 0; }
}

/* Responsive */
@media (max-width: 1200px) {
  .filters-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    grid-template-areas:
      "query query category"
      "type author source"
      "cook flags submit"
      "dashboard dashboard dashboard"
      "tags tags tags";
  }
}

@media (max-width: 1024px) {
  .fiche-header { grid-template-columns: 1fr; }
  .fiche-meta { border-left: none; padding-left: 0; border-top: 1px dashed #eadbc9; padding-top: 14px; }
  .fiche-bas { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .filters-head { flex-direction: column; align-items: flex-start; }
  .filters-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "query query"
      "category category"
      "type author"
      "source cook"
      "flags submit"
      "dashboard dashboard"
      "tags tags";
  }
}

@media (max-width: 768px) {
  .app-topbar__left,
  .app-topbar__right { padding: 10px 14px; }
  .page { padding: 0 14px; }
  .filters-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "query"
      "category"
      "type"
      "author"
      "source"
      "cook"
      "flags"
      "dashboard"
      "tags"
      "submit";
  }
  .form-recette label { grid-template-columns: 1fr; }
  .login-links { flex-direction: column; gap: 6px; }
  .tag-form { flex-direction: column; align-items: stretch; }
  .tag-form button,
  .tag-form select,
  .tag-form input[type="text"] { width: 100%; }

  .app-topbar__toggle { display: inline-flex; align-items: center; justify-content: center; }
  .app-topbar__right {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    background: rgba(25, 45, 35, 0.96);
    border-top: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 18px 40px rgba(15, 22, 18, 0.35);
  }
  .app-topbar.is-open .app-topbar__right { display: flex; }
  .app-topbar__right .btn { width: 100%; justify-content: center; }
  .user-info { flex-direction: column; align-items: stretch; }

  .view-switch {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .view-btn { text-align: center; }

  .recettes-table thead { display: none; }
  .recettes-table,
  .recettes-table tbody,
  .recettes-table tr,
  .recettes-table td { display: block; width: 100%; }

  .recettes-table tbody tr {
    border: 1px solid #efe3d6;
    border-radius: var(--radius-lg);
    padding: 10px 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    background: #fff;
  }

  .recettes-table td {
    padding: 8px 0;
    border-bottom: 1px dashed #efe3d6;
    display: grid;
    grid-template-columns: minmax(88px, auto) minmax(0, 1fr);
    align-items: center;
    gap: 12px;
  }

  .recettes-table td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-500);
    text-transform: uppercase;
    letter-spacing: 0.6px;
  }

  .recettes-table .recipe-cell-value {
    min-width: 0;
    display: block;
    text-align: right;
    color: var(--ink-800);
  }

  .recettes-table .recipe-cell-value--center {
    display: inline-flex;
    justify-self: end;
    align-items: center;
  }

  .recettes-table .recipe-cell-value--media {
    display: inline-flex;
    justify-self: end;
  }

  .recettes-table .recipe-cell-value--title {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    text-align: right;
  }

  .recettes-table .recipe-title-text {
    display: block;
    max-width: 100%;
  }

  .recettes-table td:last-child { border-bottom: 0; }
  .recettes-table .recette-thumb { width: 84px; height: 84px; border-radius: 14px; }
  .recettes-table .col-actions {
    position: static;
    right: auto;
    z-index: auto;
    box-shadow: none;
    background: transparent;
  }
  .recettes-table .recipe-cell-value--actions {
    display: inline-flex;
    justify-self: end;
    align-items: center;
    gap: 8px;
  }
  .recettes-table td.actions::before { margin-right: 0; }

  .courses-sheet .page-header-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .courses-sheet .page-header-right .btn { width: 100%; }
  .courses-sheet .bloc ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  .courses-sheet .bloc li {
    padding: 10px 0;
    border-bottom: 1px dashed #efe3d6;
  }
  .courses-sheet .bloc li:last-child { border-bottom: 0; }
  .courses-sheet .bloc li label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
  }
  .courses-sheet .bloc input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
  }

  .gallery-card a {
    display: grid;
    grid-template-columns: 120px 1fr;
    align-items: stretch;
  }
  .gallery-thumb,
  .gallery-placeholder {
    height: 100%;
    min-height: 110px;
  }
  .gallery-overlay { padding: 10px 12px; }
  .gallery-title { font-size: 15px; }
}

@media (max-width: 560px) {
  .app-topbar__right { gap: 8px; }
  .app-topbar__right .btn,
  .app-topbar__right button,
  .app-topbar__right a,
  .courses-sheet .page-header-right .btn,
  .photo-upload-mobile-actions .photo-upload-action {
    width: 100%;
    justify-content: center;
  }
  .photo-upload-mobile-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .gallery-grid { grid-template-columns: 1fr; }
}
