/* Linear Design System Inspired Theme for NutriSnap */

:root {
  /* Linear Canvas & Surface Ladder */
  --canvas: #010102;
  --surface-1: #0f1011;
  --surface-2: #141516;
  --surface-3: #18191a;
  --surface-4: #191a1b;

  /* Hairline Borders */
  --hairline: #23252a;
  --hairline-strong: #34343a;
  --hairline-tertiary: #3e3e44;

  /* Typography Colors */
  --ink: #f7f8f8;
  --ink-muted: #d0d6e0;
  --ink-subtle: #8a8f98;
  --ink-tertiary: #62666d;

  /* Linear Signature Lavender Accent */
  --primary: #5e6ad2;
  --primary-hover: #828fff;
  --primary-focus: #5e69d1;
  --primary-glow: rgba(94, 106, 210, 0.25);

  /* Functional Macro Accents */
  --macro-cal: #10b981;
  --macro-cal-bg: rgba(16, 185, 129, 0.12);

  --macro-pro: #5e6ad2;
  --macro-pro-bg: rgba(94, 106, 210, 0.12);

  --macro-carb: #06b6d4;
  --macro-carb-bg: rgba(6, 182, 212, 0.12);

  --macro-fat: #f59e0b;
  --macro-fat-bg: rgba(245, 158, 11, 0.12);

  --danger: #f43f5e;

  /* Border Radii (Linear Design Tokens) */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;

  /* Transitions & Shadows */
  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-lift: 0 12px 32px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--canvas);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-bottom: 100px;
  background-image:
    radial-gradient(ellipse 60% 40% at 50% -10%, rgba(94, 106, 210, 0.08), transparent 70%),
    radial-gradient(ellipse 40% 30% at 100% 90%, rgba(16, 185, 129, 0.05), transparent 70%);
  background-attachment: fixed;
}

.app-container {
  width: 100%;
  max-width: 480px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Linear Top Navigation Bar */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 2px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  box-shadow: 0 0 16px var(--primary-glow);
}

.brand-icon svg {
  width: 20px;
  height: 20px;
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.brand .subtitle {
  font-size: 0.72rem;
  color: var(--ink-subtle);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  background: var(--surface-1);
  color: var(--ink-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--hairline-strong);
  background: var(--surface-2);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Navigation Tabs (Linear Pill Switcher) */
.nav-tabs {
  display: flex;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink-subtle);
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tab-btn svg {
  width: 15px;
  height: 15px;
}

.tab-btn.active {
  background: var(--surface-3);
  color: var(--ink);
  border: 1px solid var(--hairline-strong);
}

/* Tab Content Visibility */
.tab-content {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.tab-content.active {
  display: flex;
}

/* Floating Action Button for Snap / Upload */
.snap-cta-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  z-index: 100;
}

.snap-btn {
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: linear-gradient(180deg, #5e6ad2 0%, #4c57b8 100%);
  color: #ffffff;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 8px 24px var(--primary-glow);
  transition: var(--transition-fast);
}

.snap-btn:active {
  transform: scale(0.98);
}

.snap-btn:hover {
  background: linear-gradient(180deg, #6c78e0 0%, #5863c7 100%);
}

.snap-btn svg {
  width: 22px;
  height: 22px;
}

/* Date Navigator */
.date-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 6px 12px;
}

.date-nav-btn {
  background: transparent;
  border: none;
  color: var(--ink-subtle);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  transition: var(--transition-fast);
}

.date-nav-btn:hover {
  color: var(--ink);
}

.current-date-display {
  position: relative;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
  cursor: pointer;
  letter-spacing: -0.01em;
}

.current-date-display input[type="date"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Linear Card Surfaces */
.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-lift);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
}

/* Calorie Ring Overview */
.calorie-hero {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-bottom: 20px;
  gap: 10px;
}

.calorie-ring-container {
  position: relative;
  width: 150px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-fill {
  transition: stroke-dashoffset 0.5s ease-out;
}

.calorie-center-text {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.big-number {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.1;
}

.calorie-center-text .label {
  font-size: 0.7rem;
  color: var(--ink-subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.calorie-stat-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-box {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--ink-subtle);
}

.stat-divider {
  height: 1px;
  background: var(--hairline);
  width: 100%;
}

/* Macros Grid */
.macros-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.macro-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.macro-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
}

.macro-name {
  color: var(--ink-subtle);
  font-weight: 500;
}

.macro-val {
  color: var(--ink);
  font-weight: 600;
}

.bar-bg {
  height: 7px;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.macro-item.protein .bar-fill { background: linear-gradient(90deg, #5e6ad2, #828fff); }
.macro-item.carbs .bar-fill { background: linear-gradient(90deg, #06b6d4, #38bdf8); }
.macro-item.fats .bar-fill { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

/* Meals List Section */
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px;
}

.section-title h3 {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.badge {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  color: var(--ink-subtle);
}

.meals-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meal-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  transition: var(--transition-fast);
}

.meal-card:hover {
  border-color: var(--hairline-strong);
  background: var(--surface-2);
}

.meal-img {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--surface-3);
  border: 1px solid var(--hairline);
}

.meal-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meal-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.meal-notes {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  letter-spacing: -0.01em;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meal-time {
  font-size: 0.7rem;
  color: var(--ink-tertiary);
}

.meal-macros-pills {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.pill {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.pill.cal { background: var(--macro-cal-bg); color: var(--macro-cal); }
.pill.pro { background: var(--macro-pro-bg); color: var(--macro-pro); }
.pill.carb { background: var(--macro-carb-bg); color: var(--macro-carb); }
.pill.fat { background: var(--macro-fat-bg); color: var(--macro-fat); }

.delete-meal-btn {
  background: transparent;
  border: none;
  color: var(--ink-tertiary);
  cursor: pointer;
  padding: 4px;
  transition: var(--transition-fast);
}

.delete-meal-btn:hover {
  color: var(--danger);
}

.empty-state {
  text-align: center;
  padding: 28px 16px;
  background: var(--surface-1);
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius-lg);
}

.empty-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.empty-state p {
  font-weight: 600;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.empty-state small {
  color: var(--ink-subtle);
  font-size: 0.75rem;
}

/* Linear Dark Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(10px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.active {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 430px;
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-xl);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.9);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.close-modal-btn {
  background: transparent;
  border: none;
  color: var(--ink-subtle);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Image Preview & AI Spinner */
.image-preview-box {
  position: relative;
  width: 100%;
  height: 190px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--hairline);
}

.image-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 16, 17, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 16px;
}

.ai-overlay.hidden {
  display: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(94, 106, 210, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Forms (Linear Input Styling) */
.meal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meal-form.hidden {
  display: none;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row .form-group {
  flex: 1;
}

label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-subtle);
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="url"] {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition-fast);
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.help-text {
  font-size: 0.7rem;
  color: var(--ink-tertiary);
}

.form-section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-top: 8px;
}

.modal-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.84rem;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
}

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

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

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--ink-muted);
}

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

/* Analytics Chart Containers */
.analytics-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.analytics-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.chart-container {
  position: relative;
  height: 190px;
  width: 100%;
}

.history-controls input {
  margin-bottom: 12px;
}
