/* ============================================================================
   GymDiet Master — Premium Diary Entry Cards
   Scoped to #screen-diary. Blue/cyan/purple neon dark theme.
   ============================================================================ */

/* ── Summary bar ─────────────────────────────────────────────────────────── */
#screen-diary .diary-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

#screen-diary .summary-item {
  text-align: center;
  background: linear-gradient(160deg, rgba(30,30,30,0.82), rgba(15,15,15,0.82));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 12px 6px;
  box-shadow: 0 8px 22px rgba(2,6,23,0.38), inset 0 1px 0 rgba(255,255,255,0.04);
}

#screen-diary .sum-val {
  display: block;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, #00f076, #00ba5b);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#screen-diary .sum-lbl {
  font-size: 10px;
  color: rgba(255,255,255,0.40);
  font-weight: 600;
  margin-top: 3px;
  display: block;
}

/* ── Entries container ───────────────────────────────────────────────────── */
#screen-diary .diary-entries {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

/* ── Base card ───────────────────────────────────────────────────────────── */
#screen-diary .diary-entry {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(30,30,30,0.80) 0%, rgba(15,15,15,0.80) 100%);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 16px 40px rgba(2,6,23,0.50), 0 0 0 1px rgba(255,255,255,0.02), inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  transform: translateY(14px);
  animation: dcCardIn 0.55s cubic-bezier(0.2,0,0,1) forwards;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
  margin-bottom: 0; /* override .card */
}

@keyframes dcCardIn {
  to { opacity: 1; transform: none; }
}

#screen-diary .diary-entry:hover {
  transform: translateY(-3px);
  border-color: rgba(255,255,255,0.16);
  box-shadow: 0 22px 52px rgba(2,6,23,0.55), 0 0 32px rgba(255,255,255,0.04), inset 0 1px 0 rgba(255,255,255,0.06);
}

/* ── Main top row ────────────────────────────────────────────────────────── */
#screen-diary .dc-main {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 14px;
  padding: 14px 14px 12px;
}

/* ── Media (photo / emoji) ───────────────────────────────────────────────── */
#screen-diary .entry-media {
  position: relative;
  width: 90px;
  height: 90px;
  min-height: 90px;
  border-radius: 18px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 0 22px rgba(255,255,255,0.04), 0 8px 22px rgba(2,6,23,0.42);
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.04), rgba(15,15,15,0.86) 70%);
}

#screen-diary .entry-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 1;
}

/* Skeleton shimmer behind image while it loads */
#screen-diary .entry-media::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(30,30,30,0.55) 25%, rgba(45,45,45,0.38) 50%, rgba(30,30,30,0.55) 75%);
  background-size: 200% 100%;
  animation: dcShimmer 1.4s linear infinite;
  pointer-events: none;
  z-index: 0;
}

#screen-diary .entry-media-placeholder {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px;
}

#screen-diary .entry-media-emoji {
  font-size: 36px;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6));
  display: block;
}

#screen-diary .entry-media-caption {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,0.40);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* ── Info column ─────────────────────────────────────────────────────────── */
#screen-diary .dc-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Top row: name + time */
#screen-diary .dc-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding-right: 32px; /* clearance for delete btn */
}

#screen-diary .entry-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: #fff;
  flex: 1;
  min-width: 0;
}

#screen-diary .dc-time-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.40);
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 3px 7px;
  white-space: nowrap;
}

/* Portion */
#screen-diary .entry-portion {
  font-size: 11.5px;
  color: rgba(255,255,255,0.40);
  font-weight: 600;
}

/* Calories row */
#screen-diary .dc-cal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 2px;
}

#screen-diary .dc-cal-block {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

#screen-diary .dc-cal-num {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(90deg, #00f076, #00ba5b);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#screen-diary .dc-cal-unit {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.40);
}

/* ── Error button ────────────────────────────────────────────────────────── */
#screen-diary .dc-error-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 10px;
  border: 1px solid rgba(251,99,64,0.38);
  background: rgba(251,99,64,0.10);
  color: #fdaa89;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  box-shadow: 0 0 12px rgba(251,99,64,0.10);
  transition: background 0.14s, box-shadow 0.14s, transform 0.1s;
  flex-shrink: 0;
}

#screen-diary .dc-error-btn:hover {
  background: rgba(251,99,64,0.22);
  box-shadow: 0 0 20px rgba(251,99,64,0.22);
  transform: translateY(-1px);
}

/* ── Divider ─────────────────────────────────────────────────────────────── */
#screen-diary .dc-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  margin: 0 14px;
}

/* ── Macro pills ─────────────────────────────────────────────────────────── */
#screen-diary .dc-macros {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  padding: 10px 14px;
}

#screen-diary .dc-macro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 6px;
  border-radius: 13px;
  border: 1px solid transparent;
  text-align: center;
}

#screen-diary .dc-macro-lbl {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#screen-diary .dc-macro-val {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1;
}

/* Protein – blue */
#screen-diary .dc-macro-p {
  background: rgba(93,165,253,0.10);
  border-color: rgba(93,165,253,0.22);
}
#screen-diary .dc-macro-p .dc-macro-lbl { color: rgba(147,197,253,0.75); }
#screen-diary .dc-macro-p .dc-macro-val { color: #93c5fd; }

/* Fat – orange/amber */
#screen-diary .dc-macro-f {
  background: rgba(251,146,60,0.10);
  border-color: rgba(251,146,60,0.22);
}
#screen-diary .dc-macro-f .dc-macro-lbl { color: rgba(252,211,77,0.75); }
#screen-diary .dc-macro-f .dc-macro-val { color: #fcd34d; }

/* Carbs – purple */
#screen-diary .dc-macro-c {
  background: rgba(167,139,250,0.10);
  border-color: rgba(167,139,250,0.22);
}
#screen-diary .dc-macro-c .dc-macro-lbl { color: rgba(167,139,250,0.75); }
#screen-diary .dc-macro-c .dc-macro-val { color: #a78bfa; }

/* ── Health bar ──────────────────────────────────────────────────────────── */
#screen-diary .dc-health {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 13px;
}

#screen-diary .dc-health-lbl {
  font-size: 10.5px;
  font-weight: 700;
  color: rgba(255,255,255,0.36);
  white-space: nowrap;
  min-width: 36px;
}

#screen-diary .dc-health-bar-wrap {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  overflow: hidden;
}

#screen-diary .dc-health-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.55s cubic-bezier(0.2,0,0,1);
}

#screen-diary .dc-health-score {
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  min-width: 30px;
  text-align: right;
}

/* ── Delete button ───────────────────────────────────────────────────────── */
#screen-diary .entry-delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 0;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.32);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s, color 0.14s;
  z-index: 2;
}

#screen-diary .entry-delete-btn:hover {
  background: rgba(248,113,113,0.18);
  color: #f87171;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
#screen-diary .diary-entry-empty {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 20px 18px;
}

#screen-diary .entry-empty-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

#screen-diary .entry-empty-copy {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#screen-diary .diary-entry-empty .entry-name {
  font-size: 16px;
  font-weight: 700;
  -webkit-line-clamp: 1;
  color: rgba(255,255,255,0.80);
}

#screen-diary .diary-entry-empty .entry-macros {
  font-size: 12.5px;
  color: rgba(255,255,255,0.40);
}

/* ── Skeleton shimmer ────────────────────────────────────────────────────── */
@keyframes dcShimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

#screen-diary .dc-skeleton-card {
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
  padding: 14px;
  display: flex;
  gap: 14px;
  background: linear-gradient(160deg, rgba(30,30,30,0.70), rgba(15,15,15,0.70));
}

#screen-diary .dc-skel {
  background: linear-gradient(90deg, rgba(30,30,30,0.6) 25%, rgba(50,50,50,0.40) 50%, rgba(30,30,30,0.6) 75%);
  background-size: 800px 100%;
  animation: dcShimmer 1.4s linear infinite;
  border-radius: 10px;
}

#screen-diary .dc-skel-thumb {
  width: 90px;
  height: 90px;
  flex-shrink: 0;
  border-radius: 18px;
}

#screen-diary .dc-skel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* ── Diary correction modal (bottom sheet) ───────────────────────────────── */
.dc-corr-overlay[hidden] { display: none !important; }

.dc-corr-overlay {
  position: fixed;
  inset: 0;
  z-index: 700;
  background: rgba(3,8,22,0.80);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s cubic-bezier(0.2,0,0,1);
}

.dc-corr-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.dc-corr-sheet {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(30,30,30,0.98), rgba(15,15,15,0.98));
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px 24px 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom,0));
  box-shadow: 0 -20px 60px rgba(0,0,0,0.65), 0 0 0 1px rgba(255,255,255,0.04);
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.34,1.56,0.64,1);
  overflow-y: auto;
  max-height: 90vh;
}

.dc-corr-sheet.is-open { transform: translateY(0); }

.dc-corr-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.18);
  margin: 0 auto 16px;
}

.dc-corr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.dc-corr-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.dc-corr-close {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.55);
  transition: background 0.14s;
}

.dc-corr-close:hover { background: rgba(255,255,255,0.16); }

.dc-corr-body { display: flex; flex-direction: column; }

.dc-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.dc-field-lbl {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.42);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dc-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dc-field-inp {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.03);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.dc-field-inp:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.dc-field-unit {
  font-size: 13px;
  color: rgba(255,255,255,0.40);
  font-weight: 600;
  flex: none;
  min-width: 28px;
}

.dc-corr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}

.dc-corr-grid .dc-field { margin-bottom: 0; }

.dc-corr-save {
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  margin-top: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #04111f;
  background: var(--gd-brand-gradient);
  box-shadow: 0 14px 30px rgba(0, 240, 118, 0.28), inset 0 1px 0 rgba(255,255,255,0.4);
  transition: transform 0.14s, box-shadow 0.14s;
}

.dc-corr-save:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 38px rgba(0, 240, 118, 0.36), inset 0 1px 0 rgba(255,255,255,0.4);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 380px) {
  #screen-diary .dc-main {
    grid-template-columns: 76px 1fr;
    gap: 11px;
    padding: 12px 12px 10px;
  }
  #screen-diary .entry-media {
    width: 76px;
    height: 76px;
    min-height: 76px;
  }
  #screen-diary .dc-cal-num { font-size: 22px; }
  #screen-diary .entry-name { font-size: 14px; }
  #screen-diary .dc-macros { padding: 9px 12px; gap: 5px; }
  #screen-diary .dc-macro { padding: 7px 4px; }
  #screen-diary .dc-macro-val { font-size: 12px; }
  #screen-diary .diary-summary { gap: 6px; }
  #screen-diary .sum-val { font-size: 15px; }
  .dc-corr-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  #screen-diary .diary-entry { animation-duration: 0.01ms; }
  #screen-diary .dc-health-bar { transition: none; }
}
