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

:root {
  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;

  /* Amplified color palette - warmer, more saturated */
  --header-bg: linear-gradient(150deg, #ff6b6b 0%, #ee5a24 50%, #f0932b 100%);

  /* Day card gradients - bolder, more distinct */
  --card-coral: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
  --card-sunset: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
  --card-mint: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
  --card-peach: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
  --card-lavender: linear-gradient(135deg, #c3cfe2 0%, #c3cfe2 40%, #ddd6f3 100%);

  /* Vibrant accent for tonight */
  --tonight-bg: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);

  /* Content area - warm off-white */
  --content-bg: #fffbf7;
  --content-radius: 32px;

  /* Text - warmer, not pure gray */
  --text-primary: #2d2a26;
  --text-secondary: #6b6560;
  --text-light: rgba(255, 255, 255, 0.95);
  --text-muted: rgba(255, 255, 255, 0.8);

  /* UI */
  --border-color: #ebe5df;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.15);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: linear-gradient(180deg, #ee5a24 0%, #f0932b 15%, #fcd9b8 40%, #fff5ed 100%);
  background-attachment: fixed;
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.6;
}

/* App Container */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--header-bg);
  color: white;
  padding: 1.5rem 1.5rem 2rem;
  padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-compact {
  padding: 1.5rem;
  padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
}

.header h1 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 900;
  margin: 0;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-compact h1 {
  font-size: 2rem;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
}

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

.nav-link {
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.2s;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.25);
}

.nav-icon {
  color: white;
  text-decoration: none;
  font-size: 1.25rem;
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.2s;
  line-height: 1;
}

.nav-icon:hover {
  background: rgba(255, 255, 255, 0.25);
}

.back-link {
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.9rem;
}

/* Content Area */
.content {
  flex: 1;
  background: var(--content-bg);
  border-radius: var(--content-radius) var(--content-radius) 0 0;
  padding: 2rem 1.5rem;
  margin-top: -1rem;
  position: relative;
}

/* Subtle texture overlay */
.content::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.015;
  pointer-events: none;
  border-radius: inherit;
}

/* Week View */
.week-view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 100px; /* Space for FAB */
}

/* Staggered entrance animation */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.week-view > * {
  animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.week-view > *:nth-child(1) { animation-delay: 0ms; }
.week-view > *:nth-child(2) { animation-delay: 50ms; }
.week-view > *:nth-child(3) { animation-delay: 100ms; }
.week-view > *:nth-child(4) { animation-delay: 150ms; }
.week-view > *:nth-child(5) { animation-delay: 200ms; }
.week-view > *:nth-child(6) { animation-delay: 250ms; }
.week-view > *:nth-child(7) { animation-delay: 300ms; }
.week-view > *:nth-child(8) { animation-delay: 350ms; }
.week-view > *:nth-child(9) { animation-delay: 400ms; }
.week-view > *:nth-child(10) { animation-delay: 450ms; }

/* Day Cards */
.day-card {
  border-radius: 20px;
  padding: 1.25rem 1.5rem;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.day-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.day-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
}

.day-card:hover::before {
  opacity: 1;
}

.day-card.consumed {
  opacity: 0.5;
  filter: grayscale(0.3);
}

/* Playful varied gradients */
.gradient-0 { background: var(--card-coral); }
.gradient-1 { background: var(--card-sunset); }
.gradient-2 { background: var(--card-mint); }
.gradient-3 { background: var(--card-peach); }
.gradient-4 { background: var(--card-lavender); }

/* Legacy class support */
.gradient-pink { background: var(--card-coral); }
.gradient-blue { background: var(--card-mint); }
.gradient-green { background: var(--card-peach); }

.day-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.day-label {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0.7;
}

.ingredient-count {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.7;
}

.ingredient-icon {
  font-size: 1.1rem;
}

.day-card .meal-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  transition: opacity 0.2s;
}

.day-card .meal-name:hover {
  opacity: 0.8;
}

.day-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Tonight Card - HERO moment */
.tonight-card {
  border-radius: 28px;
  padding: 2.5rem 2rem;
  color: white;
  background: var(--tonight-bg) !important;
  box-shadow:
    0 12px 40px rgba(238, 90, 36, 0.35),
    0 4px 12px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255,255,255,0.2);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
  min-height: 160px;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
}

.tonight-card::before {
  content: '🍽️';
  position: absolute;
  top: -20px;
  right: -20px;
  font-size: 8rem;
  opacity: 0.15;
  transform: rotate(15deg);
  pointer-events: none;
}

.tonight-card:hover {
  transform: scale(1.02);
  box-shadow:
    0 16px 48px rgba(238, 90, 36, 0.4),
    0 6px 16px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255,255,255,0.2);
}

.tonight-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tonight-label {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.95;
  background: rgba(255,255,255,0.2);
  padding: 0.35rem 0.75rem;
  border-radius: 100px;
}

.tonight-meal-name {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 900;
  color: white;
  text-decoration: none;
  line-height: 1.1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: opacity 0.2s;
}

.tonight-meal-name:hover {
  opacity: 0.9;
}

.tonight-card.consumed {
  opacity: 0.5;
  filter: grayscale(0.4);
}

.tonight-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Unassigned Section */
.unassigned-section {
  margin-top: 2rem;
}

.section-title {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-color), transparent);
}

.unassigned-card {
  background: linear-gradient(135deg, #faf8f5 0%, #f5f0ea 100%);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.unassigned-card:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-sm);
}

.unassigned-card .meal-name {
  font-family: var(--font-display);
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1rem;
}

.unassigned-card .ingredient-count {
  color: var(--text-secondary);
}

/* Sections */
.section {
  margin-top: 2rem;
}

/* Backlog Section */
.backlog-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.backlog-card {
  background: #f8f6f3;
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px dashed var(--border-color);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.backlog-card:hover {
  border-color: #ccc;
  transform: translateX(4px);
}

.backlog-card .meal-name {
  font-family: var(--font-display);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 1.05rem;
}

.backlog-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.backlog-card .ingredient-count {
  color: var(--text-secondary);
}

.btn-add-week {
  background: var(--header-bg);
  color: white;
  font-size: 1.25rem;
  font-weight: bold;
}

.btn-add-week:hover {
  opacity: 0.9;
}

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

.empty-state p {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.hint {
  font-size: 1rem;
  color: var(--text-secondary);
}

.hint a {
  color: #ee5a24;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid currentColor;
  transition: opacity 0.2s;
}

.hint a:hover {
  opacity: 0.7;
}

/* FAB */
.fab {
  position: fixed;
  bottom: 2rem;
  right: 1.5rem;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--tonight-bg);
  color: white;
  font-size: 2.25rem;
  font-weight: 300;
  border: none;
  box-shadow:
    0 6px 20px rgba(238, 90, 36, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease;
  z-index: 100;
}

.fab:hover {
  transform: scale(1.15) rotate(90deg);
  box-shadow:
    0 8px 28px rgba(238, 90, 36, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.15);
}

.fab:active {
  transform: scale(1.05) rotate(90deg);
}

/* Modal */
.modal {
  border: none;
  border-radius: 24px;
  padding: 0;
  max-width: 420px;
  width: calc(100% - 2rem);
  box-shadow: var(--shadow-lg);
  margin: auto;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--content-bg);
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translate(-50%, -45%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.modal::backdrop {
  background: rgba(30, 25, 20, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  padding: 2rem;
}

.modal-content h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

input[type="text"],
input[type="password"],
select {
  font-family: var(--font-body);
  width: 100%;
  padding: 0.875rem 1.25rem;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus {
  outline: none;
  border-color: #ee5a24;
  box-shadow: 0 0 0 3px rgba(238, 90, 36, 0.15);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Buttons */
.btn {
  font-family: var(--font-body);
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition:
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary {
  background: var(--tonight-bg);
  color: white;
  box-shadow: 0 4px 12px rgba(238, 90, 36, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(238, 90, 36, 0.4);
}

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

.btn-secondary:hover {
  background: #ebe5df;
}

.btn-danger {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.btn-block {
  width: 100%;
}

/* Meal Detail */
.meal-detail-form {
  margin-bottom: 2rem;
}

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

.ingredients-section h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.ingredient-form {
  margin-bottom: 1rem;
}

.ingredient-inputs {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 0.5rem;
  align-items: center;
}

.input-name {
  min-width: 0;
}

.input-qty {
  width: 70px !important;
}

.input-category {
  width: 100px !important;
}

.btn-add {
  padding: 0.75rem 1rem;
  min-width: 44px;
}

.ingredients {
  list-style: none;
}

.ingredient-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.ingredient-name {
  flex: 1;
  font-weight: 500;
}

.ingredient-qty {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.ingredient-category {
  background: #f0f0f0;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.btn-delete {
  background: none;
  border: none;
  color: #f5576c;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.no-ingredients {
  color: var(--text-secondary);
  font-style: italic;
  padding: 1rem 0;
}

.danger-zone {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

/* Login */
.login-form {
  max-width: 300px;
  margin: 2rem auto;
}

.pin-input {
  font-size: 1.5rem !important;
  text-align: center;
  letter-spacing: 0.5em;
}

.error-message {
  background: #fee2e2;
  color: #dc2626;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  text-align: center;
}

/* Shopping List */
.shopping-actions {
  margin-bottom: 1.5rem;
}

.shopping-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.category-group {
  background: #f9f9f9;
  border-radius: 12px;
  padding: 1rem;
}

.category-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.category-items {
  list-style: none;
}

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

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

.item-name {
  font-weight: 500;
}

.item-qty {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Responsive */
@media (min-width: 640px) {
  .ingredient-inputs {
    grid-template-columns: 1fr 80px 120px auto;
  }
}

@media (min-width: 768px) {
  .app {
    max-width: 800px;
    margin: 0 auto;
  }

  .header {
    border-radius: 0 0 24px 24px;
    margin-top: 1rem;
  }

  .content {
    border-radius: 24px 24px 0 0;
  }

  body {
    padding: 0 1rem;
  }
}

@media (min-width: 1024px) {
  .app {
    max-width: 900px;
  }
}

/* Dark Mode - warm & cozy */
@media (prefers-color-scheme: dark) {
  :root {
    --content-bg: #252220;
    --text-primary: #f5f0ea;
    --text-secondary: #a89f95;
    --border-color: #3d3630;

    /* Muted but still warm gradients for dark mode */
    --card-coral: linear-gradient(135deg, #4a3535 0%, #3d2d35 100%);
    --card-sunset: linear-gradient(135deg, #3a3545 0%, #453545 100%);
    --card-mint: linear-gradient(135deg, #2d3d35 0%, #2d3540 100%);
    --card-peach: linear-gradient(135deg, #3d3530 0%, #453530 100%);
    --card-lavender: linear-gradient(135deg, #353540 0%, #3d3545 100%);
  }

  body {
    background: linear-gradient(180deg, #1a1512 0%, #0f0d0b 100%);
  }

  .content {
    background: var(--content-bg);
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.3);
  }

  .content::before {
    opacity: 0.03;
  }

  .day-card {
    color: var(--text-primary);
  }

  .day-card .meal-name,
  .day-card .day-label {
    color: var(--text-primary);
  }

  .unassigned-card {
    background: linear-gradient(135deg, #2a2520 0%, #252220 100%);
    border-color: var(--border-color);
  }

  .backlog-card {
    background: #252220;
    border-color: var(--border-color);
  }

  .backlog-card .meal-name {
    color: var(--text-secondary);
  }

  .category-group {
    background: #252220;
  }

  input[type="text"],
  input[type="password"],
  select {
    background: #252220;
    border-color: var(--border-color);
    color: var(--text-primary);
  }

  .btn-secondary {
    background: #2d2a25;
    color: var(--text-primary);
    border-color: var(--border-color);
  }

  .modal {
    background: var(--content-bg);
  }

  .ingredient-category {
    background: #2d2a25;
    color: var(--text-secondary);
  }

  .error-message {
    background: #3d2020;
    color: #ff9080;
  }

  .section-title::after {
    background: linear-gradient(90deg, var(--border-color), transparent);
  }
}
