/**
 * B.H. Copyright (c) 2026 Yemot HaMashiach Ltd.
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * Yemot HaMashiach Ltd. ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Yemot HaMashiach Ltd.
 *
 * Unauthorized copying of this file, via any medium, is strictly prohibited.
 */

/* פלטת ימות: פטרול ותכלת על רקע תכלת בהיר, צהוב שמש לפעולה הראשית,
   אלמוגי רק למה שדורש תשומת לב (מחיקה, לבדיקה). */
:root {
  --petrol: #0f5872;
  --teal: #1a8bad;
  --sky: #3fb2d2;
  --sky-soft: #e6f5fa;
  --bg: #f2f9fc;
  --card: #ffffff;
  --sun: #ffd23f;
  --sun-soft: #fff6d6;
  --coral: #e8664f;
  --coral-soft: #fdeeea;
  --ink: #12384a;
  --muted: #6c8b98;
  --line: #d8eaf1;
  --radius: 0.9rem;
  --shadow: 0 1px 0.15rem rgba(15, 88, 114, 0.06), 0 0.4rem 1.2rem -0.6rem rgba(15, 88, 114, 0.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { font-size: clamp(15px, calc(8px + 0.45vw), 22px); }
@media (max-width: 700px) { html { font-size: 15px; } }
body { font-family: 'Assistant', system-ui, sans-serif; background: var(--bg); color: var(--ink); min-height: 100vh; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]), select, textarea {
  width: 100%; padding: 0.55rem 0.75rem; border: 1px solid var(--line); border-radius: 0.6rem; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sky); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; line-height: 1.6; }
label { display: grid; gap: 0.3rem; font-weight: 600; font-size: 0.92rem; }
label small { font-weight: 400; color: var(--muted); }

.btn { border: 0; border-radius: 0.65rem; padding: 0.55rem 1.1rem; font-weight: 700; cursor: pointer; background: var(--sky-soft); color: var(--petrol); }
.btn.primary { background: var(--sun); color: var(--ink); box-shadow: 0 0.2rem 0.7rem -0.3rem rgba(200, 150, 0, 0.6); }
.btn.soft { background: var(--sky-soft); color: var(--teal); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { color: var(--coral); }
.btn.wide { width: 100%; padding: 0.75rem; }
.btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.link-quiet { background: none; border: 0; color: var(--teal); cursor: pointer; text-align: center; font-size: 0.88rem; }
.form-error { color: var(--coral); min-height: 1.2em; font-size: 0.9rem; }
.muted { color: var(--muted); }

/* ---------- כניסה ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(60rem 30rem at 85% -10%, #c9ecf6 0%, transparent 60%),
              radial-gradient(40rem 25rem at 0% 110%, #fff1c2 0%, transparent 60%), var(--bg);
}
.login-card { width: min(24rem, 100%); background: var(--card); border-radius: 1.2rem; padding: 2rem; display: grid; gap: 1rem; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 0.8rem; }
.brand h1 { font-size: 1.5rem; color: var(--petrol); }
.brand p { color: var(--muted); }
.brand-mark {
  width: 2.6rem; height: 2.6rem; border-radius: 0.8rem; display: grid; place-items: center;
  background: var(--teal); color: #fff; font-weight: 800; font-size: 1.4rem; font-family: Georgia, serif;
}
.brand.small .brand-mark { width: 2.1rem; height: 2.1rem; font-size: 1.1rem; }
.brand.small h1 { font-size: 1.2rem; }

/* ---------- מסגרת ---------- */
.top {
  display: flex; align-items: center; gap: 1.5rem; padding: 0.8rem 1.5rem;
  background: linear-gradient(180deg, #fff 0%, rgba(255, 255, 255, 0.85) 100%);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.tabs { display: flex; gap: 0.3rem; flex: 1; }
.tabs button { border: 0; background: none; padding: 0.5rem 1rem; border-radius: 2rem; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--petrol); color: #fff; }
.me { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); }
.tab { padding: 1.5rem; max-width: 90rem; margin: 0 auto; }

/* ---------- שלוחות ---------- */
#tab-topics { display: grid; grid-template-columns: 19rem 1fr; gap: 1.5rem; align-items: start; }
.topic-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; display: grid; gap: 0.6rem; position: sticky; top: 5rem; }
.list-head { display: flex; justify-content: space-between; align-items: center; }
.list-head h2 { font-size: 1.05rem; color: var(--petrol); }
#topics { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
#topics li { display: grid; grid-template-columns: auto 1fr; column-gap: 0.7rem; padding: 0.55rem 0.6rem; border-radius: 0.7rem; cursor: pointer; }
#topics li:hover { background: var(--bg); }
#topics li.selected { background: var(--sky-soft); }
#topics li.off { opacity: 0.55; }
#topics .digit { grid-row: span 2; }
.t-name { font-weight: 700; }
.t-meta { font-size: 0.82rem; color: var(--muted); }
.digit {
  width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; align-self: center;
  background: var(--teal); color: #fff; font-weight: 800;
}
li.selected .digit { background: var(--sun); color: var(--ink); }

.editor { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; display: grid; gap: 1.1rem; }
.ed-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; }
.ed-title { display: flex; gap: 0.6rem; align-items: center; flex: 1; min-width: 16rem; }
.ed-actions { display: flex; gap: 0.6rem; align-items: center; }
.digit-input { width: 2.8rem !important; height: 2.8rem; text-align: center; font-weight: 800; font-size: 1.3rem; background: var(--sun-soft) !important; border: 0 !important; border-radius: 50% !important; padding: 0 !important; }
.digit-input.sm { width: 2.2rem !important; height: 2.2rem; font-size: 1.05rem; background: var(--sky-soft) !important; }
.title-input { font-size: 1.5rem; font-weight: 800; color: var(--petrol); border: 0 !important; padding: 0.2rem 0.4rem !important; }
.switch { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; cursor: pointer; }
.switch input { accent-color: var(--teal); width: 1.1rem; height: 1.1rem; }
.notes { background: var(--sun-soft); border-radius: 0.8rem; padding: 0.7rem 1rem; font-size: 0.9rem; line-height: 1.6; }
.notes summary { font-weight: 700; color: #8a6400; cursor: pointer; }
.notes summary small { font-weight: 400; }
.notes textarea { margin-top: 0.5rem; background: rgba(255, 255, 255, 0.7); border-color: transparent; font-size: 0.9rem; }
.audio-row { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; color: var(--muted); font-size: 0.88rem; }
.audio-row input { width: 14rem; padding: 0.3rem 0.6rem; font-size: 0.85rem; }
details.sources { font-size: 0.88rem; }
details.sources summary { cursor: pointer; color: var(--teal); font-weight: 600; width: max-content; }
.src-row { display: flex; gap: 0.4rem; align-items: center; margin-top: 0.35rem; }
.src-row input { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.src-row a { color: var(--teal); text-decoration: none; font-weight: 700; }
details.sources .link-quiet { margin-top: 0.4rem; }
.digit.main { background: var(--petrol); font-size: 0.95rem; }
.digit.big { width: 2.8rem; height: 2.8rem; font-size: 1.2rem; }
.connect { background: var(--sky-soft); border-radius: 0.8rem; padding: 0.9rem 1rem; display: grid; gap: 0.4rem; }
.connect-head { display: flex; justify-content: space-between; align-items: center; }
.connect-head b { color: var(--petrol); }
.connect p { font-size: 0.88rem; color: var(--muted); }
.connect pre { margin: 0; background: #fff; border-radius: 0.6rem; padding: 0.7rem 0.9rem; font-size: 0.88rem; overflow-x: auto; text-align: left; }
.title-static { font-size: 1.5rem; color: var(--petrol); }
#topics li.main-row { border-bottom: 1px dashed var(--line); border-radius: 0.7rem 0.7rem 0 0; margin-bottom: 0.3rem; padding-bottom: 0.7rem; }
.hear { background: var(--bg); border-radius: 0.8rem; padding: 0.7rem 1rem; font-size: 0.9rem; color: var(--muted); line-height: 1.6; }
.hear b { color: var(--petrol); }
.items { display: grid; gap: 0.9rem; }
.item { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem; display: grid; gap: 0.6rem; }
.item-head { display: flex; gap: 0.5rem; align-items: center; }
.item-title { font-weight: 700; flex: 1; }
.dur { font-size: 0.82rem; color: var(--teal); white-space: nowrap; background: var(--sky-soft); padding: 0.15rem 0.6rem; border-radius: 1rem; }
.icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0.3rem; font-size: 0.8rem; }
.icon-btn:hover { color: var(--coral); }
.item-foot { display: flex; gap: 1rem; align-items: end; justify-content: space-between; flex-wrap: wrap; }
.item-foot label { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; color: var(--muted); }
.item-foot label input { width: 14rem; padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.slug input { max-width: 20rem; }
.empty { color: var(--muted); padding: 0.5rem; }
.empty.big { padding: 3rem; text-align: center; }

/* ---------- נותני שירות ---------- */
.toolbar { display: flex; gap: 0.8rem; margin-bottom: 1rem; align-items: center; }
.toolbar input { max-width: 24rem; }
.toolbar select { max-width: 16rem; }
.toolbar .btn { margin-inline-start: auto; }
.biz-list { display: grid; gap: 0.6rem; }
.biz {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0.9rem 1.2rem;
  display: grid; grid-template-columns: 1fr auto auto; gap: 0.3rem 1.2rem; align-items: center; cursor: pointer;
}
.biz:hover { outline: 2px solid var(--sky-soft); }
.biz.off { opacity: 0.6; }
.biz h3 { font-size: 1.05rem; color: var(--petrol); }
.biz p { color: var(--muted); font-size: 0.9rem; }
.phone { font-weight: 700; letter-spacing: 0.03em; }
.chips { display: flex; gap: 0.3rem; flex-wrap: wrap; justify-content: end; }
.chip { background: var(--sky-soft); color: var(--teal); border-radius: 1rem; padding: 0.15rem 0.65rem; font-size: 0.82rem; font-weight: 600; }
.off-tag { grid-column: 1 / -1; font-size: 0.8rem; color: var(--coral); }

dialog { border: 0; border-radius: 1.1rem; padding: 0; width: min(36rem, 94vw); box-shadow: 0 1.5rem 4rem -1rem rgba(15, 88, 114, 0.4); }
dialog::backdrop { background: rgba(15, 88, 114, 0.25); }
#biz-form { padding: 1.5rem; display: grid; gap: 0.9rem; }
#biz-form h2 { color: var(--petrol); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; align-items: end; }
fieldset { border: 1px solid var(--line); border-radius: 0.7rem; padding: 0.6rem 0.9rem; }
legend { font-weight: 600; font-size: 0.92rem; padding: 0 0.3rem; }
.checks { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; }
.check { display: flex; align-items: center; gap: 0.35rem; font-weight: 500; cursor: pointer; }
.check input { accent-color: var(--teal); }
.dialog-actions { display: flex; gap: 0.5rem; align-items: center; }
.grow { flex: 1; }

/* ---------- נתונים ---------- */
#stats { display: grid; gap: 1.2rem; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; }
#stats h2 { font-size: 1.05rem; color: var(--petrol); }
.kpi { display: flex; align-items: baseline; gap: 0.5rem; }
.kpi b { font-size: 2.6rem; color: var(--teal); }
.bars { display: grid; gap: 0.5rem; }
.bar-row { display: grid; grid-template-columns: 12rem 1fr 3rem; gap: 0.8rem; align-items: center; }
.bar { height: 0.8rem; background: var(--bg); border-radius: 1rem; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--sky); border-radius: 1rem; }
.top-items { margin: 0; padding-inline-start: 1.3rem; display: grid; gap: 0.35rem; }

body.readonly #new-topic, body.readonly #new-biz, body.readonly #import,
body.readonly #save-topic, body.readonly #delete-topic, body.readonly #add-item { display: none; }

.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); z-index: 20;
  background: var(--petrol); color: #fff; padding: 0.7rem 1.3rem; border-radius: 0.8rem; box-shadow: var(--shadow);
}
.toast.error { background: var(--coral); }

@media (max-width: 860px) {
  .top { flex-wrap: wrap; gap: 0.6rem; padding: 0.7rem 1rem; }
  .brand.small { flex: 1; }
  .tabs { order: 3; flex: 0 0 100%; overflow-x: auto; }
  .tabs button { white-space: nowrap; }
  .tab { padding: 1rem; }
  #tab-topics { grid-template-columns: 1fr; }
  .topic-list { position: static; }
  .biz { grid-template-columns: 1fr; }
  .chips { justify-content: start; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input, .toolbar select { max-width: none; }
  .grid2 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 7rem 1fr 2.5rem; }
}
