/* ==========================================================================
   DIET PLAN / BUILDER
   ========================================================================== */

.diet-builder-shell {
  display: grid;
  gap: 18px;
  margin-bottom: 28px;
  border: 1px solid rgba(123, 142, 158, 0.2);
  border-radius: 8px;
  padding: clamp(18px, 3vw, 28px);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 249, 0.96)),
    #ffffff;
  box-shadow: 0 18px 45px rgba(23, 33, 43, 0.08);
}

.diet-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.diet-mode-tabs button {
  border: 1px solid rgba(39, 116, 93, 0.14);
  border-radius: 8px;
  padding: 12px 14px;
  color: #52616e;
  background: #ffffff;
  font-weight: 900;
}

.diet-mode-tabs button.active {
  color: var(--primary-dark);
  background: #e7f1ed;
  box-shadow: inset 0 0 0 1px rgba(39, 116, 93, 0.12);
}

.diet-builder-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.diet-builder-head h3 {
  margin: 0 0 8px;
  font-size: 28px;
}

.diet-macro-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  gap: 8px;
  min-width: 360px;
}

.diet-macro-summary span {
  border: 1px solid rgba(39, 116, 93, 0.14);
  border-radius: 8px;
  padding: 10px;
  color: #52616e;
  background: rgba(239, 248, 244, 0.78);
  font-size: 13px;
}

.diet-macro-summary strong {
  display: block;
  color: var(--primary-dark);
  font-size: 20px;
}

.diet-food-form {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 18px;
}

.food-library-row-info {
  min-width: 0;
}

.food-library-row-info strong,
.food-library-row-info small,
.food-library-row-info em {
  display: block;
}

.food-library-row-actions {
  display: grid;
  grid-template-columns: 78px 86px 42px 42px;
  gap: 7px;
  align-items: center;
}

.food-row-amount,
.food-row-unit,
.active-food-row input,
.active-food-row select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #d8e1e6;
  border-radius: 7px;
  padding: 7px;
  background: #ffffff;
}

.food-add-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  background: #3f629e;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.active-food-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 76px 82px minmax(190px, 1.2fr) 38px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  border-left: 4px solid #4b9c80;
  border-radius: 7px;
  padding: 10px;
  background: #ffffff;
}

.active-food-row small {
  color: #65717d;
}

.active-food-row button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 7px;
  color: #a84b4b;
  background: #fff0f0;
  cursor: pointer;
}

.diet-food-left {
  display: grid;
  gap: 14px;
}

.food-library-panel {
  border: 1px solid rgba(123, 142, 158, 0.18);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.food-library-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.admin-page-head h2 {
  margin: 0 0 8px;
  font-size: clamp(28px, 3vw, 38px);
}

.admin-page-head p {
  margin: 0;
  color: var(--muted);
}

.foods-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 220px minmax(180px, auto);
  align-items: end;
  gap: 14px;
  margin-bottom: 30px;
  border-radius: 18px;
  padding: 28px 32px;
  background: #ffffff;
  box-shadow: 0 18px 45px rgba(22, 35, 52, 0.05);
}

.foods-toolbar input,
.foods-toolbar select {
  width: 100%;
  min-height: 52px;
  border: 1px solid #d9e2ea;
  border-radius: 8px;
  padding: 0 16px;
  color: #52616e;
  background: #ffffff;
  font-size: 16px;
}

.floating-select {
  position: relative;
}

.floating-select span {
  position: absolute;
  top: -10px;
  left: 12px;
  padding: 0 6px;
  color: #9aa6b5;
  background: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.foods-add-btn {
  justify-self: end;
  min-height: 54px;
  min-width: 240px;
  background: #3f5ea8;
  box-shadow: 0 0 0 3px rgba(63, 94, 168, 0.16);
}

.foods-table-card {
  border-radius: 18px;
  padding: 28px;
  background: #ffffff;
  box-shadow: 0 18px 45px rgba(22, 35, 52, 0.05);
  overflow: auto;
}

.foods-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  color: #52616e;
}

.foods-table th {
  padding: 20px 18px;
  color: #ffffff;
  background: #3f5ea8;
  text-align: left;
  font-weight: 900;
}

.foods-table th:first-child {
  border-top-left-radius: 0;
}

.foods-table th:last-child {
  border-top-right-radius: 0;
}

.foods-table td {
  padding: 18px;
  border-bottom: 0;
}

.foods-table tbody tr {
  transition: background 0.16s ease;
}

.foods-table tbody tr:nth-child(even) {
  background: #f5f7fb;
}

.foods-table tbody tr:hover {
  background: #edf3fb;
}

.foods-table td strong,
.foods-table td span {
  display: block;
}

.foods-table td strong {
  color: #415064;
  font-weight: 500;
}

.foods-table td span {
  margin-top: 3px;
  color: #9aa6b5;
  font-size: 13px;
}

.food-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-btn {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.athlisis-import-panel {
  margin-bottom: 18px;
}

.athlisis-import-preview {
  display: grid;
  gap: 14px;
}

.athlisis-preview-days {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.athlisis-preview-day {
  border: 1px solid rgba(65, 111, 98, 0.16);
  border-radius: 18px;
  background: #fff;
  padding: 14px;
}

.athlisis-preview-day h4 {
  margin: 0 0 10px;
  color: #17202b;
}

.athlisis-preview-meal {
  display: grid;
  gap: 6px;
  padding: 10px 0;
  border-top: 1px solid rgba(65, 111, 98, 0.12);
}

.athlisis-preview-meal strong {
  color: #416f62;
}

.athlisis-preview-meal ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.athlisis-preview-meal li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: baseline;
  color: #5f6b7a;
  font-size: 13px;
}

.athlisis-preview-meal li b {
  color: #17202b;
  font-size: 12px;
  white-space: nowrap;
}

.athlisis-preview-meal li small {
  grid-column: 1 / -1;
  color: #8a94a3;
}

.foods-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
  color: var(--muted);
  font-weight: 800;
}

.print-template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.print-template-card {
  display: grid;
  gap: 18px;
  border-radius: 18px;
  padding: 22px;
  background: #ffffff;
  box-shadow: 0 18px 45px rgba(22, 35, 52, 0.06);
}

.print-template-preview {
  border-radius: 14px;
  padding: 18px;
  background:
    radial-gradient(circle at 12% 14%, color-mix(in srgb, var(--template-secondary) 42%, transparent), transparent 24%),
    linear-gradient(135deg, color-mix(in srgb, var(--template-accent) 10%, white), #ffffff);
}

.template-paper {
  position: relative;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--template-accent) 18%, #dbe5ec);
  border-radius: 12px;
  padding: 14px;
  background: #ffffff;
}

.template-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  padding: 10px 12px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--template-accent), var(--template-secondary));
}

.template-header strong,
.template-header span {
  position: relative;
  z-index: 1;
}

.template-header span {
  font-size: 12px;
  font-weight: 900;
  opacity: 0.92;
}

.template-grid-preview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid #e4ebf0;
}

.template-grid-preview span {
  min-height: 26px;
  border-right: 1px solid #e4ebf0;
  border-bottom: 1px solid #e4ebf0;
  background: #ffffff;
}

.print-template-card.stripes .template-grid-preview span:nth-child(10n + 1),
.print-template-card.stripes .template-grid-preview span:nth-child(10n + 2),
.print-template-card.stripes .template-grid-preview span:nth-child(10n + 3),
.print-template-card.stripes .template-grid-preview span:nth-child(10n + 4),
.print-template-card.stripes .template-grid-preview span:nth-child(10n + 5) {
  background: color-mix(in srgb, var(--template-secondary) 22%, white);
}

.print-template-card.checker .template-grid-preview span:nth-child(odd) {
  background: color-mix(in srgb, var(--template-secondary) 24%, white);
}

.print-template-card.playful .template-grid-preview span:nth-child(3n) {
  background: color-mix(in srgb, var(--template-secondary) 34%, white);
}

.print-template-card.playful .template-grid-preview span:nth-child(4n) {
  background: color-mix(in srgb, var(--template-accent) 16%, white);
}

.kids-doodle {
  position: absolute;
  right: 12px;
  bottom: 8px;
  color: var(--template-accent);
  font-size: 24px;
  font-weight: 900;
  opacity: 0.45;
}

.print-template-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.print-template-form div {
  display: grid;
  gap: 7px;
}

.print-template-form label {
  color: #536173;
  font-size: 13px;
  font-weight: 900;
}

.print-template-form input,
.print-template-form select {
  min-height: 42px;
  border: 1px solid #dbe5ec;
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
}

.print-template-form button {
  grid-column: 1 / -1;
}

.food-form-stage {
  display: grid;
  min-height: 68vh;
  place-items: start center;
  padding: 42px 0;
}

.food-form-window {
  width: min(980px, 100%);
  border-radius: 18px;
  padding: 34px 40px 38px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(22, 35, 52, 0.16);
}

.food-form-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.food-form-titlebar h2 {
  margin: 0;
  color: #343d4b;
  font-size: 26px;
}

.food-entry-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px 28px;
}

.food-entry-form .field:nth-child(1),
.food-entry-form .field:nth-child(3),
.food-entry-form .field.full {
  grid-column: 1 / -1;
}

.unit-field > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.unit-field input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.unit-field span {
  display: grid;
  min-width: 58px;
  place-items: center;
  border: 1px solid #d9e2ea;
  border-left: 0;
  border-radius: 0 8px 8px 0;
  color: #415064;
  background: #eef2f6;
  font-size: 16px;
}

.form-actions-right {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.food-library-list {
  display: grid;
  gap: 8px;
  max-height: 330px;
  overflow: auto;
}

.food-library-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(123, 142, 158, 0.18);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.food-library-row label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  cursor: pointer;
}

.favorite-food-btn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  color: #99a3ad;
  background: #f3f6f7;
  font-size: 18px;
}

.favorite-food-btn.active {
  color: #ffffff;
  background: #d2a740;
}

.food-library-row:hover {
  border-color: rgba(39, 116, 93, 0.34);
  background: #f2faf6;
  transform: translateY(-1px);
}

.food-library-row small {
  display: block;
  margin-top: 4px;
  color: #6d7887;
}

.food-library-row em {
  display: block;
  margin-top: 2px;
  color: #7d8794;
  font-size: 12px;
  font-style: normal;
}

.usda-search-panel {
  display: grid;
  gap: 12px;
  margin: 10px 0 12px;
  border: 1px solid rgba(50, 109, 143, 0.18);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(145deg, #f8fbff, #f3faf6);
}

.usda-search-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.usda-search-head strong,
.usda-search-head span {
  display: block;
}

.usda-search-head span {
  margin-top: 3px;
  color: #6d7887;
  font-size: 13px;
}

.usda-results {
  display: grid;
  gap: 8px;
}

.usda-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(123, 142, 158, 0.18);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
}

.usda-result-row strong,
.usda-result-row span,
.usda-result-row small {
  display: block;
}

.usda-result-row span {
  margin-top: 3px;
  color: #6d7887;
  font-size: 13px;
}

.usda-result-row small {
  margin-top: 5px;
  color: #415064;
}

.diet-food-actions {
  display: grid;
  align-content: start;
  gap: 10px;
}

.horizontal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.danger-text {
  color: var(--danger);
}

.diet-table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid rgba(123, 142, 158, 0.22);
  border-radius: 8px;
}

.diet-plan-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: #ffffff;
}

.diet-plan-table th,
.diet-plan-table td {
  border: 1px solid rgba(123, 142, 158, 0.22);
  padding: 10px;
  vertical-align: top;
}

.diet-plan-table td {
  cursor: pointer;
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.diet-plan-table td:hover {
  background: #f0f8f5;
  box-shadow: inset 0 0 0 2px rgba(39, 116, 93, 0.18);
}

.diet-plan-table td.active {
  background: #edf6f2;
  box-shadow: inset 0 0 0 2px rgba(39, 116, 93, 0.22);
}

.diet-plan-table thead th {
  background: #f1f5f4;
  text-align: center;
}

.diet-plan-table tbody th {
  width: 130px;
  text-align: center;
  background: #fbfcfa;
}

.diet-empty-cell {
  display: grid;
  min-height: 44px;
  place-items: center;
  color: #b5c0bc;
}

.active-meal-card {
  border: 1px solid rgba(39, 116, 93, 0.16);
  border-radius: 8px;
  padding: 16px;
  background: #f4faf7;
}

.active-meal-card h3 {
  margin: 4px 0 12px;
}

.diet-meal-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(23, 33, 43, 0.55);
}

.diet-meal-modal {
  position: relative;
  width: min(1500px, 96vw);
  max-height: 88vh;
  overflow: auto;
  border-radius: 18px;
  padding: clamp(22px, 3vw, 34px);
  background: #ffffff;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.26);
}

.diet-meal-modal .modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: #5f6f7c;
  background: #f1f5f4;
  font-size: 22px;
}

.diet-template-list {
  display: grid;
  gap: 12px;
}

.diet-template-list article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(123, 142, 158, 0.18);
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
}

.diet-template-list h4 {
  margin: 0 0 4px;
  font-size: 18px;
}

.diet-food-chip {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  border-radius: 3px;
  padding: 6px 7px;
  color: #ffffff;
  font-size: 13px;
  line-height: 1.25;
}

.diet-food-chip button {
  flex: 0 0 auto;
  color: inherit;
  background: transparent;
  font-size: 16px;
  line-height: 1;
}

.diet-food-chip.blue {
  background: #3f5da8;
}

.diet-food-chip.green {
  background: #60b79a;
}

.diet-food-chip.beige,
.diet-food-chip.yellow {
  color: #17212b;
  background: #efd69a;
}

.diet-food-chip.pink,
.diet-food-chip.purple {
  background: #9b5ca7;
}

.diet-food-chip.gray {
  color: #17212b;
  background: #e8edf0;
}

.diet-food-chip.print-clean {
  display: block;
  margin-bottom: 3px;
  border-radius: 0;
  padding: 0;
  color: #17212b;
  background: transparent;
  font-size: 11px;
}

.generated-plan-card {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(123, 142, 158, 0.22);
  border-radius: 8px;
  padding: 20px;
  background: #ffffff;
  box-shadow: 0 18px 45px rgba(23, 33, 43, 0.08);
}

.generated-plan-card h3 {
  margin: 8px 0 4px;
  font-size: 24px;
}

.generated-plan-card details {
  max-width: 100%;
}

.generated-plan-card summary {
  cursor: pointer;
  color: var(--primary-dark);
  font-weight: 900;
}
