/* Seating Chart — base styles */
:root {
  --bg: #f4f4f2;
  --ink: #1a1a1a;
  --accent: #1d4ed8;
  --danger: #b91c1c;
  --panel-w: 280px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ---------- top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid #ddd;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 { font-size: 18px; margin: 0; white-space: nowrap; }
#layoutName { font-size: 13px; color: #666; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.btn {
  font: inherit;
  font-size: 14px;
  padding: 7px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:hover { background: #f0f0f0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1e40af; }
.btn.small { padding: 4px 8px; font-size: 13px; }
.btn.danger-btn { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: default; }

.save-state { font-size: 12px; color: #666; }
.save-state.dirty { color: #b45309; }
.save-state.saved { color: #15803d; }

/* ---------- toolbar ---------- */
#toolbar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid #ddd;
  flex: 0 0 auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tool {
  font: inherit;
  font-size: 14px;
  padding: 7px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}
.tool:hover { background: #f0f0f0; }
.tool.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tool.danger.active { background: var(--danger); border-color: var(--danger); }

/* ---------- stage / canvas ---------- */
#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: default;
}
#chart.tool-select { cursor: default; }
#chart.tool-wall, #chart.tool-mechitza, #chart.tool-group { cursor: crosshair; }
#chart.tool-door { cursor: copy; }
#chart.tool-delete { cursor: not-allowed; }

.notice {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: rgba(26, 26, 26, 0.85);
  color: #fff;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 20px;
  pointer-events: none;
  max-width: 92%;
  text-align: center;
}

/* ---------- property panel ---------- */
#panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--panel-w);
  max-width: 86vw;
  height: 100dvh;
  background: #fff;
  border-left: 1px solid #ddd;
  box-shadow: -4px 0 16px rgba(0,0,0,0.08);
  z-index: 30;
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #eee;
}
.panel-head h2 { margin: 0; font-size: 16px; }

#panelBody { padding: 14px; overflow-y: auto; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: #555; margin-bottom: 4px; }
.field input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
}
.field .row { display: flex; gap: 6px; flex-wrap: wrap; }
.kind-tag {
  display: inline-block;
  font-size: 12px;
  background: #eef2ff;
  color: var(--accent);
  border-radius: 12px;
  padding: 2px 10px;
  margin-bottom: 10px;
  text-transform: capitalize;
}
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check-row input { width: 18px; height: 18px; }

/* ---------- login modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal-card {
  background: #fff;
  border-radius: 14px;
  padding: 22px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-card p { font-size: 14px; color: #555; }
.modal-card form { display: flex; gap: 8px; margin: 12px 0; }
.modal-card input[type="email"] {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
}
.login-msg { min-height: 20px; font-size: 13px; }
.login-msg.ok { color: #15803d; }
.login-msg.err { color: var(--danger); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(26,26,26,0.92);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 24px;
  z-index: 60;
  pointer-events: none;
  max-width: 92%;
  text-align: center;
}

/* ---------- helpers ---------- */
.hidden { display: none !important; }

/* ---------- mobile tweaks ---------- */
@media (max-width: 640px) {
  .brand h1 { font-size: 15px; }
  #layoutName { display: none; }
  .btn, .tool { font-size: 13px; padding: 6px 10px; }
  #btnPrint { font-size: 0; }
  #btnPrint::after { content: "🖨"; font-size: 16px; }
}

/* ============================================================
   PRINT — 11×17 landscape (tabloid)
   ============================================================ */
@page {
  size: 17in 11in;
  margin: 0.35in;
}

@media print {
  body { display: block; height: auto; background: #fff; }

  #topbar .actions,
  #toolbar,
  #panel,
  #loginModal,
  #toast,
  #viewNotice {
    display: none !important;
  }

  #topbar {
    border: none;
    padding: 0 0 8px;
  }
  .brand h1 { font-size: 16pt; }
  #layoutName { display: inline; font-size: 11pt; }

  #stage { overflow: visible; }

  #chart {
    position: static;
    width: 100%;
    height: auto;
  }
}
