/* ── Reset & base ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Varela Round", "Segoe UI", Tahoma, sans-serif;
  background: #fef9ef;
  color: #333;
  direction: rtl;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 60px;
}

/* ── POSTER ──────────────────────────────────────────── */
#poster {
  position: relative;
  width: 1300px;
  background: linear-gradient(135deg, #fff8e8, #fff0f5, #e8f5ff);
  border: 4px solid #f0c040;
  border-radius: 24px;
  padding: 28px 24px 24px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
}

.poster-title {
  font-family: "Secular One", "Varela Round", sans-serif;
  text-align: center;
  font-size: 46px;
  margin-bottom: 18px;
  background: linear-gradient(90deg, #b845e0, #339af0, #40c057, #f0a030, #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(2px 2px 0 rgba(0,0,0,.08));
}

/* Grid: 8 columns (meal label + 7 days) */
.poster-grid {
  direction: rtl;
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  grid-template-rows: auto repeat(3, 1fr);
  gap: 5px;
}

.cell {
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  padding: 6px;
}

/* Corner (empty top-right in RTL) */
.corner { background: transparent; }

/* Day headers – rainbow */
.day-header {
  font-family: "Secular One", sans-serif;
  font-size: 20px;
  color: #fff;
  padding: 8px 0;
  text-shadow: 1px 1px 2px rgba(0,0,0,.2);
}
.day-sun { background: #ff6b6b; }
.day-mon { background: #f0a030; }
.day-tue { background: #f5d63d; color: #665a00; }
.day-wed { background: #40c057; }
.day-thu { background: #339af0; }
.day-fri { background: #7c5ce0; }
.day-sat { background: #e84393; }

/* Meal-row headers */
.meal-header {
  font-family: "Secular One", sans-serif;
  font-size: 14px;
  line-height: 1.3;
  color: #fff;
  border-radius: 14px;
  padding: 8px 4px;
  text-shadow: 1px 1px 2px rgba(0,0,0,.15);
  word-break: break-word;
}
.meal-breakfast { background: #ffa94d; }
.meal-lunch     { background: #69db7c; }
.meal-dinner    { background: #74c0fc; }

/* Food cells */
.cell.food {
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 3px;
  min-height: 160px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 5px;
  transition: transform .15s;
}
.cell.food:hover { transform: scale(1.02); }

.cell.breakfast { background: #fff3e0; }
.cell.lunch     { background: #e8f5e9; }
.cell.dinner    { background: #e3f2fd; }

/* Food line inside a cell (one of up to 3) */
.food-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px 0;
  line-height: 1.3;
  font-size: 11.5px;
}
.food-line + .food-line {
  border-top: 1px dotted rgba(0,0,0,.12);
  padding-top: 4px;
}

.food-item {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.mini-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.mini-icon svg {
  width: 36px;
  height: 36px;
}

.food-name { direction: rtl; }

.food-sep {
  margin: 0 1px;
  color: #999;
  font-weight: 400;
}

/* Empty cell dash */
.empty-cell {
  color: #ccc;
  font-size: 22px;
}

/* ── Loading overlay ─────────────────────────────────── */
#loading {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.85);
  border-radius: 24px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 10;
}
#loading p {
  font-family: "Secular One", sans-serif;
  font-size: 24px;
  margin-top: 16px;
  color: #f0a030;
}
.hidden { display: none !important; }

.spinner {
  width: 56px; height: 56px;
  border: 6px solid #f0e0c0;
  border-top-color: #f0a030;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── EDITOR ──────────────────────────────────────────── */
#editor {
  width: 1300px;
  margin-top: 36px;
  background: #fff;
  border-radius: 18px;
  padding: 24px 28px 28px;
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
}

#editor h2 {
  font-family: "Secular One", sans-serif;
  font-size: 28px;
  margin-bottom: 6px;
  color: #555;
}

.editor-hint {
  font-size: 14px;
  color: #888;
  margin-bottom: 16px;
}

#meal-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 5px;
  direction: rtl;
}

#meal-table th {
  font-family: "Secular One", sans-serif;
  font-size: 16px;
  padding: 6px 4px;
  color: #666;
}

.row-label {
  font-family: "Secular One", sans-serif;
  font-size: 15px;
  color: #fff;
  padding: 8px 6px;
  border-radius: 10px;
  text-align: center;
  vertical-align: middle;
  min-width: 70px;
}
.breakfast-label { background: #ffa94d; }
.lunch-label     { background: #69db7c; }
.dinner-label    { background: #74c0fc; }

.input-cell {
  vertical-align: top;
}

.input-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#meal-table input {
  width: 100%;
  padding: 5px 7px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-family: "Varela Round", sans-serif;
  font-size: 13px;
  text-align: center;
  direction: rtl;
  transition: border-color .2s;
}
#meal-table input:focus {
  outline: none;
  border-color: #f0a030;
  box-shadow: 0 0 0 3px rgba(240,160,48,.2);
}
#meal-table input::placeholder {
  color: #ccc;
  font-size: 11px;
}

/* Buttons */
.button-bar {
  display: flex;
  gap: 14px;
  margin-top: 20px;
  justify-content: center;
}
.button-bar button {
  font-family: "Secular One", sans-serif;
  font-size: 20px;
  padding: 12px 32px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  color: #fff;
  transition: transform .12s, box-shadow .12s;
}
.button-bar button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.button-bar button:active { transform: translateY(0); }

#btn-generate { background: linear-gradient(135deg, #f0a030, #ff6b6b); }
#btn-save     { background: linear-gradient(135deg, #40c057, #2b9348); }
#btn-print    { background: linear-gradient(135deg, #339af0, #7c5ce0); }

/* ── PRINT ───────────────────────────────────────────── */
@media print {
  body { padding: 0; background: #fff; }
  #editor { display: none !important; }
  #poster {
    width: 100%;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 12px;
    break-inside: avoid;
  }
  .poster-title { font-size: 32px; }
  @page { size: landscape; margin: 0.5cm; }
}
