/* ============================================================
   PG Rent Manager — Design System
   Signature element: the floor-plan grid. Rooms are drawn as literal
   squares (a blueprint pinned on the office wall), split into bed
   segments so occupancy reads at a glance — vacant is an open outline,
   occupied is filled ledger-green.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800;900&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --paper: #faf9f6;
  --paper-dim: #f1efe9;
  --ink: #14151a;
  --ink-soft: #565a63;
  --line: #dfdcd3;

  --ledger: #2f6b45;      /* occupied / positive */
  --ledger-dim: #e5efe7;
  --amber: #b9790a;       /* partial occupancy / attention */
  --amber-dim: #f6ecd9;
  --rose: #a8392f;        /* overdue / destructive */
  --rose-dim: #f5e6e3;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --shadow: 0 1px 2px rgba(20, 21, 26, 0.06), 0 8px 24px rgba(20, 21, 26, 0.06);

  --font-display: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
button { font-family: var(--font-body); cursor: pointer; }
a { color: inherit; }
::selection { background: var(--ledger-dim); }

:focus-visible {
  outline: 2px solid var(--ledger);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.mono { font-family: var(--font-mono); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #2a2b32; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-danger { background: var(--rose-dim); color: var(--rose); }
.btn-danger:hover { background: #efd6d2; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Form elements ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--ink); }
.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.error-text { font-size: 13px; color: var(--rose); margin-top: 8px; }

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.login-side, .login-main { min-width: 0; }
.login-side {
  background: var(--ink);
  color: var(--paper);
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-side .brand { font-family: var(--font-display); font-weight: 800; font-size: 20px; }
.login-side .brand span { color: #8fae95; }
.login-side .pitch h1 {
  font-size: clamp(26px, 3vw, 42px);
  font-weight: 800;
  line-height: 1.15;
  max-width: 100%;
  overflow-wrap: break-word;
}
.login-side .pitch p { margin-top: 16px; color: #c7c9d1; font-size: 15px; max-width: 420px; line-height: 1.6; overflow-wrap: break-word; }
.blueprint-decor {
  position: absolute;
  right: -60px;
  bottom: -60px;
  width: 420px;
  height: 420px;
  opacity: 0.5;
}
.login-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 24px; margin-bottom: 6px; }
.login-card .sub { color: var(--ink-soft); font-size: 14px; margin-bottom: 28px; }
.role-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--paper-dim);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}
.role-toggle button {
  border: none;
  background: transparent;
  padding: 9px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.role-toggle button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.demo-creds { margin-top: 20px; font-size: 12px; color: var(--ink-soft); background: var(--paper-dim); border-radius: var(--radius-sm); padding: 10px 12px; }

@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-side { display: none; }
}

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--ink);
  color: var(--paper);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.sidebar .brand { font-family: var(--font-display); font-weight: 800; font-size: 17px; padding: 0 8px; }
.sidebar .brand span { color: #8fae95; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; color: #c7c9d1;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar-foot { margin-top: auto; }
.who-chip { font-size: 12px; color: #9a9ea8; padding: 10px 10px; border-top: 1px solid rgba(255,255,255,0.1); }
.who-chip strong { color: #fff; display: block; font-size: 13px; }

.main {
  padding: 28px 36px 60px;
  overflow-y: auto;
  max-width: 100%;
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }

/* ---------- Tabs (properties / floors) ---------- */
.tab-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.tab-chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.tab-chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tab-chip.add { border-style: dashed; }

/* ---------- Legend ---------- */
.legend { display: flex; gap: 18px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.legend-swatch { width: 13px; height: 13px; border-radius: 3px; }
.legend-swatch.vacant { border: 1.5px dashed var(--line); }
.legend-swatch.occupied { background: var(--ledger); }
.legend-swatch.partial { background: linear-gradient(135deg, var(--ledger) 50%, var(--paper-dim) 50%); border: 1.5px solid var(--line); }

/* ---------- Floor-plan room grid (signature element) ---------- */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 14px;
}
.room-square {
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: #fff;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.room-square:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.room-square .room-number { font-family: var(--font-mono); font-weight: 600; font-size: 13px; color: var(--ink-soft); }
.bed-strip { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.bed-seg {
  flex: 1;
  border-radius: 5px;
  border: 1.5px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: center;
  padding: 4px;
  background: var(--paper);
}
.bed-seg.occupied {
  border-style: solid;
  border-color: var(--ledger);
  background: var(--ledger-dim);
  color: var(--ledger);
  flex-direction: column;
  gap: 1px;
}
.bed-seg .t-name { font-family: var(--font-body); font-size: 11.5px; font-weight: 700; }
.bed-seg .t-rent { font-family: var(--font-mono); font-size: 10.5px; opacity: 0.85; }
.add-room-square {
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 1.5px dashed var(--line);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 28px;
  font-weight: 300;
}
.add-room-square:hover { border-color: var(--ink); color: var(--ink); }

/* ---------- Cards / stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat-card .label { font-size: 12px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { font-family: var(--font-mono); font-size: 26px; font-weight: 600; margin-top: 6px; }
.stat-card .value.green { color: var(--ledger); }
.stat-card .value.amber { color: var(--amber); }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); padding: 10px 12px; border-bottom: 1.5px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
.pill { display: inline-flex; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.cash { background: var(--amber-dim); color: var(--amber); }
.pill.online { background: var(--ledger-dim); color: var(--ledger); }

/* ---------- Modal / slide-over ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(20,21,26,0.4);
  display: none; align-items: stretch; justify-content: flex-end; z-index: 50;
}
.overlay.open { display: flex; }
.panel {
  width: 440px; max-width: 100%; background: var(--paper);
  height: 100%; overflow-y: auto; padding: 28px;
  box-shadow: -12px 0 40px rgba(0,0,0,0.15);
  animation: slidein 0.22s ease;
}
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.panel-head h2 { font-size: 19px; }
.panel-close { background: none; border: none; font-size: 20px; color: var(--ink-soft); line-height: 1; }
.panel-close:hover { color: var(--ink); }

.center-modal { align-items: center; justify-content: center; }
.center-panel { width: 420px; max-width: calc(100% - 32px); height: auto; border-radius: var(--radius-lg); animation: popin 0.16s ease; }
@keyframes popin { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: var(--paper);
  padding: 12px 18px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); z-index: 100; opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--rose); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty-state h3 { color: var(--ink); margin-bottom: 8px; }

/* ---------- Language toggle ---------- */
.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.lang-toggle button {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}
.lang-toggle button.active { background: var(--ink); color: var(--paper); }
.lang-toggle.on-dark { border-color: rgba(255,255,255,0.25); }
.lang-toggle.on-dark button { color: #c7c9d1; }
.lang-toggle.on-dark button.active { background: rgba(255,255,255,0.14); color: #fff; }
.login-topbar { position: absolute; top: 24px; right: 24px; z-index: 5; }
.sidebar-lang { margin-bottom: 4px; }

/* ---------- Mic / speech-to-text ---------- */
.input-with-mic { display: flex; gap: 8px; align-items: stretch; }
.input-with-mic input, .input-with-mic textarea { flex: 1; }
.mic-btn {
  flex-shrink: 0;
  width: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--ink-soft);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.mic-btn:hover { border-color: var(--ink); color: var(--ink); }
.mic-btn.listening {
  background: var(--rose-dim);
  border-color: var(--rose);
  color: var(--rose);
  animation: mic-pulse 1.1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168, 57, 47, 0.25); }
  50% { box-shadow: 0 0 0 6px rgba(168, 57, 47, 0); }
}

.settings-section { margin-bottom: 26px; }
.settings-section:last-child { margin-bottom: 0; }
.settings-section h3 { font-size: 15px; margin-bottom: 14px; }
.success-text { font-size: 13px; color: var(--ledger); margin-top: 8px; }

/* ---------- Dashboard: collection bar ---------- */
.collection-bar {
  height: 18px;
  border-radius: 999px;
  background: var(--amber-dim);
  overflow: hidden;
}
.collection-bar-paid {
  height: 100%;
  background: var(--ledger);
  border-radius: 999px 0 0 999px;
  transition: width 0.3s ease;
  min-width: 2px;
}

/* ---------- Tags editor ---------- */
.tag-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 10px;
  cursor: pointer;
}
.tag-check-row input { width: auto; }
.tag-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--paper-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 12px;
  font-weight: 600;
}
.tag-chip button {
  border: none;
  background: none;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 50%;
}
.tag-chip button:hover { background: var(--rose-dim); color: var(--rose); }
.pill-tag {
  display: inline-block;
  background: var(--ledger-dim);
  color: var(--ledger);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  margin: 2px 3px 2px 0;
}
.row-actions { display: flex; gap: 6px; }

@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; padding: 14px 16px; }
  .sidebar-foot { display: none; }
  .nav-group { flex-direction: row; }
  .main { padding: 20px; }
}
