/* PLO HOM — Dark theme, CSS Grid floor plans, transitions */

:root {
  --bg: #0a0e17;
  --surface: #141a26;
  --surface-hover: #1c2435;
  --border: #1e2a3a;
  --text: #e8edf5;
  --text-muted: #7a8ba8;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --urgent: #ef4444;
  --urgent-glow: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --success: #22c55e;
  --gold: #d4a843;
  --radius: 8px;
  --expand-ms: 350ms;
  --easing: cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────────── */

#app { display: flex; flex-direction: column; height: 100%; }

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}

#logo { font-size: 18px; font-weight: 700; letter-spacing: 1px; color: var(--text); }

main { flex: 1; overflow: auto; padding: 16px; }

.screen { display: block; }
.screen.hidden { display: none; }

/* ── Auth ────────────────────────────────────────────────── */

#auth-screen {
  display: flex; justify-content: center; align-items: center;
  height: 100%; min-height: 400px;
}

.auth-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px; text-align: center;
  max-width: 360px; width: 100%;
}

.auth-box h2 { font-size: 24px; margin-bottom: 8px; }
.auth-box p { color: var(--text-muted); margin-bottom: 24px; }

#auth-form input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text);
  font-size: 14px; margin-bottom: 12px; outline: none;
}
#auth-form input:focus { border-color: var(--accent); }

#auth-form button {
  width: 100%; padding: 10px; border: none; border-radius: var(--radius);
  background: var(--accent); color: white; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s;
}
#auth-form button:hover { opacity: 0.9; }

.msg { margin-top: 12px; font-size: 13px; }
.msg.error { color: var(--urgent); }
.msg.success { color: var(--success); }

/* ── Dashboard Grid ──────────────────────────────────────── */

#property-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.property-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; cursor: pointer;
  transition: all var(--expand-ms) var(--easing);
}
.property-card:hover { border-color: var(--accent); background: var(--surface-hover); }

.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-name { font-size: 15px; font-weight: 600; }
.card-lifecycle { font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }

.card-floorplan { margin-bottom: 12px; min-height: 100px; }

.card-stats { display: flex; gap: 12px; font-size: 13px; }
.stat { color: var(--text-muted); }
.stat.urgent { color: var(--urgent); font-weight: 600; }
.stat.attention { color: var(--warning); }
.stat.clear { color: var(--success); }
.stat.burn { color: var(--gold); }

#summary-bar { margin-top: 16px; }
.summary { color: var(--text-muted); font-size: 13px; text-align: center; padding: 12px; }

/* ── Property View ───────────────────────────────────────── */

#property-screen { display: flex; gap: 16px; height: 100%; }

#property-sidebar {
  width: 200px; flex-shrink: 0; overflow-y: auto;
  border-right: 1px solid var(--border); padding-right: 12px;
}

.back-btn { width: 100%; text-align: left; margin-bottom: 12px; }

.sidebar-list { display: flex; flex-direction: column; gap: 8px; }

.sidebar-card {
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; font-size: 13px;
  transition: border-color 0.15s;
}
.sidebar-card:hover { border-color: var(--accent); }
.sidebar-name { font-weight: 500; }

#property-main { flex: 1; overflow-y: auto; }

#floorplan-container { position: relative; margin-bottom: 16px; }

/* ── Floor Plan ──────────────────────────────────────────── */

.floorplan {
  display: grid; gap: 2px;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}

.floorplan.mini { height: 100px; }
.floorplan.full { min-height: 300px; }

.room {
  position: relative; padding: 8px; cursor: pointer;
  transition: all var(--expand-ms) var(--easing);
  border: 1px solid rgba(255, 255, 255, 0.05);
  overflow: hidden;
}
.room:hover { filter: brightness(1.2); }
.room.focused { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.room.has-urgent { border-color: var(--urgent); }

.room-label {
  font-size: 11px; color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500;
}

.room-count {
  position: absolute; top: 4px; right: 6px;
  font-size: 10px; color: var(--accent); font-weight: 700;
  background: rgba(59, 130, 246, 0.2); border-radius: 50%;
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
}

/* ── Pins ────────────────────────────────────────────────── */

.pin {
  position: absolute; width: 24px; height: 24px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  transform: translate(-50%, -50%); cursor: pointer; z-index: 2;
  transition: transform 0.15s; font-size: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.pin:hover { transform: translate(-50%, -50%) scale(1.2); z-index: 10; }
.pin-urgent { animation: pulse-urgent 2s infinite; }

.pin-icon { line-height: 1; }

.pin-cluster {
  position: absolute; width: 32px; height: 32px;
  border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  transform: translate(-50%, -50%); cursor: pointer; z-index: 3;
  font-size: 12px; font-weight: 700; color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}
.pin-cluster:hover { transform: translate(-50%, -50%) scale(1.15); }
.pin-cluster.pin-urgent { background: var(--urgent); }

.cluster-count { font-size: 12px; }

@keyframes pulse-urgent {
  0%, 100% { box-shadow: 0 0 0 0 var(--urgent-glow); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

/* ── Pin Popover ─────────────────────────────────────────── */

.pin-popover {
  position: absolute; left: 50%; top: -8px; transform: translate(-50%, -100%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; min-width: 200px;
  z-index: 20; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.pop-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.pop-type { font-size: 11px; text-transform: uppercase; font-weight: 600; }
.pop-status { font-size: 11px; padding: 2px 6px; border-radius: 4px; }
.pop-status.urgent { background: var(--urgent-glow); color: var(--urgent); }
.pop-status.pending { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.pop-status.active { background: var(--accent-glow); color: var(--accent); }
.pop-title { font-weight: 600; margin-bottom: 4px; }
.pop-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.pop-amount { font-weight: 600; color: var(--gold); }
.pop-vendor { font-size: 12px; color: var(--text-muted); }

.pop-cluster-item { display: flex; gap: 8px; padding: 4px 0; font-size: 13px; }

/* ── Property Sections ───────────────────────────────────── */

.prop-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.prop-section h3 { font-size: 14px; margin-bottom: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.item-list { display: flex; flex-direction: column; gap: 6px; }

.item-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
}
.item-row.urgent { background: var(--urgent-glow); }

.item-type { font-size: 11px; color: var(--text-muted); text-transform: uppercase; width: 60px; }
.item-title { flex: 1; font-size: 13px; }
.item-amount { font-size: 13px; color: var(--gold); font-weight: 600; }
.item-status { font-size: 11px; padding: 2px 6px; border-radius: 4px; }

.stat-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.stat-row:last-child { border-bottom: none; }

.activity-list { display: flex; flex-direction: column; gap: 4px; }
.activity-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }
.activity-action { text-transform: capitalize; }

/* ── Room Detail ─────────────────────────────────────────── */

.room-detail { padding: 16px 0; }
.room-detail h3 { font-size: 16px; margin-bottom: 16px; }
.room-detail h4 { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; }

.room-items { margin-bottom: 16px; }

.room-item-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-bottom: 1px solid var(--border);
}
.room-item-row.urgent { background: var(--urgent-glow); }

.item-icon { font-size: 16px; width: 24px; text-align: center; }
.item-info { flex: 1; }
.item-info .item-title { font-weight: 500; }
.item-info .item-desc { font-size: 12px; color: var(--text-muted); display: block; }
.item-meta { text-align: right; }

.protocol-card {
  display: flex; gap: 10px; padding: 12px;
  background: var(--urgent-glow); border: 1px solid var(--urgent);
  border-radius: var(--radius); margin-bottom: 8px;
}
.protocol-icon { font-size: 20px; }
.protocol-card p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
.photo-thumb {
  aspect-ratio: 1; background-size: cover; background-position: center;
  border-radius: 6px; position: relative; overflow: hidden;
}
.photo-caption, .photo-date {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0, 0, 0, 0.7); font-size: 10px; padding: 2px 4px;
}
.photo-date { bottom: auto; top: 0; }

/* ── Overlay Toggle ──────────────────────────────────────── */

.overlay-toggle {
  position: absolute; top: 8px; right: 8px; z-index: 5;
  font-size: 12px;
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn-ghost {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  padding: 6px 12px; border-radius: var(--radius); cursor: pointer;
  font-size: 13px; transition: all 0.15s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.user-name { font-size: 13px; color: var(--text-muted); margin-right: 12px; }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
  #property-screen { flex-direction: column; }
  #property-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 12px; }
  .sidebar-list { flex-direction: row; overflow-x: auto; }
  .sidebar-card { white-space: nowrap; }
  #property-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  main { padding: 8px; }
  .auth-box { padding: 24px 16px; }
  .pin-popover { min-width: 160px; }
}
