/*
 * Общ UI слой на табовете в приложението (план, насоки, анализ, профил).
 * Зарежда се след стиловете на страницата и изравнява шрифта, цветовете,
 * плаващите бутони, долните листове и движението. Само визия — логиката е в app-ui.js.
 */

:root {
  --ui-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ui-accent: #05737D;
  --ui-accent-strong: #075C66;
  --ui-accent-soft: rgba(3, 147, 156, 0.10);
  --ui-ink: #0B2B2A;
  --ui-ink-2: #3D5856;
  --ui-muted: #5B6E6B;
  --ui-line: rgba(11, 43, 42, 0.08);
  --ui-surface: #ffffff;
  --ui-warn: #B45309;
  --ui-warn-soft: rgba(245, 158, 11, 0.12);
  --ui-ease: var(--ds-ease-emphasis, cubic-bezier(0.16, 1, 0.3, 1));
  --ui-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ui-fab-gap: calc(96px + env(safe-area-inset-bottom, 0px));
}
[data-theme="dark"] {
  --ui-accent: #19D6D2;
  --ui-accent-strong: #5FE6E3;
  --ui-accent-soft: rgba(25, 214, 210, 0.12);
  --ui-ink: #E3F4F1;
  --ui-ink-2: #B4CFCA;
  --ui-muted: #85A39E;
  --ui-line: rgba(178, 236, 226, 0.09);
  --ui-surface: #102524;
  --ui-warn: #FBBF24;
  --ui-warn-soft: rgba(251, 191, 36, 0.10);
}

/* --- Шрифт: един навсякъде --- */
body, button, input, textarea, select {
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* --- Плаващите бутони не закриват съдържанието --- */
body { padding-bottom: var(--ui-fab-gap); }
.fab-chat, .fab-food {
  width: 52px !important;
  height: 52px !important;
  border-radius: 18px !important;
  animation: none !important;
  transition: transform 0.45s var(--ui-ease), opacity 0.3s ease, box-shadow 0.3s ease !important;
  will-change: transform;
}
.fab-chat {
  /* Аватарът е снимка: тънък пръстен вместо тежък градиент и пулсиране. */
  background: var(--ui-surface) !important;
  box-shadow: 0 10px 28px -10px rgba(0, 0, 0, 0.45), 0 0 0 2px var(--ui-accent-soft) !important;
}
.fab-chat::before { display: none !important; }
.fab-food {
  box-shadow: 0 10px 28px -10px rgba(3, 147, 156, 0.65) !important;
}
html.ui-fabs-away .fab-chat,
html.ui-fabs-away .fab-food {
  transform: translateY(140%) scale(0.9) !important;
  opacity: 0;
  pointer-events: none;
}

/* --- Долен лист: дръжката се дърпа --- */
.modal-drag-handle { cursor: grab; touch-action: none; }
.modal-card.ui-dragging { transition: none !important; }
.modal-overlay.ui-drag-release .modal-card { transition: transform 0.38s var(--ui-ease) !important; }

/* --- Отметка на хранене: изрисува се --- */
.meal-card.ui-just-done .meal-check-btn.done { animation: uiCheckPop 0.5s var(--ui-spring); }
.meal-card.ui-just-done .meal-check-btn.done i { animation: uiCheckDraw 0.42s var(--ui-ease) 0.05s both; }
@keyframes uiCheckPop {
  0% { transform: scale(0.82); }
  55% { transform: scale(1.2); }
  100% { transform: scale(1.12); }
}
@keyframes uiCheckDraw {
  from { clip-path: inset(0 100% 0 0); opacity: 0.4; }
  to { clip-path: inset(0 0 0 0); opacity: 1; }
}
.meal-card.ui-just-done { animation: uiCardSettle 0.55s var(--ui-ease); }
@keyframes uiCardSettle {
  0% { transform: scale(1); }
  35% { transform: scale(0.985); }
  100% { transform: scale(1); }
}

/* --- Карта на хранене: йерархия --- */
.meal-type {
  font-size: 0.75rem !important;
  letter-spacing: 0.06em !important;
  font-weight: 700 !important;
  opacity: 0.92;
}
.meal-name {
  font-weight: 650 !important;
  letter-spacing: -0.01em;
  line-height: 1.3 !important;
  margin-bottom: 4px !important;
}
.meal-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ui-muted);
  font-variant-numeric: tabular-nums;
}
.meal-meta span + span::before {
  content: '';
  display: inline-block;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  margin-right: 10px;
  vertical-align: middle;
}

/* --- Дневната оценка, преди да има отметки --- */
.daily-score-count {
  margin-top: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
}
.daily-score-hint { font-size: 0.875rem; opacity: 0.9; margin-top: 2px; }

/* --- „Ограничи“: неутрално, не наказателно --- */
.bad-list li {
  background: var(--ui-warn-soft) !important;
  border-left: 3px solid var(--ui-warn) !important;
}
.bad-list li::before {
  content: '' !important;
  display: inline-block;
  width: 10px; height: 2px;
  border-radius: 2px;
  background: var(--ui-warn);
  vertical-align: middle;
  margin-right: 10px !important;
}

/* --- Профил: заключените полета са обобщение, не форма --- */
.form-input:disabled, .form-textarea:disabled, select.form-input:disabled {
  opacity: 1 !important;
  cursor: default !important;
  background: transparent !important;
  border-color: transparent !important;
  border-bottom: 1px solid var(--ui-line) !important;
  border-radius: 0 !important;
  padding: 4px 0 10px !important;
  min-height: 0 !important;
  font-weight: 600;
  color: var(--ui-ink) !important;
  -webkit-text-fill-color: var(--ui-ink);
  appearance: none;
  -webkit-appearance: none;
  resize: none;
  box-shadow: none !important;
}
.form-input:disabled::placeholder, .form-textarea:disabled::placeholder { color: var(--ui-muted); opacity: 0.7; }
.form-group:has(> .form-input:disabled) .form-label,
.form-group:has(> .form-textarea:disabled) .form-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ui-muted);
  margin-bottom: 2px;
}

/* --- Дърпане за обновяване --- */
.ui-ptr {
  position: fixed;
  top: 0; left: 50%;
  z-index: 950;
  width: 38px; height: 38px;
  margin-left: -19px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ui-surface);
  color: var(--ui-accent);
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.4);
  transform: translateY(-48px);
  opacity: 0;
  pointer-events: none;
}
.ui-ptr svg { width: 20px; height: 20px; }
.ui-ptr.is-loading svg { animation: uiSpin 0.8s linear infinite; }
@keyframes uiSpin { to { transform: rotate(360deg); } }
.ui-toast {
  position: fixed;
  left: 50%;
  top: calc(14px + env(safe-area-inset-top, 0px));
  z-index: 960;
  transform: translate(-50%, -20px);
  opacity: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ui-ink);
  color: var(--ui-surface);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.5);
  transition: transform 0.4s var(--ui-ease), opacity 0.3s ease;
  pointer-events: none;
}
.ui-toast.is-shown { transform: translate(-50%, 0); opacity: 1; }

/* --- Натиснато състояние: отклик на допир навсякъде --- */
.acc-header, .meal-card--clickable, .bottom-nav-item, .btn, .btn-primary, .btn-secondary {
  -webkit-tap-highlight-color: transparent;
}
.acc-header:active, .meal-card--clickable:active { transform: scale(0.985); }
.acc-header, .meal-card--clickable { transition: transform var(--ds-motion-press, 120ms) var(--ui-ease); }
.btn:active, .btn-primary:active, .btn-secondary:active { transform: scale(var(--ds-press-scale, 0.97)); }

/* --- Намалено движение: уважава настройката на телефона --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Изравняване на акцентите: един тюркоазен акцент, без случайни сини/лилави --- */
.profile-header .theme-toggle-btn {
  background: var(--ui-accent-soft) !important;
  color: var(--ui-accent) !important;
  box-shadow: none !important;
  border: 1px solid var(--ui-line) !important;
}
.analysis-header {
  /* Цветът по подразбиране; оценката на здравето го заменя със своя (inline). */
  background: var(--ds-fill-grad);
}
.ios-prompt { font-family: var(--ui-font) !important; }
