*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

:root {
  --wall: #1c1c1e;
  --slab: #111113;
  --text: #e8d5c0;
  --text-dim: #7a5a40;
  --accent: #e87c2a;
  --danger: #c0392b;
  --gap: 7px;
}

body {
  background: var(--wall);
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
  overflow: hidden;
}

/* ── Building ── */
#building-pan {
  position: fixed;
  top: 0;
  left: 0;
  cursor: grab;
  user-select: none;
  will-change: transform;
  transform-origin: 0 0;
}

#building-pan.panning { cursor: grabbing; }

#building {
  min-width: max(100vw, 1750px);
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: var(--gap);
  background-image: url('/images/wall.png');
  background-repeat: repeat;
  background-size: auto;
}

.floor {
  display: flex;
  gap: 0;
  align-items: stretch;
  background: #000;
}

.viga-row {
  display: flex;
  height: var(--gap);
  flex-shrink: 0;
}

.viga-seg {
  background-image: url('/images/viga_01.png');
  background-repeat: repeat-x;
  background-size: auto 100%;
}

.viga-col {
  width: var(--gap);
  flex-shrink: 0;
  background-image: url('/images/viga_01.png');
  background-repeat: repeat-x;
  background-size: auto 100%;
}

.viga-dark {
  filter: brightness(0.25);
}

.coluna {
  width: var(--gap);
  flex-shrink: 0;
  align-self: stretch;
  background-image: url('/images/coluna_01.png');
  background-repeat: repeat-y;
  background-size: 100% auto;
}

.coluna-dark {
  filter: brightness(0.25);
}

/* ── Apartment ── */
.apartment {
  flex: 1;
  min-width: 0;
  aspect-ratio: 938 / 633;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: transform 0.15s;
}

.apartment:hover {
  transform: scale(1.05);
  z-index: 10;
}

/* ── Divider apartment (architectural separator) ── */
.apartment.divider {
  flex: 0.9;
  margin-top: 10px;
  margin-bottom: -4px;
  filter: brightness(0.28) saturate(0.35);
  box-shadow:
    inset 8px 0 24px rgba(0,0,0,0.95),
    inset -8px 0 24px rgba(0,0,0,0.95),
    inset 0 10px 28px rgba(0,0,0,0.9),
    inset 0 -6px 16px rgba(0,0,0,0.8);
}

.apartment.divider.divider-lit {
  filter: brightness(0.55) saturate(0.6);
  box-shadow:
    inset 6px 0 18px rgba(0,0,0,0.75),
    inset -6px 0 18px rgba(0,0,0,0.75),
    inset 0 8px 20px rgba(0,0,0,0.65),
    inset 0 -4px 10px rgba(0,0,0,0.5);
}

.apartment.divider:hover {
  transform: scale(1.02);
}

/* ── Mine marker ── */
.apartment.mine::after {
  content: '';
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  z-index: 3;
}

/* ── Online dot (vizinho online) ── */
.apt-online {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2ecc71;
  box-shadow: 0 0 6px #2ecc71;
  z-index: 3;
  pointer-events: none;
}

/* ── Blocked apartment ── */
.apt-blocked {
  filter: brightness(0.35) saturate(0.2);
  cursor: default;
}
.apt-blocked-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  z-index: 3;
  pointer-events: none;
  opacity: 0.7;
}

/* ── Unread badge ── */
.apt-unread {
  position: absolute;
  top: 3px;
  left: 3px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  z-index: 4;
  pointer-events: none;
}

/* ── Neighbor enter/leave animation ── */
@keyframes aptPulseIn {
  0%, 100% { box-shadow: none; }
  40%       { box-shadow: 0 0 0 4px rgba(46,204,113,0.7), 0 0 14px rgba(46,204,113,0.4); }
}
@keyframes aptPulseOut {
  0%, 100% { box-shadow: none; }
  40%       { box-shadow: 0 0 0 4px rgba(192,57,43,0.7), 0 0 14px rgba(192,57,43,0.4); }
}
.apt-anim-in  { animation: aptPulseIn  1.4s ease; }
.apt-anim-out { animation: aptPulseOut 1.4s ease; }

/* ── Occupant info (hover) ── */
.apt-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  z-index: 2;
  pointer-events: none;
}

.apt-name-row {
  padding: 0 5px 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s;
}

.apt-status-row {
  padding: 0 5px 3px;
  margin-top: -0px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s;
}

.apartment:hover .apt-name-row,
.apartment:hover .apt-status-row { opacity: 1; }
.apt-name-row.always-visible   { opacity: 1; }
.apt-status-row.always-visible { opacity: 1; }

.apt-name   { display: block; font-size: 9px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apt-status { display: block; font-size: 8px; color: rgba(255,255,255,0.65); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Apartment tooltip ── */
.apt-tooltip {
  position: fixed;
  background: rgba(10,5,2,0.92);
  border: 1px solid #3a1a08;
  color: var(--text);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 5px;
  pointer-events: none;
  z-index: 200;
  max-width: 220px;
  white-space: normal;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.apt-tooltip.visible { opacity: 1; }

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }

.modal-box {
  background: #1a0b05;
  border: 1px solid #3a1a08;
  border-radius: 10px;
  padding: 28px 28px 24px;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-box h2  { font-size: 18px; font-weight: 700; }
.modal-sub     { font-size: 13px; color: var(--text-dim); }
.field-label   { font-size: 12px; color: var(--text-dim); }

.modal-box input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  background: #100704;
  border: 1px solid #3a1a08;
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.modal-box input[type="text"]:focus { border-color: var(--accent); }

/* ── Style picker ── */
.style-picker {
  display: flex;
  gap: 10px;
}

.style-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.style-option input[type="radio"] { display: none; }

.style-option img {
  width: 100%;
  aspect-ratio: 938 / 633;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid #2a1208;
  transition: border-color 0.2s, transform 0.2s;
}

.style-option input:checked + img {
  border-color: var(--accent);
  transform: scale(1.04);
}

.style-option span { font-size: 11px; color: var(--text-dim); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Panel ── */
.panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: #160a04;
  border-left: 1px solid #2a1208;
  display: flex;
  flex-direction: column;
  z-index: 90;
  box-shadow: -8px 0 32px rgba(0,0,0,0.6);
}
.panel.hidden { display: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #2a1208;
  font-size: 14px;
  font-weight: 600;
}

.panel-sub   { display: block; font-size: 11px; color: var(--text-dim); font-weight: 400; }
.panel-close { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 14px; }
.panel-close:hover { color: var(--text); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.field-row label { font-size: 12px; color: var(--text-dim); width: 72px; flex-shrink: 0; }

.field-row input[type="text"],
.field-row input[type="email"],
.field-row select {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  background: #100704;
  border: 1px solid #3a1a08;
  border-radius: 5px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.field-row input:focus,
.field-row select:focus { border-color: var(--accent); }
.field-row input[readonly] { opacity: 0.5; cursor: default; }
.field-row input[readonly]:focus { border-color: #3a1a08; }

.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

/* ── Panel cards ── */
.panel-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel-card-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.syndico-user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  cursor: pointer;
  font-size: 13px;
}
.syndico-user-item:hover { background: rgba(255,255,255,0.08); }

/* ── Chat ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg { display: flex; flex-direction: column; gap: 2px; max-width: 85%; }
.chat-msg.sent  { align-self: flex-end; align-items: flex-end; }
.chat-msg.recv  { align-self: flex-start; }

.chat-bubble {
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
}
.chat-msg.sent .chat-bubble { background: var(--accent); color: #fff; }
.chat-msg.recv .chat-bubble { background: #2a1208; color: var(--text); }
.chat-meta { font-size: 10px; color: var(--text-dim); }

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #2a1208;
}
.chat-input-row input {
  flex: 1;
  padding: 8px 12px;
  background: #100704;
  border: 1px solid #3a1a08;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.chat-input-row input:focus { border-color: var(--accent); }

/* ── Typing indicator ── */
.chat-typing {
  padding: 4px 16px 6px;
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}
.chat-typing.hidden { display: none; }

/* ── Info panel ── */
.info-name   { font-size: 18px; font-weight: 700; margin-top: 4px; }
.info-status { font-size: 14px; color: var(--text-dim); margin-top: 4px; }
.info-hint      { font-size: 11px; color: #4a2a10; margin-top: 16px; }
.contract-info  { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.contract-info.urgent { color: #e8882a; }

/* ── Histórico ── */
.history-section { margin-top: 12px; }
.history-title   { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #2a1208;
  font-size: 12px;
}
.history-item:last-child { border-bottom: none; }
.history-item-name  { flex: 1; color: var(--text); }
.history-item-dates { font-size: 10px; color: var(--text-dim); white-space: nowrap; }
.history-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  background: #2a1208;
}

/* ── Vizinho online item ── */
.neighbor-online-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #2a1208;
  cursor: pointer;
}
.neighbor-online-item:last-child { border-bottom: none; }
.neighbor-online-item:hover { opacity: 0.8; }
.neighbor-online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #2ecc71; box-shadow: 0 0 5px #2ecc71; flex-shrink: 0;
}
.neighbor-online-name    { font-size: 13px; flex: 1; }
.neighbor-online-address { font-size: 10px; color: var(--text-dim); }

/* ── Avatar ── */
.avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 4px;
}
.avatar-wrap {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #2a1208;
  border: 2px solid #3a1a08;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.avatar-img.loaded { display: block; }
.avatar-initial {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
}
.avatar-side { display: flex; flex-direction: column; gap: 5px; }
.avatar-hint { font-size: 10px; color: var(--text-dim); }
.btn-sm { padding: 5px 10px; font-size: 11px; }

/* avatar pequeno no hover do apê */
.apt-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.apt-info-inner {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── Buttons ── */
.btn-primary {
  padding: 9px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.85; }

@keyframes save-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,124,42,0.7); }
  50%       { box-shadow: 0 0 0 6px rgba(232,124,42,0); }
}
.btn-primary.dirty {
  animation: save-pulse 1.2s ease infinite;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-ghost {
  padding: 9px 16px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid #3a1a08;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--text); }

.btn-danger {
  padding: 9px 16px;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.btn-danger:hover { background: rgba(192,57,43,0.1); }

.btn-toggle {
  padding: 6px 14px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #3a1a08;
  background: #1a0a04;
  color: var(--text-dim);
  transition: all 0.2s;
}
.btn-toggle.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: #2a1208;
  color: var(--text);
  border: 1px solid #4a2010;
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 13px;
  pointer-events: none;
  transition: transform 0.3s, opacity 0.3s;
  opacity: 0;
  z-index: 200;
  white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── Neighbor popup ── */
.neighbor-popup {
  position: fixed;
  background: #1a0d06;
  border: 1px solid #3a1a08;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 150;
  min-width: 160px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}
.neighbor-popup.hidden { display: none; }

.popup-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  padding-bottom: 4px;
  border-bottom: 1px solid #2a1208;
  margin-bottom: 2px;
}

.popup-btn {
  padding: 7px 10px;
  background: transparent;
  border: 1px solid #3a1a08;
  border-radius: 5px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.popup-btn:hover { background: #2a1208; }
.popup-btn.popup-btn-danger { color: #e05555; }
.popup-btn.active { background: #2a1208; color: var(--accent); border-color: #4a2010; }

/* ── Chat events ── */
.chat-event {
  align-self: center;
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
  padding: 2px 8px;
}

/* ── Login corner button ── */
.btn-login-corner {
  position: fixed;
  bottom: 20px;
  left: 20px;
  padding: 8px 16px;
  background: #2a2a2e;
  color: #ccc;
  border: 1px solid #444;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  z-index: 150;
  transition: background 0.2s;
}
.btn-login-corner:hover   { background: #3a3a3e; color: #fff; }
.btn-login-corner.logged-in { color: var(--accent); border-color: var(--accent); }

/* ── Form error ── */
.form-error { font-size: 12px; color: #e05555; }
.form-error.hidden { display: none; }

/* ── Go-home button ── */
.btn-go-home {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(26,11,5,0.88);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  line-height: 1;
}
.btn-go-home:hover { background: var(--accent); color: #fff; }
.btn-go-home.hidden { display: none; }

/* ── Zoom buttons ── */
.btn-zoom {
  position: fixed;
  right: 20px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(26,11,5,0.88);
  border: 1px solid #444;
  color: #ccc;
  font-size: 20px;
  font-weight: 300;
  cursor: pointer;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  line-height: 1;
}
#btn-zoom-out { bottom: 66px;  }
#btn-zoom-in  { bottom: 112px; }
.btn-zoom:hover { background: #3a3a3e; color: #fff; }

/* ── Debug button ── */
.btn-debug {
  position: fixed;
  bottom: 158px;
  right: 20px;
  padding: 8px 14px;
  background: #2a2a2e;
  color: #aaa;
  border: 1px solid #444;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  z-index: 150;
  transition: background 0.2s;
}
.btn-debug:hover { background: #3a3a3e; color: #fff; }
.btn-debug.hidden { display: none; }

/* ── New floor animation ── */
@keyframes floorIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.floor-new { animation: floorIn 0.5s ease; }
