/* FMB Al Saadah menu calendar: navy and gold, after the HQHB calendar. */
:root {
  --navy-950: #061528;
  --navy-900: #0b2340;
  --navy-800: #12345a;
  --navy-700: #1c4670;
  --gold: #d6aa3a;
  --gold-deep: #b5861c;
  --gold-soft: #f6e6b5;
  --cream: #fffaea;
  --ink: #1b2333;
  --muted: #687385;
  --line: #ece5d3;
  --card: #ffffff;
  --page: #f7f3e8;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(3, 14, 30, .28);

  --mon: #2e7d32; --tue: #e2570e; --wed: #6d28a8; --thu: #1748a5;
  --fri: #d61f69; --sat: #00838f; --sun: #64748b;

  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='88' viewBox='0 0 88 88'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.055' stroke-width='1.2'%3E%3Cpath d='M44 10 53 35 78 44 53 53 44 78 35 53 10 44 35 35Z'/%3E%3Crect x='25' y='25' width='38' height='38'/%3E%3Crect x='25' y='25' width='38' height='38' transform='rotate(45 44 44)'/%3E%3Ccircle cx='0' cy='0' r='15'/%3E%3Ccircle cx='88' cy='0' r='15'/%3E%3Ccircle cx='0' cy='88' r='15'/%3E%3Ccircle cx='88' cy='88' r='15'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--navy-900) var(--pattern);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.ar { font-family: 'Amiri', serif; direction: rtl; unicode-bidi: isolate; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px clamp(16px, 4vw, 40px);
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--navy-950) var(--pattern);
  border-bottom: 2px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand-logo { width: 44px; height: 44px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(214, 170, 58, .5); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text b { color: var(--gold); font-size: clamp(18px, 2.4vw, 24px); font-weight: 800; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { color: #fff; font-weight: 600; font-size: 13px; opacity: .9; }
.top-admin {
  display: none; text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 8px 14px; border-radius: 999px; color: var(--navy-950);
  background: linear-gradient(180deg, #e9c25a, var(--gold-deep));
}

.banner {
  margin: 0; padding: 10px clamp(16px, 4vw, 40px);
  background: linear-gradient(90deg, var(--gold-soft), #fff4d1);
  color: #5a420b; font-weight: 500; font-size: 14px; text-align: center;
}

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: calc(100vh - 66px); }
.sidebar {
  background: rgba(6, 21, 40, .55);
  border-right: 3px solid var(--gold);
  padding: 18px 18px 32px;
  color: #fff;
  display: flex; flex-direction: column; gap: 22px;
}
.main { padding: clamp(16px, 2.4vw, 30px); display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.loading { color: #fff; opacity: .8; padding: 40px; text-align: center; }

.side-today { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.side-today small { display: block; color: var(--gold); font-weight: 500; font-size: 13px; }
.side-title { margin: 0 0 10px; color: var(--gold); font-size: 13px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; }

.btn-gold, .btn-ghost, .btn-plain {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 12px; padding: 11px 16px; font-weight: 600; font-size: 15px;
  border: 1px solid transparent; text-decoration: none; transition: transform .12s ease, box-shadow .12s ease;
}
.btn-gold { color: #fff; background: linear-gradient(180deg, #e3b94a, var(--gold-deep)); box-shadow: 0 4px 12px rgba(181, 134, 28, .35); }
.btn-gold:hover { transform: translateY(-1px); }
.btn-ghost { color: #fff; background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .18); }
.btn-ghost:hover { background: rgba(255, 255, 255, .14); }
.btn-ghost.active { background: linear-gradient(180deg, #e3b94a, var(--gold-deep)); border-color: transparent; }
.btn-plain { color: var(--ink); background: #fff; border-color: var(--line); }
.btn-plain:hover { border-color: var(--gold); }
.btn-block { width: 100%; justify-content: flex-start; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.side-card { background: #fff; color: var(--ink); border-radius: 14px; padding: 14px 16px; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.side-card h3 { margin: 0 0 2px; font-size: 15px; }
.side-card .meta { color: var(--muted); font-size: 12.5px; }
.side-card ul { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.side-card li { display: flex; gap: 8px; align-items: baseline; font-size: 14.5px; font-weight: 500; }
.side-card li::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent, var(--gold)); flex: none; transform: translateY(-1px); }
.side-week { display: grid; gap: 8px; }
.side-day {
  display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center;
  width: 100%; text-align: left; background: #fff; color: var(--ink); border: 0; border-radius: 12px; padding: 8px 10px;
}
.side-day .chip {
  display: grid; place-items: center; border-radius: 10px; padding: 5px 0; color: #fff; line-height: 1.05;
  background: linear-gradient(180deg, #e3b94a, var(--gold-deep)); font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.side-day .chip b { font-size: 18px; }
.side-day .what { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-day .what small { display: block; color: var(--muted); font-weight: 500; font-size: 11.5px; }
.side-day.is-today { box-shadow: inset 0 0 0 2px var(--gold); background: var(--cream); }

/* ---------- calendar header ---------- */
.card { background: var(--card); border-radius: 22px; box-shadow: var(--shadow); }
.cal-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 16px 22px; }
.cal-title { text-align: center; }
.cal-title h1 { margin: 0; font-size: clamp(22px, 3vw, 30px); font-weight: 700; letter-spacing: .3px; }
.cal-title .ar { color: var(--gold-deep); font-size: clamp(17px, 2vw, 22px); line-height: 1.3; }
.cal-title .hijri-en { color: var(--muted); font-size: 13px; }
.round {
  width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid var(--gold);
  background: #fff; color: var(--gold-deep); font-size: 20px; font-weight: 700; display: grid; place-items: center;
}
.round:hover { background: var(--cream); }
.cal-actions { display: flex; align-items: center; gap: 10px; }
.pill-gold {
  border: 0; border-radius: 999px; padding: 10px 20px; font-weight: 600; color: #fff;
  background: linear-gradient(180deg, #e3b94a, var(--gold-deep)); box-shadow: 0 4px 12px rgba(181, 134, 28, .35);
}
.seg { display: none; background: #f2ecdc; border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 8px 16px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }

/* ---------- month grid ---------- */
.month { padding: 14px; overflow: hidden; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.dow {
  padding: 12px 6px; text-align: center; font-weight: 600; font-size: 13.5px; letter-spacing: .6px;
  background: #fbf8f0; border-bottom: 1px solid var(--line); color: #3b4252;
}
.dow:not(:nth-child(7n)) { border-right: 1px solid var(--line); }
.dow.fri { color: #1f8a4c; background: #eef8f0; }
.cell {
  color: var(--ink);
  position: relative; min-height: 118px; padding: 8px 8px 10px; background: #fff; border: 0; text-align: left;
  border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.cell:not(:nth-child(7n)) { border-right: 1px solid var(--line); }
.cell:hover { background: #fffdf6; }
.cell.out { background: #faf8f3; }
.cell.out .num, .cell.out .hd { opacity: .45; }
.cell.fri { background: #fbfefb; }
.cell .top { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 6px; }
.cell .num { font-weight: 700; font-size: 18px; color: #2b3240; }
.cell .hd { font-family: 'Amiri', serif; color: var(--gold-deep); font-size: 15px; font-weight: 700; }
.cell .hm { font-family: 'Amiri', serif; font-size: 11.5px; color: #fff; background: var(--gold-deep); border-radius: 999px; padding: 0 7px; line-height: 1.6; white-space: nowrap; }
.cell.today { background: var(--cream); box-shadow: inset 0 0 0 2px var(--gold); }
.cell.today .num { background: var(--gold); color: #fff; border-radius: 50%; width: 30px; height: 30px; display: grid; place-items: center; font-size: 15px; }
.dishes { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.dishes li {
  font-size: 12.5px; font-weight: 500; line-height: 1.3; padding: 3px 7px; border-radius: 7px;
  background: color-mix(in srgb, var(--accent) 9%, #fff); border-left: 3px solid var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dishes li.more { background: transparent; border: 0; color: var(--muted); padding-left: 2px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; border-radius: 8px;
  padding: 3px 8px; background: #fff7df; color: #8a650f; border: 1px solid #f0dca0; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tag.no_thali, .tag.holiday { background: #f3f4f6; color: #555f6e; border-color: #e2e5ea; }
.dots { display: none; gap: 3px; justify-content: center; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* ---------- week view (poster style) ---------- */
.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.day-card {
  background: #fff; border-radius: 20px; padding: 18px 20px 20px; box-shadow: var(--shadow);
  border-top: 6px solid var(--accent); display: flex; flex-direction: column; gap: 8px; text-align: left; border-left: 0; border-right: 0; border-bottom: 0;
}
.day-card.today { box-shadow: var(--shadow), inset 0 0 0 2px var(--gold); background: var(--cream); }
.day-card .wd { font-size: 26px; font-weight: 800; color: var(--accent); letter-spacing: -.2px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.day-card .badge-today { font-size: 11.5px; font-weight: 700; color: #fff; background: var(--gold-deep); border-radius: 999px; padding: 3px 10px; letter-spacing: .5px; text-transform: uppercase; }
.day-card .dates {
  border-radius: 12px; padding: 8px 12px; text-align: center; font-weight: 600; line-height: 1.45;
  background: color-mix(in srgb, var(--accent) 8%, #fff); color: var(--accent);
  border-bottom: 2px solid color-mix(in srgb, var(--accent) 35%, #fff);
}
.day-card .dates .g { font-size: 16.5px; }
.day-card .dates .h { font-size: 14px; }
.day-card ul { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 7px; }
.day-card li { display: flex; gap: 10px; align-items: baseline; font-size: 17px; font-weight: 500; }
.day-card li::before { content: ''; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); flex: none; transform: translateY(-1px); }
.day-card .empty { color: var(--muted); font-size: 14px; font-style: italic; margin-top: 6px; }
.day-card .note { font-size: 13.5px; color: #6b5414; background: #fff7df; border-radius: 10px; padding: 7px 10px; }
.week-tools { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.week-foot { text-align: center; color: var(--gold); font-weight: 600; letter-spacing: .4px; padding: 4px 0 8px; }

/* ---------- day sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(4, 12, 24, .55); display: grid; place-items: center; padding: 16px; }
.sheet { width: min(460px, 100%); background: #fff; border-radius: 22px; padding: 22px; box-shadow: var(--shadow); border-top: 6px solid var(--accent, var(--gold)); max-height: 90vh; overflow: auto; }
.sheet h2 { margin: 0; font-size: 24px; color: var(--accent, var(--ink)); }
.sheet .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.sheet .ar { color: var(--gold-deep); font-size: 18px; }
.sheet ul { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; }
.sheet li { display: flex; gap: 10px; align-items: baseline; font-size: 18px; font-weight: 500; }
.sheet li::before { content: ''; width: 11px; height: 11px; border-radius: 50%; background: var(--accent, var(--gold)); flex: none; }
.sheet .row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: var(--navy-950); color: #fff; border: 1px solid var(--gold); border-radius: 12px; padding: 10px 16px; font-size: 14px;
}

/* ---------- admin ---------- */
.panel { padding: clamp(16px, 2.4vw, 26px); }
.panel h2 { margin: 0 0 4px; font-size: 22px; }
.panel .lead { color: var(--muted); margin: 0 0 16px; font-size: 14.5px; }
.form { display: grid; gap: 12px; max-width: 420px; }
label.field { display: grid; gap: 6px; font-size: 13.5px; font-weight: 600; color: #3b4252; }
.field input, .field textarea, .field select, .ed-row textarea, .ed-row input, .ed-row select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; font-size: 15px;
}
.field input:focus, .field textarea:focus, .ed-row textarea:focus, .ed-row input:focus, .ed-row select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(214, 170, 58, .2); }
.err { color: #b42318; font-size: 14px; }
.muted { color: var(--muted); }
.ed-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ed-head h3 { margin: 0; font-size: 18px; }
.ed-rows { display: grid; gap: 12px; }
.ed-row {
  display: grid; grid-template-columns: 170px minmax(0, 1fr) 160px; gap: 12px; align-items: start;
  border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 14px; padding: 12px;
}
.ed-row .when b { display: block; color: var(--accent); font-size: 17px; }
.ed-row .when span { display: block; color: var(--muted); font-size: 13px; }
.ed-row textarea { min-height: 92px; resize: vertical; line-height: 1.45; }
.ed-row .side { display: grid; gap: 8px; }
.ed-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 16px; }
details.paste { margin: 0 0 14px; border: 1px dashed #d9c890; border-radius: 12px; padding: 10px 14px; background: #fffcf2; }
details.paste summary { cursor: pointer; font-weight: 600; color: #6b5414; }
details.paste textarea { width: 100%; min-height: 130px; margin-top: 10px; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px; }

/* ---------- tablet & phone ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 0; padding: 16px 16px 0; background: transparent; gap: 14px; }
  .sidebar .desktop-only { display: none; }
  .top-admin { display: inline-flex; }
  .seg { display: inline-flex; }
  .main { padding: 14px 16px 28px; }
}
@media (max-width: 700px) {
  .brand-logo { width: 38px; height: 38px; }
  .cal-head { grid-template-columns: auto 1fr auto; padding: 12px 12px; gap: 8px; border-radius: 18px; }
  .cal-head .pill-gold { display: none; }
  .cal-actions { gap: 6px; }
  .round { width: 40px; height: 40px; font-size: 18px; }
  .cal-title h1 { font-size: 20px; }
  .cal-title .ar { font-size: 16px; }
  .cal-title .hijri-en { font-size: 12px; }
  .view-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  .month { padding: 8px; border-radius: 18px; }
  .dow { padding: 8px 2px; font-size: 11px; letter-spacing: 0; }
  .cell { min-height: 62px; padding: 5px 2px 6px; gap: 4px; align-items: center; }
  .cell .top { flex-direction: column; gap: 0; }
  .cell .num { font-size: 15px; }
  .cell.today .num { width: 26px; height: 26px; font-size: 13px; }
  .cell .hd { font-size: 12px; line-height: 1.1; }
  .cell .hm { display: none; }
  .cell .dishes, .cell .tag { display: none; }
  .dots { display: flex; }
  .week { grid-template-columns: 1fr; gap: 14px; }
  .day-card .wd { font-size: 24px; }
  .ed-row { grid-template-columns: 1fr; }
  .sheet-backdrop { place-items: end center; padding: 0; }
  .sheet { border-radius: 22px 22px 0 0; padding-bottom: max(22px, env(safe-area-inset-bottom)); }
}
.view-bar { display: none; }
@media (max-width: 980px) { .view-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; } }
