/* Variables */
:root {
  --color-primary: #D4A574;      /* Terracotta douce */
  --color-primary-dark: #B8956A;
  --color-secondary: #7C9885;    /* Vert sauge */
  --color-accent: #E8B4A0;       /* Pêche */
  --color-background: #FDF8F3;   /* Crème chaude */
  --color-surface: #FFFFFF;
  --color-text: #3D3D3D;
  --color-text-light: #6B6B6B;
  --color-border: #E5DDD5;
  --color-error: #D67272;
  --color-success: #7C9885;
  --color-warning: #E6B566;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background: var(--color-background);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
.app-header {
  background: var(--color-surface);
  padding: 1rem 2rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-primary-dark);
}

.main-nav {
  display: flex;
  gap: 0.5rem;
}

.nav-link {
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: var(--color-text-light);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  font-weight: 500;
}

.nav-link:hover {
  background: var(--color-background);
  color: var(--color-text);
}

.nav-link.active {
  background: var(--color-primary);
  color: white;
}

/* Main Content */
#app-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  min-height: calc(100vh - 80px);
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--color-text-light);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-background);
}

.btn-danger {
  background: var(--color-error);
  color: white;
}

.btn-danger:hover {
  background: #c45858;
}

.btn-success {
  background: var(--color-success);
  color: white;
}

.btn-success:hover {
  background: #6a8573;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

/* Forms */
input, textarea, select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
  background: var(--color-surface);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
}

input:disabled, textarea:disabled, select:disabled {
  background: var(--color-background);
  cursor: not-allowed;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--color-text);
}

/* Tags */
.tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--color-background);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.tag-batch-cooking {
  background: var(--color-warning);
  color: white;
}

.tag-rapide {
  background: var(--color-success);
  color: white;
}

.tag-enfants-adorent {
  background: var(--color-accent);
  color: var(--color-text);
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Rating Stars */
.stars {
  display: inline-flex;
  gap: 0.25rem;
}

.star {
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--color-border);
  transition: color 0.2s;
}

.star.filled {
  color: var(--color-warning);
}

.star:hover {
  color: var(--color-warning);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-light);
  padding: 0.25rem;
  line-height: 1;
}

.modal-close:hover {
  color: var(--color-text);
}

.modal-body {
  margin-bottom: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* Chat Component */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 500px;
  max-height: 70vh;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  display: flex;
  max-width: 85%;
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message-content {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  line-height: 1.5;
}

.message.user .message-content {
  background: var(--color-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
  background: var(--color-background);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}

.message.loading .message-content {
  color: var(--color-text-light);
  font-style: italic;
}

.typing .dots {
  animation: blink 1.4s infinite;
}

@keyframes blink {
  0%, 20% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

.chat-input-container {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.chat-input {
  flex: 1;
}

.chat-send {
  width: 50px;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Recipe Card */
.recipe-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.recipe-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.recipe-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.recipe-card-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--color-text-light);
  margin-bottom: 0.75rem;
}

.recipe-card-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Recipe Grid */
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* Calendar */
.calendar-container {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  background: var(--color-primary);
  color: white;
}

.calendar-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.calendar-nav {
  display: flex;
  gap: 0.5rem;
}

.calendar-nav button {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
}

.calendar-nav button:hover {
  background: rgba(255,255,255,0.3);
}

.calendar-grid {
  display: grid;
  grid-template-columns: auto repeat(7, 1fr);
  border-top: 1px solid var(--color-border);
}

.calendar-cell {
  padding: 0.75rem;
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  min-height: 100px;
}

.calendar-cell:last-child {
  border-right: none;
}

.calendar-cell.header {
  background: var(--color-background);
  font-weight: 600;
  text-align: center;
  min-height: auto;
  padding: 1rem 0.5rem;
}

.calendar-cell.label {
  background: var(--color-background);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: auto;
}

.meal-slot {
  background: var(--color-background);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.meal-slot:hover {
  background: var(--color-border);
}

.meal-slot.empty {
  border: 2px dashed var(--color-border);
  background: transparent;
}

.meal-slot.filled {
  background: var(--color-accent);
}

.meal-slot-name {
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
}

/* Shopping List */
.shopping-list {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.shopping-category {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.shopping-category:last-child {
  border-bottom: none;
}

.shopping-category-title {
  font-weight: 600;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.shopping-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.shopping-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.shopping-item.checked .shopping-item-name {
  text-decoration: line-through;
  color: var(--color-text-light);
}

.shopping-item-name {
  flex: 1;
}

.shopping-item-recipes {
  font-size: 0.75rem;
  color: var(--color-text-light);
}

/* Cooking Mode */
.cooking-mode {
  position: fixed;
  inset: 0;
  background: var(--color-background);
  z-index: 2000;
  display: flex;
  flex-direction: column;
}

.cooking-header {
  background: var(--color-primary);
  color: white;
  padding: 1.5rem;
  text-align: center;
}

.cooking-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
}

.cooking-step-indicator {
  font-size: 0.9rem;
  opacity: 0.9;
}

.cooking-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
}

.cooking-instruction {
  font-size: 1.5rem;
  line-height: 1.6;
  max-width: 600px;
  margin-bottom: 1.5rem;
}

.cooking-tip {
  background: var(--color-accent);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  max-width: 500px;
  margin-bottom: 1rem;
}

.cooking-tip-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.cooking-duration {
  color: var(--color-text-light);
  font-size: 1.1rem;
}

.cooking-nav {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.cooking-nav button {
  padding: 1rem 2rem;
  font-size: 1.1rem;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--color-text-light);
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mr-1 { margin-right: 0.5rem; }
.ml-1 { margin-left: 0.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.w-full { width: 100%; }
.hidden { display: none; }

/* Page Title */
.page-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 1.5rem;
}

/* Search Bar */
.search-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.search-input {
  flex: 1;
  position: relative;
}

.search-input input {
  padding-left: 2.5rem;
}

.search-input::before {
  content: '🔍';
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

/* Filters */
.filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-select {
  min-width: 150px;
}

/* Recipe View */
.recipe-view {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.recipe-view-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  padding: 2rem;
}

.recipe-view-title {
  font-size: 2rem;
  margin: 0 0 1rem 0;
}

.recipe-view-meta {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.recipe-view-meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.recipe-view-body {
  padding: 2rem;
}

.recipe-section {
  margin-bottom: 2rem;
}

.recipe-section:last-child {
  margin-bottom: 0;
}

.recipe-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-primary-dark);
}

.ingredient-list {
  list-style: none;
}

.ingredient-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
}

.ingredient-item:last-child {
  border-bottom: none;
}

.step-list {
  list-style: none;
  counter-reset: step-counter;
}

.step-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  gap: 1rem;
}

.step-item:last-child {
  border-bottom: none;
}

.step-number {
  width: 32px;
  height: 32px;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.step-content {
  flex: 1;
}

.step-tip {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--color-background);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--color-text-light);
}

.recipe-tips {
  background: var(--color-background);
  padding: 1rem;
  border-radius: var(--radius-md);
}

.recipe-tips ul {
  margin: 0;
  padding-left: 1.5rem;
}

.recipe-tips li {
  margin-bottom: 0.5rem;
}

.recipe-tips li:last-child {
  margin-bottom: 0;
}

.recipe-actions {
  display: flex;
  gap: 1rem;
  padding: 1.5rem 2rem;
  background: var(--color-background);
  border-top: 1px solid var(--color-border);
}

/* Preview Recipe */
.recipe-preview {
  background: var(--color-background);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-top: 1rem;
}

.recipe-preview h3 {
  margin: 0 0 1rem 0;
  color: var(--color-primary-dark);
}

/* Mobile Calendar Layout - Jours en lignes, repas en colonnes */
@media (max-width: 768px) {
  /* Masquer la grille desktop */
  .calendar-grid {
    display: none !important;
  }

  /* Afficher le layout mobile */
  .calendar-mobile-layout {
    display: block !important;
  }

  .calendar-mobile-day {
    border-bottom: 2px solid var(--color-border);
    padding: 0.75rem;
  }

  .calendar-mobile-day:last-child {
    border-bottom: none;
  }

  .calendar-mobile-day-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--color-primary-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .calendar-mobile-day-date {
    font-size: 0.85rem;
    font-weight: normal;
    color: var(--color-text-light);
  }

  .calendar-mobile-meals {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .calendar-mobile-meal {
    text-align: center;
  }

  .calendar-mobile-meal-label {
    font-size: 0.75rem;
    color: var(--color-text-light);
    margin-bottom: 0.25rem;
  }

  .calendar-mobile-meal .meal-slot {
    min-height: 50px;
    font-size: 0.8rem;
  }

  .calendar-mobile-meal .meal-slot-name {
    font-size: 0.75rem;
  }
}

/* Desktop: masquer le layout mobile */
@media (min-width: 769px) {
  .calendar-mobile-layout {
    display: none !important;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .main-nav {
    width: 100%;
    justify-content: space-around;
  }

  .nav-link {
    padding: 0.5rem;
    font-size: 0.85rem;
  }

  #app-content {
    padding: 1rem;
  }

  .calendar-header h2 {
    font-size: 1rem;
  }

  .calendar-nav button {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
  }

  .recipe-view-header {
    padding: 1.5rem;
  }

  .recipe-view-title {
    font-size: 1.5rem;
  }

  .recipe-view-meta {
    gap: 1rem;
  }

  .cooking-instruction {
    font-size: 1.25rem;
  }

  .search-bar {
    flex-direction: column;
  }

  .filters {
    flex-direction: column;
  }

  .filter-select {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .logo {
    font-size: 1.25rem;
  }

  .nav-link {
    font-size: 0.75rem;
    padding: 0.4rem;
  }

  .recipes-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 1.5rem;
    width: 95%;
  }
}
