/* BASIC — עיצוב הפאנל. RTL, עברית, מצב בהיר וכהה. */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #16a34a;
  --brand-dark: #15803d;
  --brand-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #0f172a;
    --border: #1f2937;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --brand-soft: #052e16;
    --danger-soft: #450a0a;
    --warn-soft: #451a03;
    --info-soft: #172554;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans Hebrew", "Rubik", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--brand-dark); }

/* ------------------------------------------------------------ פריסה */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; gap: 10px; align-items: center; margin-bottom: 22px; padding: 0 6px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #0ea5e9);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 19px;
}
.brand strong { display: block; font-size: 17px; }
.brand small { color: var(--muted); font-size: 12px; }

nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  color: var(--text); text-decoration: none; font-size: 14.5px;
}
nav a:hover { background: var(--surface-2); }
nav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
nav .ico { width: 20px; text-align: center; opacity: .8; }
.nav-sep { height: 1px; background: var(--border); margin: 10px 4px; }

.logout { border-top: 1px solid var(--border); padding-top: 12px; }
.who { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; text-align: center; }

.content { flex: 1; padding: 24px 30px 60px; min-width: 0; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 24px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------ כרטיסים */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.card > h2, .card > h3 { margin-top: 0; font-size: 17px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; font-size: 17px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); }
.stat .value { font-size: 27px; font-weight: 700; line-height: 1.2; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat.ok .value { color: var(--brand); }
.stat.danger .value { color: var(--danger); }

/* ------------------------------------------------------------ תגיות */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.badge.ok { background: var(--brand-soft); color: var(--brand-dark); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------------------ כפתורים */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 9px; border: 1px solid transparent;
  background: var(--brand); color: #fff;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------ טפסים */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.field .hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

input[type=text], input[type=password], input[type=search], input[type=email],
select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); color: var(--text);
  font-family: inherit; font-size: 14.5px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.65; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin: 0; flex: 1 1 180px; }

/* ------------------------------------------------------------ טבלאות */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: none; background: var(--surface-2); position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.ltr { direction: ltr; text-align: right; unicode-bidi: isolate; }

.empty { text-align: center; color: var(--muted); padding: 34px 12px; }
.empty .big { font-size: 34px; display: block; margin-bottom: 6px; opacity: .5; }

/* ------------------------------------------------------------ הודעות מערכת */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash { padding: 11px 15px; border-radius: 9px; border: 1px solid; font-size: 14px; }
.flash-success { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.flash-error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.flash-warning { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.flash-info, .flash-debug { background: var(--info-soft); border-color: var(--info); color: var(--info); }

/* ------------------------------------------------------------ QR */
.qr-box { text-align: center; padding: 10px; }
.qr-box img { width: 262px; height: 262px; background: #fff; padding: 10px; border-radius: 12px; border: 1px solid var(--border); }
.qr-steps { counter-reset: step; list-style: none; padding: 0; margin: 16px 0 0; text-align: right; }
.qr-steps li { counter-increment: step; padding: 5px 0 5px 0; color: var(--muted); font-size: 13.5px; }
.qr-steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 21px; height: 21px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: 12px; margin-left: 8px; }

/* ------------------------------------------------------------ בועות הודעה */
.bubble-list { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 78%; padding: 9px 13px; border-radius: 13px; font-size: 14px; }
.bubble .meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.bubble.in { background: var(--surface-2); border: 1px solid var(--border); align-self: flex-start; border-start-start-radius: 3px; }
.bubble.out { background: var(--brand-soft); color: var(--brand-dark); align-self: flex-end; border-start-end-radius: 3px; }

/* ------------------------------------------------------------ קוד */
code, pre, .mono { font-family: "Cascadia Code", Consolas, monospace; font-size: 13px; }
.codebox {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 10px 12px;
  direction: ltr; text-align: left; overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}

/* ------------------------------------------------------------ דף התחברות */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(135deg, #0f172a, #14532d); }
.login-card { width: 100%; max-width: 390px; background: var(--surface);
  border-radius: 16px; padding: 32px 30px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card .brand { justify-content: center; margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.login-error { background: var(--danger-soft); color: var(--danger); border-radius: 9px; padding: 10px 13px; font-size: 13.5px; margin-bottom: 14px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ------------------------------------------------------------ נייד */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; flex: none; height: auto; position: static; border-inline-start: none; border-bottom: 1px solid var(--border); }
  nav { flex-direction: row; flex-wrap: wrap; }
  nav a { flex: 1 1 auto; justify-content: center; }
  .content { padding: 18px 15px 40px; }
  .bubble { max-width: 92%; }
}
