/* ============================================================
   Daily Intake Tracker — enterprise-grade CSS
   Clean, modern, functional. Status: low/ok/high color system.
   Inspired by Cronometer (rings + categories), MyFitnessPal (log),
   Apple Health (status colors).
   ============================================================ */

/* ── Design tokens ── */
:root {
  --di-color-energy:  #f59e0b;
  --di-color-protein: #3b82f6;
  --di-color-carbs:   #10b981;
  --di-color-fat:     #f97316;

  --di-status-low:    #ef4444;
  --di-status-ok:     #22c55e;
  --di-status-high:   #f59e0b;
  --di-status-none:   #cbd5e1;

  --di-surface:       #ffffff;
  --di-bg:            #f8fafc;
  --di-border:        #e2e8f0;
  --di-text:          #0f172a;
  --di-text-sub:      #64748b;
  --di-text-muted:    #94a3b8;
  --di-accent:        #1e3a5f;
}

/* ── Backdrop ── */
.di-backdrop {
  position: fixed;
  top: var(--lpo-navbar-height, 103px);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 20px 16px 40px;
  background:
    radial-gradient(circle at 12% 8%, rgba(94, 137, 74, 0.18), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(216, 154, 69, 0.14), transparent 30%),
    rgba(15, 23, 42, 0.70);
  backdrop-filter: blur(10px);
}

/* ── Modal shell ── */
.di-modal {
  width: min(1040px, 100%);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--di-surface);
  border-radius: 24px;
  box-shadow: 0 32px 80px rgba(15, 23, 42, 0.30), 0 0 0 1px rgba(0,0,0,0.05);
  animation: di-enter 0.26s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes di-enter {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

/* ── Header ── */
.di-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 18px;
  background: linear-gradient(135deg, #1e3a5f 0%, #1a4a7a 60%, #163d6e 100%);
  flex-shrink: 0;
}

.di-eyebrow {
  margin: 0 0 2px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.65);
}

.di-heading {
  margin: 0 0 2px;
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.di-date {
  margin: 0;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.55);
}

.di-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.di-btn-reset {
  padding: 6px 14px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 20px;
  color: rgba(255,255,255,0.88);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease;
}

.di-btn-reset:hover {
  background: rgba(255,255,255,0.22);
}

.di-btn-close {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 50%;
  color: #fff;
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.18s ease;
}

.di-btn-close:hover { background: rgba(255,255,255,0.24); }
.di-btn-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ── Body ── */
.di-body {
  flex: 1;
  padding: 20px 28px 24px;
  background: var(--di-bg);
}

/* ── Panels ── */
.di-panel {
  background: var(--di-surface);
  border: 1px solid var(--di-border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 14px;
}

.di-panel:last-of-type { margin-bottom: 0; }

.di-panel-title {
  margin: 0 0 14px;
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--di-text-sub);
  display: flex;
  align-items: center;
  gap: 8px;
}

.di-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--di-accent);
  color: #fff;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
}

/* ── Empty state ── */
.di-empty {
  color: var(--di-text-sub);
  font-size: 0.88rem;
  line-height: 1.6;
  margin: 0;
  text-align: center;
  padding: 16px 0;
}

.di-preview-panel {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.di-preview-title {
  margin: 0 0 6px;
  color: var(--di-text);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.35;
}

.di-preview-copy {
  margin: 0;
  color: var(--di-text-sub);
  font-size: 0.88rem;
  line-height: 1.55;
}

/* ── Daily Log ── */
.di-log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.di-log-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--di-bg);
  border: 1px solid var(--di-border);
  border-radius: 10px;
  transition: border-color 0.18s ease;
}

.di-log-row:hover { border-color: #94a3b8; }

.di-log-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.di-log-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--di-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.di-log-qty {
  font-size: 0.75rem;
  color: var(--di-text-muted);
}

.di-log-macros {
  display: flex;
  gap: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--di-text-sub);
  white-space: nowrap;
}

.di-log-remove {
  width: 28px;
  height: 28px;
  background: none;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--di-text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.di-log-remove:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #ef4444;
}

/* ── Macro rings ── */
.di-rings {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 4px 0;
}

.di-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 96px;
}

.di-ring-wrap {
  position: relative;
  width: 72px;
  height: 72px;
}

.di-ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.di-ring-track {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 6;
}

.di-ring-fill {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dasharray 0.6s ease;
}

.di-ring-fill--energy { stroke: var(--di-color-energy); }
.di-ring-fill--protein { stroke: var(--di-color-protein); }
.di-ring-fill--carbs { stroke: var(--di-color-carbs); }
.di-ring-fill--fat { stroke: var(--di-color-fat); }

.di-ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  pointer-events: none;
}

.di-ring-val {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--di-text);
}

.di-ring-unit {
  font-size: 0.62rem;
  color: var(--di-text-muted);
}

.di-ring-name {
  margin: 2px 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--di-text);
  text-align: center;
}

.di-ring-rda {
  margin: 0;
  font-size: 0.68rem;
  color: var(--di-text-muted);
  text-align: center;
}

/* ── Nutrient table ── */
.di-nt {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.di-nt-head {
  display: grid;
  grid-template-columns: 160px 1fr 80px 60px 50px;
  gap: 8px;
  padding: 0 6px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--di-text-muted);
  border-bottom: 1px solid var(--di-border);
}

.di-nt-col-bar { /* empty placeholder column header */ }

.di-nr {
  display: grid;
  grid-template-columns: 160px 1fr 80px 60px 50px;
  gap: 8px;
  align-items: center;
  padding: 6px 6px;
  border-radius: 6px;
  transition: background 0.14s ease;
}

.di-nr:hover { background: var(--di-bg); }

.di-nr-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--di-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.di-nr-bar-track {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.di-nr-progress {
  width: 100%;
  height: 100%;
  appearance: none;
  border: 0;
  border-radius: 3px;
  overflow: hidden;
}

.di-nr-progress::-webkit-progress-bar {
  background: #e2e8f0;
}

.di-nr-progress::-webkit-progress-value {
  border-radius: 3px;
}

.di-nr-progress::-moz-progress-bar {
  border-radius: 3px;
}

.di-nr-progress--low::-webkit-progress-value { background: var(--di-status-low); }
.di-nr-progress--ok::-webkit-progress-value { background: var(--di-status-ok); }
.di-nr-progress--high::-webkit-progress-value { background: var(--di-status-high); }
.di-nr-progress--none::-webkit-progress-value { background: var(--di-status-none); }
.di-nr-progress--low::-moz-progress-bar { background: var(--di-status-low); }
.di-nr-progress--ok::-moz-progress-bar { background: var(--di-status-ok); }
.di-nr-progress--high::-moz-progress-bar { background: var(--di-status-high); }
.di-nr-progress--none::-moz-progress-bar { background: var(--di-status-none); }

.di-nr-intake {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--di-text);
  text-align: right;
  white-space: nowrap;
}

.di-nr-rda {
  font-size: 0.75rem;
  color: var(--di-text-muted);
  white-space: nowrap;
}

.di-pct--low  { color: var(--di-status-low); }
.di-pct--ok   { color: var(--di-status-ok); }
.di-pct--high { color: var(--di-status-high); }
.di-pct--none { color: var(--di-text-muted); }

.di-nr-pct {
  font-size: 0.75rem;
  font-weight: 700;
  text-align: right;
}

/* ── Legend ── */
.di-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--di-text-muted);
  padding: 12px 4px 0;
}

.di-legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.di-legend-dot--low  { background: var(--di-status-low); }
.di-legend-dot--ok   { background: var(--di-status-ok); }
.di-legend-dot--high { background: var(--di-status-high); }

/* ── Footer ── */
.di-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 28px;
  background: var(--di-surface);
  border-top: 1px solid var(--di-border);
  flex-shrink: 0;
}

.di-btn-primary {
  padding: 9px 22px;
  background: var(--di-accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.14s ease;
}

.di-btn-primary:hover {
  background: #163d6e;
  transform: translateY(-1px);
}

.di-btn-secondary {
  padding: 9px 18px;
  background: transparent;
  color: var(--di-text-sub);
  border: 1px solid var(--di-border);
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.di-btn-secondary:hover {
  background: var(--di-bg);
  border-color: #94a3b8;
}

/* ── Responsive ── */
@media (max-width: 720px) {
  .di-backdrop { padding: 12px 8px 24px; }

  .di-modal {
    border-radius: 18px;
    width: 100%;
  }

  .di-header { padding: 18px 18px 14px; }
  .di-body { padding: 14px 14px 18px; }
  .di-footer { padding: 14px 18px; }

  .di-rings { gap: 10px; }
  .di-ring { width: 80px; }
  .di-ring-wrap { width: 60px; height: 60px; }

  .di-nt-head,
  .di-nr {
    grid-template-columns: 120px 1fr 64px 50px 40px;
    gap: 6px;
  }

  .di-nr-label { font-size: 0.76rem; }
  .di-nr-intake { font-size: 0.72rem; }

  .di-log-macros { display: none; }

  .di-btn-reset {
    display: none; /* Hidden on small screens — use header action instead */
  }
}

@media (max-width: 480px) {
  .di-nt-head,
  .di-nr {
    grid-template-columns: 100px 1fr 56px 0 36px;
  }

  .di-nr-rda { display: none; }
}
