/* ============================================
   DETAIL RECETTE - Sidebar, ingredients, etapes
   Nos Recettes V3 - Mobile First
   ============================================ */

/* === HEADER RECETTE === */
.recipe-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
}

.recipe-back-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--accent);
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.recipe-back-btn:hover {
  background: var(--accent-light);
}

.recipe-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: var(--leading-tight);
}

/* === META RECETTE === */
.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: var(--space-3) 0;
}

.recipe-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.recipe-meta-item-icon {
  font-size: var(--text-base);
}

.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) 0;
}

/* === IMAGE HERO + TITRE + META === */
.recipe-hero-container {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.recipe-hero-image {
  width: 100%;
  aspect-ratio: 5 / 2;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.recipe-hero-fallback {
  width: 100%;
  aspect-ratio: 5 / 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--orange-50);
  font-size: 4rem;
  color: var(--orange-300);
}

.recipe-hero-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-8) var(--space-6) var(--space-6);
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
  color: white;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.recipe-hero-badge {
  align-self: flex-start;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--orange-500);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
}

.recipe-hero-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.recipe-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.85);
}

.recipe-hero-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.recipe-hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.recipe-hero-tag {
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
  font-size: var(--text-xs);
  backdrop-filter: blur(4px);
}

/* === INGREDIENTS === */
.ingredients-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.ingredients-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ingredients-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
}

.ingredient-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-left: 3px solid var(--ingredient-color, transparent);
  font-size: var(--text-sm);
  transition: background var(--transition-fast);
}

.ingredient-item:hover {
  background: color-mix(in srgb, var(--ingredient-color, transparent) 8%, transparent);
}

@media (max-width: 639px) {
  .ingredients-list {
    grid-template-columns: 1fr;
  }

  .ingredient-item {
    font-size: var(--text-base);
  }
}

.ingredient-emoji {
  font-size: var(--text-lg);
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.ingredient-quantity {
  font-weight: var(--font-semibold);
  color: var(--orange-700);
  white-space: nowrap;
}

.ingredient-name {
  color: var(--text-primary);
}

/* === ETAPES === */
.steps-section {
  padding: var(--space-4) 0;
}

.steps-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.steps-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.step-item {
  display: flex;
  gap: var(--space-4);
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--orange-500);
  color: white;
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-content {
  flex: 1;
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
}

.step-content strong {
  font-weight: var(--font-semibold);
  color: var(--orange-700);
}

.step-content del {
  text-decoration: line-through;
  color: var(--text-secondary);
  opacity: 0.7;
}

.step-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.step-content a:hover {
  color: var(--accent-hover);
}

.step-ingredient-highlight {
  text-decoration: underline;
  text-decoration-color: var(--highlight-color);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  font-weight: var(--font-medium);
}

.step-image {
  float: right;
  width: 220px;
  height: 120px;
  object-fit: cover;
  margin: 0 0 var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: zoom-in;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 639px) {
  .step-image {
    float: none;
    width: 100%;
    height: auto;
    max-height: 200px;
    margin: 0 0 var(--space-3) 0;
  }
}

/* === ETAPE EDITABLE (clic pour modifier) === */
.step-editable {
  cursor: pointer;
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin: calc(-1 * var(--space-3));
  transition: background var(--transition-fast);
}

.step-editable:hover {
  background: var(--accent-light);
}

/* === MODALE EDITION ETAPE === */
.step-editor-toolbar {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.step-editor-toolbar-btn {
  width: 32px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.step-editor-toolbar-btn:hover {
  background: var(--accent-light);
  border-color: var(--border);
}

.step-editor-toolbar-bold {
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
}

.step-editor-toolbar-italic {
  font-style: italic;
  font-size: var(--text-sm);
  font-family: Georgia, serif;
}

.step-editor-toolbar-strike {
  text-decoration: line-through;
  font-size: var(--text-sm);
}

.step-editor-toolbar-link {
  font-size: var(--text-sm);
}

.step-editor-textarea {
  width: 100%;
  min-height: 120px;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  resize: vertical;
}

.step-editor-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

.step-editor-preview-label {
  margin-top: var(--space-3);
}

.step-editor-preview {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  min-height: 2.5rem;
}

.step-editor-preview strong {
  font-weight: var(--font-semibold);
  color: var(--orange-700);
}

.step-editor-preview em {
  font-style: italic;
  color: var(--text-secondary);
}

.step-editor-preview del {
  text-decoration: line-through;
  color: var(--text-secondary);
}

.step-editor-preview a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.step-editor-preview-empty {
  color: var(--text-secondary);
  font-style: italic;
}

.step-editor-label {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.step-editor-images {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.step-editor-thumb {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.step-editor-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.step-editor-thumb-remove {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--error);
  color: white;
  font-size: var(--text-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid var(--bg-card);
  line-height: 1;
}

.step-editor-add {
  width: 80px;
  height: 80px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: var(--text-2xl);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.step-editor-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.step-editor-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-4);
}

.step-editor-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.step-editor-btn:hover {
  background: var(--accent-light);
}

.step-editor-btn-save {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.step-editor-btn-save:hover {
  background: var(--accent-hover);
}

.step-editor-btn-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* === INGREDIENT EDITABLE === */
.ingredient-editable {
  cursor: pointer;
  transition: background var(--transition-fast);
  border-radius: var(--radius-sm);
}

.ingredient-editable:hover {
  background: var(--accent-light);
}

.ingredient-add-btn {
  width: 100%;
  padding: var(--space-3);
  margin-top: var(--space-2);
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ingredient-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* === HERO EDITABLE === */
.hero-editable {
  cursor: pointer;
}

.hero-editable:hover .recipe-hero-title {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 4px;
}

/* === INGREDIENT EDITOR (modale) === */
.ingredient-editor-field {
  margin-bottom: var(--space-3);
}

.ingredient-editor-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.ingredient-editor-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: inherit;
  background: var(--bg-page);
  color: var(--text-primary);
  box-sizing: border-box;
}

.ingredient-editor-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.15);
}

.ingredient-editor-row {
  display: flex;
  gap: var(--space-3);
}

.ingredient-editor-row .ingredient-editor-field {
  flex: 1;
}

.ingredient-editor-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-4);
}

.ingredient-editor-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.ingredient-editor-btn:hover {
  background: var(--accent-light);
}

.ingredient-editor-btn-save {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.ingredient-editor-btn-save:hover {
  background: var(--accent-hover);
}

.ingredient-editor-btn-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ingredient-editor-btn-delete {
  background: transparent;
  color: #E74C3C;
  border-color: #E74C3C;
  margin-right: auto;
}

.ingredient-editor-btn-delete:hover {
  background: rgba(231, 76, 60, 0.1);
}

/* === RECIPE EDITOR (modale) === */
.recipe-editor-field {
  margin-bottom: var(--space-3);
}

.recipe-editor-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.recipe-editor-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: inherit;
  background: var(--bg-page);
  color: var(--text-primary);
  box-sizing: border-box;
}

.recipe-editor-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.15);
}

.recipe-editor-row {
  display: flex;
  gap: var(--space-3);
}

.recipe-editor-row .recipe-editor-field {
  flex: 1;
}

.recipe-editor-image-section {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.recipe-editor-image-preview {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.recipe-editor-image-change {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.recipe-editor-image-change:hover {
  background: var(--accent-light);
}

.recipe-editor-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-4);
}

.recipe-editor-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.recipe-editor-btn:hover {
  background: var(--accent-light);
}

.recipe-editor-btn-save {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.recipe-editor-btn-save:hover {
  background: var(--accent-hover);
}

.recipe-editor-btn-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.recipe-editor-btn-delete {
  background: transparent;
  color: var(--error);
  border-color: var(--error);
  margin-right: auto;
}

.recipe-editor-btn-delete:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* === MARKDOWN CONTENT (astuces, etc) - style bleu pastel === */
.recipe-markdown {
  background: #e8f4fd;
  color: #1e3a5f;
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  border-left: 4px solid #7cb9e8;
}

[data-theme="dark"] .recipe-markdown {
  background: rgba(124, 185, 232, 0.1);
  color: #a8d4f0;
  border-left-color: #5a9bc6;
}

.recipe-markdown h2 {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: #1e3a5f;
  margin: var(--space-4) 0 var(--space-3);
}

.recipe-markdown h2:first-child,
.recipe-markdown h3:first-child {
  margin-top: 0;
}

.recipe-markdown h3 {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: #1e3a5f;
  margin: var(--space-4) 0 var(--space-3);
}

[data-theme="dark"] .recipe-markdown h2,
[data-theme="dark"] .recipe-markdown h3 {
  color: #a8d4f0;
}

.recipe-markdown p {
  margin-bottom: var(--space-3);
  line-height: var(--leading-relaxed);
  color: inherit;
}

.recipe-markdown ul,
.recipe-markdown ol {
  padding-left: var(--space-6);
  margin-bottom: var(--space-3);
}

.recipe-markdown ul li {
  list-style: disc;
  margin-bottom: var(--space-2);
  color: inherit;
  line-height: var(--leading-relaxed);
}

.recipe-markdown ol li {
  margin-bottom: var(--space-2);
  color: inherit;
  line-height: var(--leading-relaxed);
}

/* === SIDEBAR (tablette + desktop) === */
.sidebar-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.sidebar-card + .sidebar-card {
  margin-top: var(--space-4);
}

.sidebar-card-title {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--accent);
}

/* Outils : grille 5 colonnes avec icone + label */
.sidebar-tools {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-1);
}

.sidebar-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-2) var(--space-1);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-tool-btn:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

.sidebar-tool-btn.active {
  background: var(--accent-light);
}

.sidebar-tool-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.sidebar-tool-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Informations : icone + label + valeur */
.sidebar-meta-list {
  display: flex;
  flex-direction: column;
}

.sidebar-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
}

.sidebar-meta-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sidebar-meta-icon {
  font-size: var(--text-base);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-meta-label {
  color: var(--text-secondary);
  flex: 1;
}

.sidebar-meta-value {
  color: var(--text-primary);
  font-weight: var(--font-semibold);
  text-align: right;
}

/* === RESPONSIVE === */
@media (min-width: 640px) {
  .recipe-hero-title {
    font-size: var(--text-3xl);
  }

  .recipe-hero-image,
  .recipe-hero-fallback {
    aspect-ratio: 3 / 1;
  }

  .recipe-hero-overlay {
    padding: var(--space-10) var(--space-8) var(--space-6);
  }
}

@media (min-width: 1024px) {
  .recipe-hero-title {
    font-size: var(--text-4xl);
  }

  .recipe-hero-container {
    border-radius: var(--radius-xl);
  }
}
