/* בית ראש פינה — RTL-first, phone-first.
   Written for dir="rtl" from the start: every inset uses logical properties
   (inline-start / inline-end), so nothing here is a mirrored LTR layout. */

:root {
  --bg:        #f6f4ef;   /* warm paper, like the house */
  --card:      #ffffff;
  --ink:       #22201c;
  --muted:     #7d7669;
  --line:      #e4dfd4;
  --green:     #2f6b4f;   /* Galilee green */
  --green-ink: #ffffff;
  --red:       #b23a2c;
  --amber:     #b7791f;
  --radius:    14px;
  --shadow:    0 1px 3px rgba(34,32,28,.08), 0 6px 18px rgba(34,32,28,.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding-bottom: 6rem;          /* room for the floating button */
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Hebrew",
        Arial, sans-serif;
}

/* --- top bar -------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .8rem 1rem; padding-top: max(.8rem, env(safe-area-inset-top));
  background: var(--green); color: var(--green-ink);
  box-shadow: var(--shadow);
}
.topbar-title { color: inherit; text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.topbar-user {
  color: inherit; text-decoration: none; font-size: .85rem;
  background: rgba(255,255,255,.18); padding: .2rem .6rem; border-radius: 999px;
}

.content { max-width: 720px; margin: 0 auto; padding: 1rem; }

/* --- cards ---------------------------------------------------------------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem; margin-bottom: 1rem;
}
.card h1 { font-size: 1.3rem; margin: 0 0 .25rem; }
.card h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.gate { max-width: 24rem; margin: 2.5rem auto; text-align: center; }
.muted { color: var(--muted); font-size: .85rem; }
.hint { margin: .5rem 0 0; }
.or-line { margin: .9rem 0 .3rem; }
.back { display: inline-block; margin-bottom: .75rem; color: var(--green);
        text-decoration: none; font-size: .9rem; }

/* --- forms ---------------------------------------------------------------- */
.label { display: block; font-size: .85rem; color: var(--muted); margin: .9rem 0 .3rem; }
.field {
  width: 100%; padding: .7rem .8rem; margin-bottom: .3rem;
  font: inherit; color: inherit;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
}
.field:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: var(--green); }
textarea.field { resize: vertical; }
.filebtn { display: block; margin-bottom: .3rem; cursor: pointer; }
.filebtn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.filebtn-face {
  display: block; padding: .8rem; text-align: center; font-weight: 600;
  color: var(--green); background: #f2f7f4;
  border: 1px dashed var(--green); border-radius: 10px;
}
.filebtn input:focus-visible + .filebtn-face { outline: 2px solid var(--green); outline-offset: 2px; }

.btn {
  display: inline-block; padding: .75rem 1.1rem; border: 0; border-radius: 10px;
  font: inherit; font-weight: 600; cursor: pointer; text-align: center; text-decoration: none;
}
.btn-primary { background: var(--green); color: var(--green-ink); }
.btn-ghost   { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-block   { display: block; width: 100%; margin-top: .6rem; }

.switch { display: flex; align-items: center; gap: .55rem; margin: 1rem 0 .2rem; }
.switch input { width: 1.25rem; height: 1.25rem; accent-color: var(--red); }

/* --- chips (rooms) -------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  padding: .45rem .8rem; border-radius: 999px; font: inherit; font-size: .92rem;
  background: #fff; color: var(--ink); border: 1px solid var(--line); cursor: pointer;
}
/* The radio is visually hidden and the <span> next to it is the button. Styling
   the sibling (input:checked + span) rather than the label via :has() keeps this
   working on older phone browsers, where :has() silently does nothing and the
   selected room would show no highlight at all. */
.chip-radio { padding: 0; border: 0; background: none; }
.chip-radio input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.chip-radio span {
  display: block; padding: .45rem .8rem; border-radius: 999px;
  background: #fff; border: 1px solid var(--line);
}
.chip-radio input:checked + span {
  background: var(--green); color: var(--green-ink); border-color: var(--green);
}
.chip-radio input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }

/* --- filters -------------------------------------------------------------- */
.filters { margin-bottom: .9rem; }
.filter-row { display: flex; gap: .4rem; margin-bottom: .5rem; align-items: center; }
.scroll-x { overflow-x: auto; padding-bottom: .2rem; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; text-align: center; padding: .5rem .3rem; border-radius: 10px;
  background: #fff; border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: .9rem;
}
.tab-on { background: var(--green); color: var(--green-ink); border-color: var(--green); }
.chip-sm {
  flex: 0 0 auto; padding: .3rem .7rem; border-radius: 999px; font-size: .85rem;
  background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
.chip-on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* --- fault list ----------------------------------------------------------- */
.fault-list { list-style: none; margin: 0; padding: 0; }
.fault-list li { margin-bottom: .6rem; }
.fault-card {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .8rem; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); color: inherit; text-decoration: none;
}
.fault-card.is-done { opacity: .55; }
.thumb {
  flex: 0 0 auto; width: 62px; height: 62px; object-fit: cover; border-radius: 10px;
  background: var(--line);
}
.fault-body { min-width: 0; }
.fault-title { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.fault-title.big { font-size: 1.15rem; }
.fault-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .4rem; }
.pill { font-size: .78rem; padding: .12rem .55rem; border-radius: 999px;
        background: #efece4; color: var(--muted); }
.urgent {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  padding: .1rem .45rem; border-radius: 5px; margin-inline-end: .35rem;
  background: var(--red); color: #fff; vertical-align: .1em;
}
.status { font-size: .78rem; font-weight: 600; }
.status-open        { color: var(--red); }
.status-in_progress { color: var(--amber); }
.status-done        { color: var(--green); }

.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty-emoji { font-size: 2.2rem; }

/* --- detail --------------------------------------------------------------- */
.notes { white-space: pre-wrap; margin: .8rem 0 0; }
.gallery { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.gallery img { width: 104px; height: 104px; object-fit: cover; border-radius: 10px; }
.status-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.status-actions form { flex: 1 1 auto; }
.status-actions .btn { width: 100%; }

.timeline { list-style: none; margin: 0 0 1rem; padding: 0;
            border-inline-start: 2px solid var(--line); padding-inline-start: .9rem; }
.ev { margin-bottom: .8rem; }
.ev-head { display: flex; gap: .5rem; align-items: baseline; font-size: .85rem; }
.ev-text { white-space: pre-wrap; overflow-wrap: anywhere; }

details.card summary { cursor: pointer; color: var(--muted); font-size: .9rem; }

/* --- the one big button --------------------------------------------------- */
.fab {
  position: fixed; inset-inline: 1rem; bottom: max(1rem, env(safe-area-inset-bottom));
  max-width: 690px; margin: 0 auto;
  padding: .95rem 1rem; text-align: center; text-decoration: none;
  background: var(--green); color: var(--green-ink); font-weight: 700;
  border-radius: 999px; box-shadow: 0 6px 20px rgba(47,107,79,.35);
}

.flashes { max-width: 720px; margin: .75rem auto 0; padding: 0 1rem; }
.flash {
  background: #fdf1ef; border: 1px solid #f0c9c2; color: var(--red);
  padding: .6rem .8rem; border-radius: 10px; font-size: .9rem;
}
