/* =========================================================================
 * Wellport / Newport — statusi prodaje
 * Visual language taken from the original TV boards:
 *   gold  #B39F73 (Newport, zgrade A1/B1), burgundy #61103F (A2/B2, Wellport),
 *   white background, letter-spaced uppercase type, thin gold row rules.
 * ========================================================================= */

:root {
  --gold: #b39f73;
  --gold-dark: #8f7c50;
  --gold-line: #d8cdb2;
  --burgundy: #61103f;
  --burgundy-line: #d9c3d0;
  --ink: #414042;
  --ink-soft: #6d6e71;
  --bg: #ffffff;

  /* Status colors — adapted to the elegant gold/burgundy identity */
  --st-available: #33714b;
  --st-available-bg: #e9f2ec;
  --st-reserved: #b06e12;
  --st-reserved-bg: #faf0dc;
  --st-sold: #59595c;
  --st-sold-bg: #ededee;

  --band-w: 96px;
  --font: "Montserrat", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body { padding-right: var(--band-w); min-height: 100vh; }

/* ---------- Header ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  padding: 22px 32px 10px;
}

.brand img { height: 58px; display: block; }

.phase-tabs { display: flex; gap: 8px; flex-wrap: wrap; }

.phase-tab {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-soft);
  border: 1px solid var(--gold-line);
  background: transparent;
  padding: 9px 18px 8px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.phase-tab:hover { color: var(--gold-dark); border-color: var(--gold); }

.phase-tab.is-active {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}

body[data-theme="burgundy"] .phase-tab:hover { color: var(--burgundy); border-color: var(--burgundy); }
body[data-theme="burgundy"] .phase-tab.is-active {
  background: var(--burgundy);
  border-color: var(--burgundy);
}

/* ---------- Toolbar (filters + summary) ---------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding: 8px 32px 4px;
}

.filters { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }

.status-filter { display: flex; flex-wrap: wrap; }

.status-filter .chip {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--gold-line);
  border-right-width: 0;
  padding: 8px 14px 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.status-filter .chip:first-child { border-radius: 2px 0 0 2px; }
.status-filter .chip:last-child { border-right-width: 1px; border-radius: 0 2px 2px 0; }
.status-filter .chip:hover { color: var(--ink); background: #faf8f3; }
.status-filter .chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.status-filter .chip.is-active + .chip { border-left-color: var(--ink); }

select.building-select,
input.search-input {
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink);
  border: 1px solid var(--gold-line);
  border-radius: 2px;
  background: #fff;
  padding: 8px 10px;
}
input.search-input { width: 130px; }
select.building-select:focus, input.search-input:focus { outline: 1.5px solid var(--gold); outline-offset: 0; }

.summary {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.summary .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.summary .dot.available { background: var(--st-available); }
.summary .dot.reserved { background: var(--st-reserved); }
.summary .dot.sold { background: var(--st-sold); }

/* ---------- Board ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 26px 30px;
  padding: 18px 32px 48px;
  align-items: start;
}

.board-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 0;
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.apt-table { width: 100%; }

.apt-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gold);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  padding: 9px 14px 8px;
  border-left: 5px solid var(--burgundy);
}

.apt-table-head.head-burgundy { background: var(--burgundy); border-left-color: var(--gold); }

.apt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--gold-line);
  font-family: var(--font);
  padding: 8px 6px 7px 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.apt-row:hover, .apt-row:focus-visible { background: #f7f4ec; outline: none; }
.apt-row:focus-visible { box-shadow: inset 0 0 0 1.5px var(--gold); }

.apt-row .num {
  font-size: 14px;
  letter-spacing: 0.14em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- Status badges ---------- */

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 4px 9px 3px;
  border-radius: 2px;
  white-space: nowrap;
}
.badge.available { color: var(--st-available); background: var(--st-available-bg); }
.badge.reserved { color: var(--st-reserved); background: var(--st-reserved-bg); }
.badge.sold { color: var(--st-sold); background: var(--st-sold-bg); }

/* ---------- Phase band (right edge, like the original boards) ---------- */

.phase-band {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--band-w);
  background: var(--gold);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 34px;
  z-index: 5;
}

body[data-theme="burgundy"] .phase-band { background: var(--burgundy); }

.phase-band .label {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.85);
  padding-bottom: 12px;
  margin-bottom: 6px;
}

.phase-band .number { font-size: 92px; font-weight: 700; line-height: 1.05; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 35, 40, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: #fff;
  width: min(420px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border-top: 5px solid var(--gold);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  padding: 26px 28px 28px;
}
.modal.theme-burgundy { border-top-color: var(--burgundy); }

.modal-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

.modal h2 {
  margin: 0 0 2px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
}

.modal .subtitle {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 14px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0 2px;
}
.modal-close:hover { color: var(--ink); }

.modal .badge { font-size: 12px; padding: 6px 12px 5px; }

.detail-list { margin: 18px 0 0; }

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--gold-line);
  padding: 8px 2px 7px;
  font-size: 13px;
}
.detail-row dt { color: var(--ink-soft); letter-spacing: 0.1em; text-transform: uppercase; font-size: 11px; padding-top: 2px; }
.detail-row dd { margin: 0; text-align: right; letter-spacing: 0.04em; }

.floorplan { margin-top: 16px; }
.floorplan img { width: 100%; height: auto; display: block; border: 1px solid var(--gold-line); }

.modal-cta { margin-top: 22px; }

.cta-note {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  padding: 12px 10px 11px;
  border-radius: 2px;
}
.cta-note.reserved { color: var(--st-reserved); background: var(--st-reserved-bg); }
.cta-note.sold { color: var(--st-sold); background: var(--st-sold-bg); }

.cta-button {
  display: block;
  text-align: center;
  text-decoration: none;
  background: var(--gold);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 13px 10px 12px;
  border-radius: 2px;
  transition: background 0.15s;
}
.cta-button:hover { background: var(--gold-dark); }
.modal.theme-burgundy .cta-button { background: var(--burgundy); }
.modal.theme-burgundy .cta-button:hover { background: #7a2153; }

.cta-phone {
  display: block;
  text-align: center;
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  text-decoration: none;
}

/* ---------- Data validation banner (only shows if apartments.js is invalid) ---------- */

.data-errors {
  margin: 0 32px 10px;
  padding: 12px 16px;
  background: #fdecea;
  color: #8a1c12;
  font-size: 13px;
  border: 1px solid #f2b8b2;
}
.data-errors ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Prijava agenata i editor statusa ---------- */

.auth-area {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.auth-user {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.auth-link {
  background: none;
  border: none;
  border-bottom: 1px solid var(--gold-line);
  padding: 2px 1px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-dark);
  cursor: pointer;
}
.auth-link:hover { color: var(--ink); border-bottom-color: var(--gold); }
body[data-theme="burgundy"] .auth-link { color: var(--burgundy); }

.api-offline {
  margin: 0 32px 10px;
  padding: 10px 16px;
  background: var(--st-reserved-bg);
  color: var(--st-reserved);
  font-size: 12px;
  letter-spacing: 0.08em;
  border: 1px solid #ecd9b4;
}

/* Diskretan signal da je bedž klikabilan (samo prijavljeni sales/admin) */
body.can-edit .badge[data-apt-id] {
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
body.can-edit .badge[data-apt-id]:hover {
  box-shadow: inset 0 0 0 1.5px currentColor;
}

/* Popover za promenu statusa — izgled po Claude Design meniju */
.status-pop {
  position: fixed;
  z-index: 80;
  width: 326px;
  background: #fff;
  border: 1px solid rgba(179, 159, 115, 0.6);
  box-shadow: 0 22px 60px rgba(52, 10, 33, 0.28);
  animation: se-pop-in 0.14s ease-out;
}
@keyframes se-pop-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.status-pop.sheet {
  left: 0 !important;
  right: 0;
  bottom: 0;
  top: auto !important;
  width: auto;
  border-left: none;
  border-right: none;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.status-pop .se-head {
  background: var(--burgundy);
  padding: 16px 22px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.se-kind { font-size: 13px; font-weight: 600; letter-spacing: 2px; color: rgba(255, 255, 255, 0.6); }
.se-label { font-size: 22px; font-weight: 600; letter-spacing: 1.5px; color: #fff; }

.se-list { display: flex; flex-direction: column; padding: 12px; }

.se-option {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  height: 58px;
  padding: 0 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  transition: background 0.12s;
}
.se-option:hover:not(:disabled), .se-option:focus-visible { background: rgba(179, 159, 115, 0.16); outline: none; }
.se-option:disabled { opacity: 0.55; cursor: default; }
.se-option.current { background: rgba(179, 159, 115, 0.10); cursor: default; }

.se-dot { width: 14px; height: 14px; flex: none; border-radius: 50%; }
.se-txt { display: flex; flex-direction: column; gap: 3px; }
.se-st { font-size: 16px; font-weight: 600; letter-spacing: 1.4px; }
.se-sr { font-size: 12px; letter-spacing: 1.2px; color: #9c9691; }
.se-check { margin-left: auto; font-size: 15px; font-weight: 600; color: var(--burgundy); }

.se-option.st-available .se-dot, .se-option.st-available .se-st { background-color: var(--st-available); color: var(--st-available); }
.se-option.st-reserved .se-dot, .se-option.st-reserved .se-st { background-color: var(--st-reserved); color: var(--st-reserved); }
.se-option.st-sold .se-dot, .se-option.st-sold .se-st { background-color: var(--st-sold); color: var(--st-sold); }
.se-option .se-st { background-color: transparent; }

.se-close {
  width: 100%;
  height: 48px;
  border: none;
  border-top: 1px solid rgba(179, 159, 115, 0.35);
  background: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #a9a3a0;
  cursor: pointer;
}
.se-close:hover { color: var(--burgundy); }

.se-note {
  margin: 0 22px 10px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.se-note.error { color: #8a1c12; }

.se-confirm-text { font-size: 13px; line-height: 1.55; margin: 16px 22px 12px; }

.se-confirm-row { display: flex; gap: 8px; padding: 0 12px 12px; }
.se-confirm-yes, .se-confirm-no {
  flex: 1;
  height: 46px;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0 8px;
}
.se-confirm-yes { background: var(--gold); color: #fff; }
.se-confirm-yes:hover { background: var(--gold-dark) !important; color: #fff; }
.se-confirm-no { border: 1px solid var(--gold-line); color: var(--ink-soft); }

/* Toast poruke */
.se-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  z-index: 90;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  letter-spacing: 0.1em;
  padding: 11px 20px 10px;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: min(92vw, 480px);
  text-align: center;
}
.se-toast.show { opacity: 1; transform: translate(-50%, 0); }
.se-toast.error { background: #7a231a; }

/* Modali prijave i istorije */
.auth-modal { border-top-color: var(--gold); }

.auth-form { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }

.auth-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.auth-input {
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--ink);
  border: 1px solid var(--gold-line);
  border-radius: 2px;
  padding: 10px 10px;
}
.auth-input:focus { outline: 1.5px solid var(--gold); }

.auth-error { color: #8a1c12; font-size: 12.5px; margin: 0; }

.auth-submit { border: none; cursor: pointer; width: 100%; font-family: var(--font); }
.auth-submit:disabled { opacity: 0.6; cursor: default; }

.history-modal { width: min(640px, 100%); }

.history-scroll { margin-top: 14px; overflow-x: auto; }

.history-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.history-table th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--gold-line);
  padding: 6px 10px 6px 2px;
}
.history-table td {
  border-bottom: 1px solid var(--gold-line);
  padding: 7px 10px 6px 2px;
  white-space: nowrap;
}
.history-table .badge { font-size: 9.5px; padding: 3px 7px 2px; }

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
  body { padding-right: 0; }
  .phase-band { display: none; }
}

@media (max-width: 640px) {
  .site-header { padding: 16px 16px 8px; }
  .brand img { height: 44px; }
  .toolbar { padding: 6px 16px 2px; }
  .board { padding: 12px 16px 40px; grid-template-columns: 1fr; }
  input.search-input { width: 100%; }
  .filters { width: 100%; }
  .summary { gap: 12px; }
  .modal { padding: 20px 18px 22px; }
}
