/* Google Fonts Import: Inter */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Soft Modern Palette (Option 9) */
  --bg-app: #f4f6f9;
  /* Light grey-blue background */
  --bg-panel: #ffffff;
  /* White cards */
  --bg-sidebar: #ffffff;
  /* White sidebar */

  --text-primary: #1e293b;
  /* Deep slate */
  --text-secondary: #64748b;
  /* Muted slate */
  --text-light: #94a3b8;

  /* Primary Indigo */
  --primary: #6366f1;
  /* Indigo 500 */
  --primary-rgb: 99, 102, 241;
  --primary-hover: #4f46e5;
  --primary-light: #e0e7ff;
  /* Indigo 100 */

  /* Accents */
  --success: #10b981;
  --success-bg: #d1fae5;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --warning: #f59e0b;

  /* UI Elements */
  --border: #e2e8f0;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  /* For cards */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-soft: 0 10px 15px -3px rgba(0, 0, 0, 0.03);

  --sidebar-width: 260px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  overflow: hidden;
  /* Prevent body scroll, scrolling happens in main */
}

a {
  text-decoration: none;
  color: inherit;
}

/* Layout: Sidebar + Main Content */
.app-container {
  display: flex;
  width: 100%;
  height: 100%;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  /* Pushes footer down */
}

.sidebar-footer {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-item:hover {
  background: var(--bg-app);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

/* Main Content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 48px;
}

.main-content-full {
  padding: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

/* UI Components */
.card {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  gap: 8px;
}

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

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

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

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

.btn-danger {
  background: white;
  border: 1px solid var(--danger-bg);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-bg);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--bg-app);
  color: var(--primary);
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: white;
  transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Grid Layouts */
.grid-meals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.grid-ingredients {
  display: grid;
  gap: 12px;
}

/* Meal Card Specifics */
.meal-card {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

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

.meal-img-placeholder {
  height: 220px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 48px;
}

.meal-img {
  height: 220px;
  background-size: cover;
  background-position: center;
  width: 100%;
}

.meal-content {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.meal-title {
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 8px;
}

.meal-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  flex: 1;
}

.meal-meta {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.tag {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}

.tag-cal {
  background: #fff7ed;
  color: #c2410c;
}

.tag-pro {
  background: #eff6ff;
  color: #1d4ed8;
}

/* Ingredient Item */
.ingredient-row {
  display: flex;
  align-items: center;
  padding: 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.2s;
}

.ingredient-row:hover {
  border-color: var(--primary);
}

.ing-info {
  flex: 1;
}

.ing-name {
  font-weight: 600;
  font-size: 16px;
}

.ing-detail {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Toast */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  background: white;
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--primary);
  min-width: 300px;
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--danger);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-panel {
  background: white;
  width: 90%;
  max-width: 500px;
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-soft);
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-overlay.open .modal-panel {
  transform: scale(1);
}

/* Auth Page specific */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg-app);
}

/* Mobile Navigation */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: white;
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
}

.mobile-logo {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
}

.mobile-menu-close {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  margin-left: auto;
}

/* Mobile Navigation */
.mobile-menu-btn {
  display: none;
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 20;
  background: white;
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 768px) {
  .app-container {
    position: relative;
  }

  .sidebar {
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
    z-index: 25;
    /* Above overlay */
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    padding-top: 80px;
    /* Space for menu button */
    padding-left: 24px;
    padding-right: 24px;
  }

  .mobile-menu-btn {
    display: flex;
    /* Kept for legacy if valid, but we use .mobile-header now */
    /* Reverting display:none from desktop rule */
    position: relative;
    /* Reset from absolute if needed, or keeping it inside header */
    top: auto;
    left: auto;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .mobile-header {
    display: flex;
  }

  .mobile-menu-close {
    display: block;
  }

  .brand {
    justify-content: space-between;
    width: 100%;
  }
}