/* ============================================================
   בית המאזן רגעים — לוח שיבוץ שבועי
   CSS — פלטת צבעים מבוססת הלוגו
   ============================================================ */

/* ===== LOGIN SCREEN ===== */
#login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(150deg, #1a4731 0%, #2d6a4f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}
.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 44px 52px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.28);
  width: 380px;
  max-width: calc(100vw - 32px);
}
.login-logo {
  height: 70px;
  margin-bottom: 14px;
  object-fit: contain;
}
.login-title {
  font-size: 26px;
  color: #1a4731;
  margin: 0 0 4px;
  font-weight: 700;
}
.login-subtitle {
  font-size: 14px;
  color: #777;
  margin: 0 0 30px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: right;
}
.login-label {
  font-size: 13px;
  color: #444;
  font-weight: 600;
}
.login-input {
  padding: 11px 14px;
  border: 1.5px solid #ccc;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
  text-align: left;
  direction: ltr;
}
.login-input:focus { border-color: #2d6a4f; }
.login-input.input-error { border-color: #dc3545; }
.login-error {
  font-size: 12px;
  color: #dc3545;
  text-align: right;
}
.login-btn {
  margin-top: 6px;
  padding: 12px;
  background: #2d6a4f;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.login-btn:hover { background: #1a4731; }
.login-btn-ghost {
  margin-top: 10px;
  padding: 8px;
  background: none;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
}
.login-btn-ghost:hover { background: #f5f5f5; }
.login-sent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.login-sent-icon  { font-size: 40px; }
.login-sent-title { font-size: 16px; font-weight: 700; color: #1a4731; }
.login-sent-sub   { font-size: 13px; color: #666; text-align: center; line-height: 1.6; }
.login-sent-sub span { font-size: 11px; color: #aaa; }
/* Logout button in header */
.btn-logout {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-logout:hover { background: rgba(255,255,255,0.28); }
.hdr-btn-backup, .hdr-btn-restore {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.25);
}
.hdr-btn-backup:hover  { background: rgba(100,200,100,0.3); }
.hdr-btn-restore:hover { background: rgba(100,160,255,0.3); }

/* ===== VARIABLES ===== */
:root {
  /* Logo color palette */
  --green-dark:   #2C5F2E;
  --green-mid:    #3D8B37;
  --green-light:  #7BB341;
  --orange:       #E07235;
  --red-brick:    #C4372A;
  --amber:        #E8A030;
  --bg:           #F5F1EB;
  --surface:      #FDFBF8;
  --white:        #FFFFFF;
  --text:         #2C3820;
  --text-sec:     #5C6850;
  --text-muted:   #9CAA8C;
  --border:       #D8DDD0;
  --shadow:       rgba(44,95,46,0.12);

  /* Calendar sizing */
  --hour-h:       80px;   /* px per hour → 15min = 20px */
  --start-h:      8;      /* calendar starts at 08:00 */
  --end-h:        22;     /* calendar ends at 22:00 */
  --time-w:       52px;
  --sidebar-w:    264px;
  --hdr-h:        60px;
  --cal-hdr-h:    48px;
  --min-day-w:    130px;

  /* Event type colors */
  --c-therapy:    #ddf0d8;
  --c-group:      #dde8fb;
  --c-shiatsu:    #fde8d8;
  --c-meeting:    #ede0fb;
  --c-meal:       #fff5cc;
  --c-activity:   #d8f0f0;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Segoe UI', 'Arial', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); overflow: hidden; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-mid); outline-offset: 1px; }

/* ===== APP SHELL ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ===== HEADER ===== */
#app-header {
  height: var(--hdr-h);
  background: var(--header-bg, var(--green-dark));
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  z-index: 100;
}

/* ===== ORANGE THEME (טיפול יום) ===== */
body.theme-orange { --header-bg: #C96318; }

/* ===== ORG SWITCHER ===== */
.org-switcher {
  position: relative;
}
.org-switcher-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.org-subtitle {
  font-size: 10px;
  color: rgba(255,255,255,0.72);
  font-weight: 400;
  letter-spacing: 0.03em;
  padding-right: 2px;
  pointer-events: none;
  white-space: nowrap;
}
.org-switcher-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.org-switcher-btn:hover { background: rgba(255,255,255,0.28); }
.org-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 9999;
  overflow: hidden;
}
.org-dropdown-item {
  display: block;
  width: 100%;
  padding: 11px 16px;
  text-align: right;
  font-size: 14px;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.12s;
}
.org-dropdown-item:hover { background: #f5f5f5; }
.org-dropdown-item.active {
  background: #eef6ee;
  font-weight: 700;
  color: var(--green-dark);
}
body.theme-orange .org-dropdown-item.active {
  background: #fff3ec;
  color: #C96318;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}
#logo-img {
  height: 42px;
  width: auto;
  border-radius: 6px;
  background: #fff;
  padding: 2px;
}

.header-week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
}
.nav-btn {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  transition: background 0.15s;
  border: 1px solid rgba(255,255,255,0.2);
}
.nav-btn:hover { background: rgba(255,255,255,0.28); }
.btn-today { font-size: 12px; padding: 6px 12px; font-weight: 600; }

.week-info { text-align: center; min-width: 160px; }
#week-label { font-size: 15px; font-weight: 700; }
#week-dates { font-size: 11px; opacity: 0.8; margin-top: 1px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 12px;
  color: #fff;
  opacity: 0.9;
}
.toggle-wrap input { display: none; }
.toggle-switch {
  width: 36px;
  height: 20px;
  background: rgba(255,255,255,0.25);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 2px; right: 2px;
  transition: transform 0.2s;
}
.toggle-wrap input:checked + .toggle-switch { background: var(--amber); }
.toggle-wrap input:checked + .toggle-switch::after { transform: translateX(-16px); }

.hdr-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 12px;
  transition: background 0.15s;
  white-space: nowrap;
}
.hdr-btn:hover { background: rgba(255,255,255,0.25); }
.hdr-btn-print { background: rgba(255,255,255,0.08); }

/* ===== MAIN LAYOUT ===== */
#main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
.stab {
  flex: 1;
  padding: 10px 4px;
  font-size: 12px;
  color: var(--text-sec);
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  text-align: center;
}
.stab:hover { color: var(--green-mid); }
.stab.active { color: var(--green-dark); border-bottom-color: var(--green-mid); font-weight: 700; }

.tab-panel { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.tab-panel.active { display: flex; }

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 80px;
}
.panel-scroll::-webkit-scrollbar { width: 5px; }
.panel-scroll::-webkit-scrollbar-track { background: transparent; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.sidebar-section { margin-bottom: 14px; }
.section-hdr {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 4px 6px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

/* Sidebar chip (draggable item) */
.sidebar-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: #fff;
  border: 1px solid var(--border);
  cursor: grab;
  transition: box-shadow 0.15s, transform 0.1s, border-color 0.15s;
  user-select: none;
  position: relative;
}
.sidebar-chip:hover {
  box-shadow: 0 2px 8px var(--shadow);
  border-color: var(--green-mid);
  transform: translateY(-1px);
}
.sidebar-chip:active { cursor: grabbing; transform: translateY(0); }

.chip-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chip-info { flex: 1; min-width: 0; }
.chip-name { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.2; }
.chip-sub { font-size: 11px; color: var(--text-sec); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-days { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }

.chip-edit-btn {
  opacity: 0;
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 5px;
  border-radius: 4px;
  transition: opacity 0.15s, color 0.15s;
}
.sidebar-chip:hover .chip-edit-btn { opacity: 1; }
.chip-edit-btn:hover { color: var(--green-mid); background: var(--bg); }

.chip-deactivate-btn {
  opacity: 0;
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 5px;
  border-radius: 4px;
  transition: opacity 0.15s, color 0.15s;
}
.sidebar-chip:hover .chip-deactivate-btn { opacity: 1; }
.chip-deactivate-btn:hover { color: #E07B50; background: var(--bg); }

/* Patients header */
.patients-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 6px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sec);
}
.patients-badge {
  background: var(--green-mid);
  color: #fff;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
}
.patients-badge.full { background: var(--orange); }

.add-area { padding: 8px 4px; }
.add-btn {
  width: 100%;
  padding: 8px 12px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  background: transparent;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  text-align: center;
}
.add-btn:hover { border-color: var(--green-mid); color: var(--green-dark); background: rgba(61,139,55,0.05); }

.archive-link-wrap { padding: 4px 4px 12px; text-align: center; }
.link-btn {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px;
  transition: color 0.15s;
  background: none;
  border: none;
  cursor: pointer;
}
.link-btn:hover { color: var(--green-mid); }

/* Patient chip coloured strip */
.patient-chip { position: relative; overflow: hidden; }
.patient-chip::before {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 0 8px 8px 0;
  background: var(--chip-color, #ccc);
}

/* ===== CALENDAR ===== */
#calendar-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

#cal-header {
  display: flex;
  position: sticky;
  top: 0;
  flex-shrink: 0;
  background: #fff;
  border-bottom: 2px solid var(--green-dark);
  height: var(--cal-hdr-h);
  z-index: 50;
}
.cal-gutter { width: var(--time-w); flex-shrink: 0; }

#day-headers-row {
  flex: 1;
  display: flex;
  min-width: 0;
}
.day-hdr {
  position: relative;
  flex: 1;
  min-width: var(--min-day-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--border);
  padding: 4px;
  transition: background 0.15s;
}
.day-hdr:first-child { border-left: none; }

/* Column resize handle (sits on left border in RTL) */
.col-resize-handle {
  position: absolute;
  left: -4px;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 6;
  border-radius: 3px;
  transition: background 0.15s;
}
.col-resize-handle:hover,
.col-resize-handle.dragging {
  background: rgba(44, 95, 46, 0.25);
}
.day-hdr.today { background: #f0f8f0; }
.day-hdr.today .day-name { color: var(--green-dark); }
.day-hdr.closed-day { background: #f5f5f5; }
.day-hdr-name { font-size: 13px; font-weight: 700; color: var(--text); }
.day-hdr-date { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.day-hdr.today .day-hdr-date {
  background: var(--green-mid);
  color: #fff;
  border-radius: 10px;
  padding: 0 6px;
}

/* Closed day header */
.day-hdr.closed-day .day-hdr-name { color: var(--text-muted); }

#cal-scroll {
  flex: 1;
  overflow: auto;
}
#cal-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
#cal-scroll::-webkit-scrollbar-track { background: var(--bg); }
#cal-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#cal-body {
  display: flex;
  position: relative;
  /* height set by JS */
}

/* Time column */
#time-col {
  width: var(--time-w);
  flex-shrink: 0;
  position: sticky;
  right: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 10;
}
.time-label {
  position: absolute;
  right: 0;
  width: 100%;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  transform: translateY(-50%);
  padding-left: 4px;
  pointer-events: none;
}
.time-label-half {
  font-size: 8px;
  opacity: 0.55;
}

/* Day columns */
#day-cols {
  flex: 1;
  display: flex;
  min-width: 0;
}
.day-col {
  flex: 1;
  min-width: var(--min-day-w);
  position: relative;
  border-left: 1px solid #e8e8e0;
  background: #fff;
  transition: background 0.2s;
}
.day-col:first-child { border-left: none; }
.day-col.today { background: #f8fcf8; }

/* Hour and half-hour lines */
.cal-hour-line {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: #ece8e0;
  pointer-events: none;
  z-index: 1;
}
.cal-half-line {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: #f3f0ea;
  pointer-events: none;
  z-index: 1;
}

/* Drop highlight */
.day-col.drag-over { background: #f0f8f0; }
.day-col.drag-over::after {
  content: 'שחרר כאן';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  color: var(--green-mid);
  opacity: 0.6;
  pointer-events: none;
}

/* Drop line indicator */
.drop-indicator {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: var(--green-mid);
  pointer-events: none;
  z-index: 20;
  border-radius: 2px;
}
.drop-indicator::before {
  content: '';
  position: absolute;
  right: -4px;
  top: -4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--green-mid);
}

/* Closed / blocked time overlay */
.time-block-overlay {
  position: absolute;
  left: 0; right: 0;
  background: repeating-linear-gradient(
    45deg,
    rgba(200,190,180,0.2),
    rgba(200,190,180,0.2) 6px,
    transparent 6px,
    transparent 12px
  );
  border-top: 1px dashed #ccc;
  z-index: 2;
  pointer-events: none;
}
.time-block-label {
  font-size: 10px;
  color: #bbb;
  text-align: center;
  padding-top: 8px;
}
/* Sunday before-11:00 block */
.pre-open-block {
  position: absolute;
  left: 0; right: 0;
  top: 0;
  background: rgba(230,225,215,0.5);
  z-index: 2;
  pointer-events: none;
}
.pre-open-label {
  font-size: 10px;
  color: #bbb;
  text-align: center;
  padding-top: 12px;
}

/* Sunday morning 8:00–11:00 visual overlay */
.sunday-morning-block {
  position: absolute;
  left: 0; right: 0;
  background: rgba(232,248,230,0.6);
  border-bottom: 1px solid rgba(100,170,100,0.25);
  z-index: 2;
  pointer-events: none;
}
.sunday-morning-label {
  font-size: 10px;
  color: rgba(50,130,50,0.7);
  text-align: center;
  padding-top: 8px;
  line-height: 1.7;
}

/* ===== CALENDAR EVENTS ===== */
.cal-event {
  position: absolute;
  border-radius: 6px;
  padding: 4px 7px 2px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,0.08);
  transition: box-shadow 0.15s, transform 0.1s;
  z-index: 10;
  display: flex;
  flex-direction: column;
  user-select: none;
  min-height: 22px;
}
.cal-event:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,0.18);
  z-index: 15;
}
.cal-event.is-dragging {
  opacity: 0.5;
  pointer-events: none;
}
.cal-event.conflict {
  border: 2px solid var(--orange) !important;
  box-shadow: 0 0 0 2px rgba(224,114,53,0.3);
}

.event-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
  overflow: hidden;
}
.event-sub {
  font-size: 10px;
  color: var(--text-sec);
  margin-top: 1px;
  word-break: break-word;
}
.event-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 2px;
}
.evt-time {
  font-size: 10px;
  font-weight: 700;
  color: rgba(0,0,0,0.5);
  margin-left: 3px;
  white-space: nowrap;
}

/* Room indicator dot on event */
.event-room-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Fixed event lock icon */
.event-lock {
  font-size: 9px;
  opacity: 0.5;
  position: absolute;
  top: 3px;
  left: 5px;
}

/* Resize handle at bottom */
.resize-handle {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  height: 8px;
  cursor: ns-resize;
  background: rgba(0,0,0,0.06);
  border-radius: 0 0 6px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.resize-handle::after {
  content: '';
  width: 20px; height: 2px;
  background: rgba(0,0,0,0.2);
  border-radius: 2px;
}
.resize-handle:hover { background: rgba(0,0,0,0.12); }

/* Slot-swap move buttons on event cards (◀ / ▶ arrows, visible on hover) */
.event-move-slot {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 3px;
  font-size: 8px;
  line-height: 1;
  padding: 3px 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 6;
  color: var(--text);
}
.cal-event:hover .event-move-slot { opacity: 1; }
.event-move-slot:hover { background: white !important; opacity: 1 !important; }
.event-move-slot-l { left: 2px; }
.event-move-slot-r { right: 2px; }

/* Current time line */
#current-time-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: #e53935;
  z-index: 30;
  pointer-events: none;
}
#current-time-line::before {
  content: '';
  position: absolute;
  right: -5px;
  top: -4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #e53935;
}

/* ===== DRAG GHOST ===== */
#drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  padding: 8px 12px;
  background: var(--green-dark);
  color: #fff;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  white-space: nowrap;
  transform: translate(-50%, -50%);
  opacity: 0.9;
}

/* ===== MODALS ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: #fff;
  border-radius: 14px;
  width: 520px;
  max-width: 96vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}
.modal-sm { width: 380px; }

.modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.modal-hdr h3 { font-size: 16px; font-weight: 700; color: var(--green-dark); }
.modal-x {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.modal-x:hover { background: #f0e8e0; color: var(--red-brick); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Form groups */
.fg { display: flex; flex-direction: column; gap: 4px; }
.fg label { font-size: 12px; font-weight: 600; color: var(--text-sec); }
.fg input, .fg select, .fg textarea {
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s;
  width: 100%;
}
.fg input:focus, .fg select:focus, .fg textarea:focus {
  border-color: var(--green-mid);
  outline: none;
}
.fg textarea { resize: vertical; }

.fg-row { display: flex; gap: 10px; }
.fg-row .fg { flex: 1; }

/* Color swatch row */
.color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.color-swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--green-dark); transform: scale(1.2); box-shadow: 0 0 0 2px rgba(44,95,46,0.3); }

/* Patients checkbox grid */
.patients-check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.patient-check-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.patient-check-item input { display: none; }
.patient-check-item.checked { border-color: var(--green-mid); background: #f0f8f0; }
.patient-color-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Modal footer */
.modal-ftr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.modal-ftr-r { display: flex; gap: 8px; }

/* Buttons */
.btn-primary {
  background: var(--green-mid);
  color: #fff;
  border-radius: 8px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  background: transparent;
  color: var(--text-sec);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: var(--text-sec); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--red-brick);
  border: 1.5px solid rgba(196,55,42,0.3);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 12px;
  transition: background 0.15s;
}
.btn-danger:hover { background: rgba(196,55,42,0.08); border-color: var(--red-brick); }

/* ===== TEMPLATE LIST ===== */
.tpl-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 340px;
  overflow-y: auto;
  padding: 2px 2px 4px;
}
.tpl-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px 4px 6px;
  transition: background 0.12s;
}
.tpl-row:hover { background: #e8f5e9; }
.tpl-name-btn {
  flex: 1;
  text-align: right;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  padding: 6px 4px;
}
.tpl-name-btn:hover { color: var(--green-dark); }
.tpl-del-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.45;
  transition: opacity 0.15s;
  padding: 4px;
  flex-shrink: 0;
}
.tpl-del-btn:hover { opacity: 1; }
.btn-secondary {
  background: transparent;
  color: var(--text-sec);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  transition: border-color 0.15s, color 0.15s;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--text-sec); color: var(--text); }

/* ===== CONTEXT MENU ===== */
#ctx-menu {
  position: fixed;
  z-index: 2000;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  padding: 6px 0;
  min-width: 150px;
  border: 1px solid var(--border);
}
.ctx-item {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}
.ctx-item:hover { background: var(--bg); }
.ctx-danger { color: var(--red-brick); }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ===== TOAST ===== */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  background: var(--text);
  color: #fff;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 13px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  animation: toastIn 0.25s ease;
}
#toast.success { background: var(--green-mid); }
#toast.error { background: var(--red-brick); }
#toast.warning { background: var(--amber); color: var(--text); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Archive list */
.archive-list { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.archive-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.archive-item-name { font-size: 13px; font-weight: 600; }
.archive-restore-btn {
  font-size: 11px;
  color: var(--green-mid);
  border: 1px solid var(--green-light);
  border-radius: 6px;
  padding: 4px 10px;
  transition: background 0.15s;
}
.archive-restore-btn:hover { background: rgba(61,139,55,0.08); }
.archive-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 24px; }

/* ===== SCROLLBAR GLOBAL ===== */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ===== PATIENT SLOTS IN EVENTS ===== */
.event-patient-slots {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}
.event-session-slots {
  border-top-style: dashed;
  border-top-color: rgba(0,0,0,0.18);
}
/* Grid layout: dot + time on row 1, name wraps on row 2 — always readable in narrow columns */
.event-patient-slot {
  display: grid;
  grid-template-columns: 10px 1fr 16px;
  grid-template-rows: auto auto;
  column-gap: 2px;
  row-gap: 1px;
  font-size: 10.5px;
  line-height: 1.35;
  padding: 2px 3px;
  border-radius: 3px;
  background: rgba(255,255,255,0.45);
  min-height: 18px;
}
.event-patient-slot:hover { background: rgba(255,255,255,0.8); }
.slot-patient-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  grid-area: 1 / 1;
  margin-top: 3px;
}
.slot-time {
  font-weight: 700;
  font-size: 10px;
  color: #333;
  cursor: pointer;
  text-decoration: underline dotted rgba(0,0,0,0.3);
  transition: color 0.1s;
  grid-area: 1 / 2;
  white-space: nowrap;
}
.slot-time:hover { color: var(--green-dark); }
.slot-name {
  grid-area: 2 / 2;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  color: #222;
  font-size: 10px;
}
.slot-remove-btn {
  background: none;
  border: none;
  padding: 0 2px;
  cursor: pointer;
  color: #bbb;
  font-size: 9px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  grid-area: 1 / 3;
  align-self: start;
  margin-top: 2px;
}
.event-patient-slot:hover .slot-remove-btn { opacity: 1; }
.slot-remove-btn:hover { color: var(--red-brick); }

/* Event as patient drop target */
.cal-event.patient-drop-target {
  outline: 2px solid var(--green-mid);
  outline-offset: 1px;
  z-index: 15;
}
.cal-event.patient-drop-target::after {
  content: '+\ שחרר לשיבוץ';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(44,95,46,0.88);
  color: #fff;
  text-align: center;
  font-size: 10px;
  padding: 3px 0;
  border-radius: 0 0 5px 5px;
  pointer-events: none;
  z-index: 20;
}

/* Modal patient slots section */
.em-patient-slots-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 28px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 6px;
  padding: 2px 0;
}
.em-slots-empty {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 2px;
  font-style: italic;
}
.modal-slot-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 12px;
}
.modal-slot-row .slot-patient-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.modal-slot-row .slot-time-input {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 12px;
  width: 78px;
  flex-shrink: 0;
  background: #fff;
}
.modal-slot-row .slot-name { flex: 1; font-weight: 600; color: var(--text); }
.modal-slot-row .slot-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #bbb;
  font-size: 13px;
  padding: 0 3px;
  opacity: 0.6;
  transition: color 0.15s, opacity 0.15s;
}
.modal-slot-row .slot-remove-btn:hover { color: var(--red-brick); opacity: 1; }

.em-add-patient-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.em-add-patient-row select {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: #fff;
}
.em-add-patient-row input[type="time"] {
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  width: 82px;
  flex-shrink: 0;
}
.btn-add-slot {
  padding: 5px 12px;
  background: var(--green-mid);
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-add-slot:hover { background: var(--green-dark); }

.em-manual-patient-row {
  margin-top: 4px;
}
.em-manual-patient-row input[type="text"] {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  background: #fffde7;
  box-sizing: border-box;
}

/* ===== PRINT ===== */
@media print {
  @page { size: A4 landscape; margin: 6mm 8mm; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  #app-header .header-actions,
  #sidebar,
  #ctx-menu, #toast, #drag-ghost,
  .resize-handle, .col-resize-handle,
  .event-move-slot,
  .chip-edit-btn, .chip-deactivate-btn { display: none !important; }
  #app { height: auto; overflow: visible; }
  #main-layout { overflow: visible; }
  #calendar-main { overflow: visible; }
  #cal-scroll { overflow: visible; height: auto !important; width: 100%; }
  #cal-body { height: auto !important; overflow: visible; }
  #cal-header { width: 100% !important; min-width: 0 !important; overflow: visible; }
  #day-headers-row { width: 100%; }
  #day-cols { width: 100%; }
  .day-col { min-width: 0 !important; flex: 1 !important; overflow: visible; }
  .day-hdr { min-width: 0 !important; flex: 1 !important; }
  .cal-event { page-break-inside: avoid; }
  body { background: #fff; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  :root { --sidebar-w: 220px; --min-day-w: 100px; }
  .hdr-btn-print, #btn-save-template, #btn-load-template { display: none; }
  .title-sub { display: none; }
}
@media (max-width: 680px) {
  :root { --sidebar-w: 0px; }
  #sidebar { display: none; }
  #app-header { padding: 0 8px; gap: 6px; }
  .header-logo { min-width: 0; }
  .title-main { font-size: 13px; }
}

/* ===== ROOM COLORS (for dots on events) ===== */
.room-upper   { background: #7BB341; }
.room-small   { background: #3A72B8; }
.room-lower   { background: #9370DB; }
.room-common  { background: #E8A030; }
.room-outside { background: #20B2AA; }
