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

:root {
  color-scheme: light;
  --bg: #f6f2eb;
  --bg-elevated: rgba(252, 248, 241, 0.78);
  --bg-strong: rgba(255, 251, 246, 0.9);
  --border: rgba(112, 96, 78, 0.17);
  --border-weak: rgba(144, 125, 104, 0.22);
  --text: #3a2f24;
  --text-muted: #7d6a58;
  --shadow: 0 16px 32px rgba(66, 52, 38, 0.09);
  --shadow-lift: 0 24px 48px rgba(66, 52, 38, 0.16);
  --accent-1: #d1a574;
  --accent-2: #b88d63;
  --accent-3: #9a7b5c;
  --glass-blur: 18px;
}

.dark {
  color-scheme: dark;
  --bg: #1f1914;
  --bg-elevated: rgba(48, 40, 32, 0.82);
  --bg-strong: rgba(58, 48, 39, 0.9);
  --border: rgba(204, 178, 150, 0.22);
  --border-weak: rgba(176, 150, 124, 0.19);
  --text: #eee2d3;
  --text-muted: #baa184;
  --shadow: 0 18px 36px rgba(12, 8, 5, 0.62);
  --shadow-lift: 0 28px 60px rgba(12, 8, 5, 0.74);
  --glass-blur: 16px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  height: 100%;
}

body {
  font-family: 'Sora', sans-serif;
}

h1, h2, h3, h4, .heading {
  font-family: 'Fraunces', serif;
  letter-spacing: -0.01em;
}

body::before {
  content: "";
  position: fixed;
  inset: -20% -10% 0 -10%;
  background:
    radial-gradient(circle at 20% 10%, rgba(196, 153, 97, 0.14), transparent 55%),
    radial-gradient(circle at 80% 0%, rgba(153, 120, 88, 0.16), transparent 50%),
    linear-gradient(120deg, rgba(112, 96, 78, 0.03), rgba(112, 96, 78, 0.05));
  pointer-events: none;
  z-index: -1;
}

.dark body::before {
  background:
    radial-gradient(circle at 20% 10%, rgba(194, 154, 111, 0.14), transparent 55%),
    radial-gradient(circle at 80% 0%, rgba(160, 127, 96, 0.14), transparent 50%),
    linear-gradient(120deg, rgba(17, 12, 9, 0.5), rgba(17, 12, 9, 0.7));
}

.glass-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.2);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.2);
  box-shadow: var(--shadow);
}

.glass-card {
  background: var(--bg-strong);
  border: 1px solid var(--border-weak);
  backdrop-filter: blur(calc(var(--glass-blur) * 0.85)) saturate(1.15);
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 0.85)) saturate(1.15);
  box-shadow: var(--shadow);
}

.glass-subtle {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border-weak);
  backdrop-filter: blur(calc(var(--glass-blur) * 0.5)) saturate(1.1);
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 0.5)) saturate(1.1);
}

.dark .glass-subtle {
  background: rgba(58, 47, 38, 0.6);
}

.glass-input {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--border-weak);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.dark .glass-input {
  background: rgba(56, 45, 35, 0.66);
  border-color: rgba(176, 150, 124, 0.2);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.glass-input::placeholder {
  color: var(--text-muted);
}

.glass-input:focus {
  outline: none;
  border-color: rgba(196, 153, 97, 0.56);
  box-shadow: 0 0 0 3px rgba(196, 153, 97, 0.2);
}

input[type="checkbox"] {
  accent-color: var(--accent-1);
}

.lift {
  transition: transform 200ms ease, box-shadow 200ms ease;
}

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

.animated-gradient {
  background-size: 220% 220%;
  animation: gradientShift 10s ease infinite;
}

.production-notes-gradient {
  background: linear-gradient(120deg, rgba(191, 151, 105, 0.84), rgba(167, 130, 95, 0.86), rgba(129, 101, 76, 0.84));
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.stagger-item {
  animation: fadeUp 420ms ease both;
}

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

.animate-fade {
  animation: fadeIn 320ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.theme-transition, .theme-transition * {
  transition: background-color 300ms ease, color 300ms ease, border-color 300ms ease, box-shadow 300ms ease;
}

button {
  position: relative;
  overflow: hidden;
}

.btn-gradient-soft {
  background-image: linear-gradient(120deg, #b59d82, #ab9378);
}

button.btn-gradient-soft:hover {
  background-image: linear-gradient(120deg, #b0997f, #a78f75);
}

.dark .btn-gradient-soft {
  background-image: linear-gradient(120deg, #917a62, #867059);
}

.dark button.btn-gradient-soft:hover {
  background-image: linear-gradient(120deg, #958067, #8b755d);
}

.ripple-ink {
  position: absolute;
  border-radius: 9999px;
  transform: scale(0);
  opacity: 0.6;
  background: rgba(255, 255, 255, 0.5);
  pointer-events: none;
  animation: ripple 600ms ease-out forwards;
}

.dark .ripple-ink {
  background: rgba(198, 164, 129, 0.45);
}

@keyframes ripple {
  to { transform: scale(2.8); opacity: 0; }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
}

.badge-light {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

.badge-energy { background: rgba(249, 115, 22, 0.16); color: #c2410c; }
.badge-protein { background: rgba(168, 132, 96, 0.17); color: #78553a; }
.badge-carb { background: rgba(120, 113, 108, 0.2); color: #57534e; }
.badge-fat { background: rgba(244, 63, 94, 0.14); color: #be123c; }

.dark .badge-energy { background: rgba(249, 115, 22, 0.2); color: #fdba74; }
.dark .badge-protein { background: rgba(168, 132, 96, 0.28); color: #e7c6a0; }
.dark .badge-carb { background: rgba(120, 113, 108, 0.32); color: #d6d3d1; }
.dark .badge-fat { background: rgba(244, 63, 94, 0.2); color: #fda4af; }

.icon-gradient {
  background: linear-gradient(135deg, rgba(200, 160, 110, 0.18), rgba(132, 108, 84, 0.22));
  color: #7a5b43;
}

.dark .icon-gradient {
  color: #d8b690;
}

.icon-gradient.orange {
  background: linear-gradient(135deg, rgba(176, 136, 95, 0.2), rgba(132, 108, 84, 0.24));
  color: #8a6446;
}

.dark .icon-gradient.orange {
  color: #d8b690;
}

.icon-gradient.red {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.2), rgba(244, 63, 94, 0.25));
  color: #be123c;
}

.dark .icon-gradient.red {
  color: #fda4af;
}

.nav-active {
  background: rgba(196, 153, 97, 0.14);
  color: #7a5b43;
}

.dark .nav-active {
  background: rgba(191, 151, 105, 0.18);
  color: #e7c6a0;
}

.nav-mobile-active {
  background: rgba(196, 153, 97, 0.14);
  color: #8a6446;
}

.dark .nav-mobile-active {
  background: rgba(191, 151, 105, 0.18);
  color: #e7c6a0;
}

.toast {
  background: var(--bg-strong);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(calc(var(--glass-blur) * 0.8)) saturate(1.1);
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) * 0.8)) saturate(1.1);
}

.toast.toast-error {
  border-color: rgba(248, 113, 113, 0.4);
}

.toast.toast-success {
  border-color: rgba(191, 151, 105, 0.36);
}

.alert-glow {
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.4), 0 20px 45px rgba(248, 113, 113, 0.25);
}

.incident-spotlight {
  border: 1px solid rgba(248, 113, 113, 0.28);
  background:
    linear-gradient(135deg, rgba(255, 244, 242, 0.9), rgba(255, 250, 248, 0.86));
  box-shadow: 0 14px 28px rgba(239, 68, 68, 0.12);
}

.dark .incident-spotlight {
  border-color: rgba(248, 113, 113, 0.34);
  background:
    linear-gradient(135deg, rgba(78, 34, 34, 0.52), rgba(57, 30, 29, 0.48));
  box-shadow: 0 16px 32px rgba(18, 7, 7, 0.48);
}

.incident-spotlight-card {
  border-radius: 0.95rem;
  border: 1px solid rgba(248, 113, 113, 0.2);
  background: rgba(255, 255, 255, 0.78);
  padding: 0.6rem 0.7rem;
  box-shadow: 0 10px 24px rgba(239, 68, 68, 0.08);
}

.dark .incident-spotlight-card {
  background: rgba(66, 39, 35, 0.58);
  border-color: rgba(248, 113, 113, 0.24);
}

.incident-spotlight-card-low {
  border-color: rgba(163, 133, 91, 0.26);
}

.incident-spotlight-card-med {
  border-color: rgba(245, 158, 11, 0.34);
}

.incident-spotlight-card-high {
  border-color: rgba(239, 68, 68, 0.46);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2), 0 14px 30px rgba(239, 68, 68, 0.18);
}

.dark .incident-spotlight-card-low {
  border-color: rgba(198, 164, 126, 0.32);
}

.dark .incident-spotlight-card-med {
  border-color: rgba(245, 158, 11, 0.36);
}

.dark .incident-spotlight-card-high {
  border-color: rgba(248, 113, 113, 0.56);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.26), 0 12px 28px rgba(0, 0, 0, 0.45);
}

.incident-pulse {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 9999px;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
  animation: incidentPulse 1.8s ease-out infinite;
}

@keyframes incidentPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.58);
  }
  75% {
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@media (max-width: 1023px) {
  #appMain {
    padding-bottom: calc(8.5rem + env(safe-area-inset-bottom)) !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-split-page {
    height: auto !important;
    min-height: calc(100dvh - 10rem);
    overflow: visible !important;
  }

  .mobile-split-page > .mobile-stacked-pane {
    height: auto !important;
    min-height: 22rem;
    border-left-width: 0 !important;
    border-right-width: 0 !important;
    scroll-margin-top: 5rem;
  }

  .mobile-split-page > .mobile-stacked-pane + .mobile-stacked-pane {
    margin-top: 0.75rem;
  }

  #recipeDetailPanel,
  #setDetailPanel,
  #haccpSidePanel,
  #editor > .flex-1,
  #setEditor > .flex-1 {
    overflow: visible !important;
  }

  #emptyEditor,
  #setEmptyEditor {
    position: static;
    min-height: 15rem;
    padding: 2rem 1.25rem;
    text-align: center;
  }

  #editor,
  #setEditor {
    height: auto !important;
    min-height: 28rem;
  }

  .recipe-item-toolbar,
  .set-item-toolbar {
    flex-wrap: wrap;
  }

  .recipe-item-toolbar > .relative,
  .recipe-item-toolbar > input,
  .set-item-toolbar > .relative,
  .set-item-toolbar > input {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }

  .recipe-item-toolbar > button,
  .set-item-toolbar > button {
    flex: 1 1 calc(50% - 0.25rem);
    min-height: 2.5rem;
  }

  #ingredientsPage .sticky {
    position: static;
  }

  #ingredientsPage #ingList {
    flex: none;
    overflow: visible;
    max-height: none;
  }

  #ingredientsPage #ingEditorPanel > .flex-1 {
    flex: none;
    overflow: visible;
  }

  #ingredientsPage #ingEditorPanel {
    padding-bottom: calc(2.5rem + env(safe-area-inset-bottom));
  }
}

@media (max-width: 768px) {
  :root {
    --glass-blur: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stagger-item,
  .animate-fade,
  .animated-gradient,
  .incident-pulse {
    animation: none !important;
  }

  .lift {
    transition: none;
  }
}

.text-slate-900 { color: #3a2f24; }
.text-slate-800 { color: #4a3b2d; }
.text-slate-700 { color: #63503e; }
.text-slate-600 { color: #79624d; }
.text-slate-500 { color: #90745a; }
.text-slate-400 { color: #a78a6d; }
.text-slate-300 { color: #bda184; }

.border-slate-200 { border-color: rgba(161, 140, 117, 0.24); }
.border-slate-100 { border-color: rgba(161, 140, 117, 0.18); }

.ring-slate-200 { --tw-ring-color: rgba(161, 140, 117, 0.3); }

.bg-white { background-color: rgba(254, 250, 244, 0.84); }
.bg-slate-50 { background-color: rgba(251, 245, 236, 0.76); }
.bg-slate-100 { background-color: rgba(244, 232, 217, 0.76); }
.bg-slate-50\/50 { background-color: rgba(251, 245, 236, 0.56); }
.bg-slate-50\/40 { background-color: rgba(251, 245, 236, 0.48); }
.bg-slate-50\/60 { background-color: rgba(251, 245, 236, 0.64); }
.bg-slate-50\/70 { background-color: rgba(251, 245, 236, 0.72); }

.dark .text-slate-900 { color: #f8efe3; }
.dark .text-slate-800 { color: #ebdccb; }
.dark .text-slate-700 { color: #ddc8b1; }
.dark .text-slate-600 { color: #ceb499; }
.dark .text-slate-500 { color: #bc9d7e; }
.dark .text-slate-400 { color: #aa8969; }
.dark .text-slate-300 { color: #957759; }

.dark .border-slate-200 { border-color: rgba(189, 162, 134, 0.22); }
.dark .border-slate-100 { border-color: rgba(189, 162, 134, 0.16); }

.dark .bg-white { background-color: rgba(60, 50, 40, 0.8); }
.dark .bg-slate-50 { background-color: rgba(56, 46, 37, 0.68); }
.dark .bg-slate-100 { background-color: rgba(60, 50, 40, 0.8); }
.dark .bg-slate-50\/50 { background-color: rgba(56, 46, 37, 0.58); }
.dark .bg-slate-50\/40 { background-color: rgba(56, 46, 37, 0.5); }
.dark .bg-slate-50\/60 { background-color: rgba(56, 46, 37, 0.62); }
.dark .bg-slate-50\/70 { background-color: rgba(56, 46, 37, 0.68); }
/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none;  scrollbar-width: none; }

/* Custom refined scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(152, 130, 109, 0.56); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(119, 98, 79, 0.86); }
