/* public/css/style.css - "פנקס קהילתי מודרני" */
@import url('https://fonts.googleapis.com/css2?family=Frank+Ruhl+Libre:wght@500;700&family=Assistant:wght@400;500;600;700&display=swap');

:root {
  --navy: #1E2A44;
  --navy-light: #2C3B5E;
  --gold: #C9A227;
  --gold-soft: rgba(201,162,39,0.16);
  --cream: #FAF8F3;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e4e0d4;
  --green: #1a7a4a;
  --green-bg: #e7f5ee;
  --orange: #b5720b;
  --orange-bg: #fdf1de;
  --red: #b3423a;
  --red-bg: #fbeae8;
  --shadow-sm: 0 1px 3px rgba(30,42,68,0.08);
  --shadow-md: 0 4px 16px rgba(30,42,68,0.10);
  --shadow-lg: 0 12px 32px rgba(30,42,68,0.18);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Assistant', Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
}
.serif { font-family: 'Frank Ruhl Libre', serif; }

/* מסכי כניסה (login/setup) */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
}
.auth-card {
  background: white;
  border-radius: 14px;
  padding: 36px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.auth-card h1 {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 1.5rem;
  color: var(--navy);
  margin: 0 0 4px;
}
.auth-card p.sub { color: var(--muted); font-size: 0.85rem; margin: 0 0 24px; }

label { display: block; font-size: 0.82rem; color: var(--muted); margin: 14px 0 5px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--cream);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); border-color: var(--gold); }

button, .btn {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--gold); color: #3d3006; box-shadow: var(--shadow-sm); }
.btn-primary:hover { opacity: 0.92; box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { background: white; border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--cream); border-color: var(--gold); }
.btn-block { width: 100%; margin-top: 18px; }
button:disabled { opacity: 0.55; cursor: default; }

.error-msg { color: var(--red); font-size: 0.85rem; margin-top: 10px; min-height: 1.2em; }

/* מבנה האפליקציה הראשית */
.app-shell { display: flex; min-height: 100vh; }
.mobile-topbar { display: none; }
#sidebarOverlay { display: none; }
.sidebar {
  width: 210px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy) 0%, #17213a 100%);
  padding: 24px 14px;
  color: white;
  box-shadow: 2px 0 12px rgba(0,0,0,0.12);
}
.sidebar .brand {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 1.2rem;
  margin-bottom: 26px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #F5EFD9;
}
.sidebar .brand svg { flex-shrink: 0; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  color: #C7CCDA;
  text-decoration: none;
  font-size: 0.87rem;
  margin-bottom: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar nav a svg { flex-shrink: 0; opacity: 0.85; }
.sidebar nav a.active { background: var(--gold-soft); color: #F0D989; box-shadow: inset 2px 0 0 var(--gold); }
.sidebar nav a.active svg { opacity: 1; }
.sidebar nav a:hover:not(.active) { background: rgba(255,255,255,0.07); color: white; }

.main { flex: 1; padding: 28px 34px; min-width: 0; }
.main h2.page-title {
  font-family: 'Frank Ruhl Libre', serif;
  color: var(--navy);
  font-size: 1.55rem;
  margin: 0 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s ease;
}
.card[onclick], .card.clickable { cursor: pointer; }
.card[onclick]:hover, .card.clickable:hover { box-shadow: var(--shadow-md); border-color: var(--gold); }

table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { background: #f3efe2; color: var(--navy); font-weight: 600; position: sticky; top: 0; font-size: 0.8rem; letter-spacing: 0.01em; }
tbody tr { transition: background 0.1s ease; }
tr:hover td { background: var(--cream); }

.badge { display: inline-block; font-size: 0.72rem; padding: 3px 9px; border-radius: 99px; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-gray { background: #eee; color: #666; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type="search"] { max-width: 280px; }
.spacer { flex: 1; }

.status-msg { font-size: 0.85rem; color: var(--muted); margin: 8px 0; }
.status-msg.error { color: var(--red); }
.status-msg.success { color: var(--green); }

/* כרטיס משפחה - ציר זמן ותגיות */
.tag-pill { display: inline-block; background: var(--gold-soft); color: #8a6d0e; font-size: 0.72rem; padding: 3px 10px; border-radius: 99px; margin-inline-end: 4px; }
.info-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 14px 16px; background: #f6f4ec; border-radius: 10px; }
.info-grid .f-label { font-size: 0.72rem; color: var(--muted); }
.info-grid .f-value { font-size: 0.9rem; }
.timeline-item { display: flex; gap: 12px; margin-bottom: 4px; position: relative; padding-bottom: 16px; }
.timeline-item:not(:last-child)::before {
  content: ''; position: absolute; top: 30px; bottom: 0; right: 13px; width: 1px; background: var(--line);
}
.timeline-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; z-index: 1; box-shadow: 0 0 0 3px white; }
.timeline-label { font-size: 0.9rem; color: var(--ink); }
.timeline-date { font-size: 0.75rem; color: var(--muted); margin-top: 1px; }
.ti-donation { background: var(--green-bg); color: var(--green); }
.ti-keva { background: #e6f1fb; color: #185fa5; }
.ti-support { background: var(--orange-bg); color: var(--orange); }
.ti-discussion { background: #f4e9fb; color: #7a3fa0; }

/* מודל */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,26,40,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  animation: fadeIn 0.15s ease;
  backdrop-filter: blur(1px);
}
.modal-box {
  background: white; border-radius: 14px; padding: 24px 28px; width: 100%;
  max-width: 480px; max-height: 85vh; overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.18s ease;
}
.modal-box h3 { margin-top: 0; color: var(--navy); font-family: 'Frank Ruhl Libre', serif; font-size: 1.2rem; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: transparent; border: none; padding: 9px 14px; font-size: 0.85rem; color: var(--muted); border-bottom: 2px solid transparent; border-radius: 0; }
.tabs button.active { color: var(--navy); border-bottom-color: var(--gold); font-weight: 600; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi-card {
  background: white; border: 1px solid var(--line); border-radius: 10px;
  padding: 15px 17px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi-card::before { content: ''; position: absolute; top: 0; right: 0; width: 3px; height: 100%; background: var(--gold); opacity: 0.7; }
.kpi-card .kpi-label { font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; }
.kpi-card .kpi-value { font-size: 1.55rem; font-weight: 600; color: var(--navy); font-family: 'Frank Ruhl Libre', serif; }

/* ============ מובייל ============ */
@media (max-width: 860px) {
  /* המגירה (תפריט הצד) יושבת מחוץ למסך כשהיא סגורה - בלי זה היא "מותחת"
     את רוחב הדף ויוצרת גלילה אופקית מיותרת בכל המסכים. */
  html, body { overflow-x: hidden; max-width: 100%; }

  .app-shell { flex-direction: column; }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--navy);
    color: white;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }
  .mobile-topbar button {
    background: transparent;
    border: none;
    color: #F5EFD9;
    padding: 4px;
  }
  .mobile-topbar-title {
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 1.05rem;
    color: #F5EFD9;
  }

  #sidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,14,24,0.5);
    z-index: 35;
  }
  #sidebarOverlay.visible { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 78vw;
    max-width: 300px;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    z-index: 40;
    overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0,0,0,0.25);
  }
  .sidebar.open { transform: translateX(0); }

  .main { padding: 16px; }
  .main h2.page-title { font-size: 1.25rem; flex: 1 1 100%; }
  /* שורות כותרת עם כפתורים לצדן - נשברות לשורות במקום לדחוס את הכותרת */
  .main > div { flex-wrap: wrap; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-card { padding: 11px 12px; }
  .kpi-card .kpi-value { font-size: 1.2rem; }

  .toolbar { flex-wrap: wrap; gap: 8px; }
  .toolbar input[type="search"] { max-width: none; flex: 1 1 100%; }

  /* טבלאות - גלילה אופקית פנימית במקום דחיפת כל הדף לרוחב.
     הטבלה עצמה הופכת למיכל גלילה, והתוכן שבתוכה נשאר טבלה ברוחב התוכן. */
  table { min-width: 0; }
  .card table, .main table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }
  .card table thead, .card table tbody,
  .main table thead, .main table tbody {
    display: table;
    width: max-content;
    min-width: 100%;
  }
  th, td { white-space: nowrap; }

  .modal-box { max-width: 94vw; width: 94vw; padding: 18px 16px; max-height: 90vh; }

  .info-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  button, .btn { padding: 10px 14px; font-size: 0.88rem; }
}

@media (min-width: 861px) {
  .sidebar { transform: none !important; }
}

@media print {
  .sidebar, .toolbar, button, .no-print { display: none !important; }
  .app-shell { display: block; }
  .main { padding: 0; }
  body { background: white; }
  .card { box-shadow: none; break-inside: avoid; }
  .kpi-card { box-shadow: none; }
  .page-title { color: black !important; }
}

