/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --primary: #0288D1;
  --primary-light: #4FC3F7;
  --primary-lighter: #E1F5FE;
  --primary-dark: #01579B;
  --sidebar-width: 240px;
  --sidebar-bg: #01579B;
  --topbar-h: 60px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Reset & Base ────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
body { font-family: var(--font); background: #F0F4F8; color: #1a2332; margin: 0; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-width); height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 1000; transition: transform .25s ease;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 20px 20px 16px;
  font-size: 1.3rem; font-weight: 700;
  color: #fff; border-bottom: 1px solid rgba(255,255,255,.15);
  display: flex; align-items: center;
}
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav .nav-link,
.sidebar-footer .nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: rgba(255,255,255,.8);
  text-decoration: none; font-size: .9rem;
  border-radius: 0; transition: background .15s, color .15s;
}
.sidebar-nav .nav-link:hover,
.sidebar-footer .nav-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-nav .nav-link.active {
  background: rgba(255,255,255,.2); color: #fff; font-weight: 600;
  border-left: 3px solid var(--primary-light);
}
.sidebar-nav .nav-link i,
.sidebar-footer .nav-link i { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar-footer { padding: 12px 0; border-top: 1px solid rgba(255,255,255,.15); }

/* ── Main wrapper ────────────────────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh; display: flex; flex-direction: column;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; padding: 0 24px;
  position: sticky; top: 0; z-index: 900;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar-title { font-weight: 600; font-size: 1rem; color: #475569; }
.topbar-user { font-size: .875rem; color: #64748b; display: flex; align-items: center; }
.sidebar-toggle { background: none; border: none; cursor: pointer; padding: 4px 8px; margin-right: 12px; color: #64748b; }

/* ── Page content ────────────────────────────────────────────────────────── */
.page-content { flex: 1; padding: 28px 28px; }

/* ── KPI Cards ───────────────────────────────────────────────────────────── */
.kpi-card {
  border-radius: 12px; padding: 20px;
  display: flex; align-items: center; gap: 16px;
  color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.kpi-blue  { background: linear-gradient(135deg, #0288D1, #4FC3F7); }
.kpi-green { background: linear-gradient(135deg, #2E7D32, #66BB6A); }
.kpi-red   { background: linear-gradient(135deg, #C62828, #EF5350); }
.kpi-orange{ background: linear-gradient(135deg, #E65100, #FFA726); }
.kpi-icon { font-size: 2rem; opacity: .85; }
.kpi-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.kpi-label { font-size: .85rem; opacity: .9; margin-top: 2px; }
.kpi-sub   { font-size: .75rem; opacity: .75; margin-top: 2px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card { border: none; border-radius: 12px; }
.card-header { border-radius: 12px 12px 0 0 !important; border-bottom: 1px solid #f1f5f9; }

/* ── Unit cards ──────────────────────────────────────────────────────────── */
.unit-card { border-radius: 12px; transition: transform .15s, box-shadow .15s; }
.unit-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1) !important; }
.unit-occupied { border-left: 4px solid #66BB6A; }
.unit-vacant   { border-left: 4px solid #90A4AE; }
.tenant-chip {
  background: var(--primary-lighter); border-radius: 20px;
  padding: 4px 12px; font-size: .85rem; display: inline-flex; align-items: center;
}

/* ── Tenant avatar ───────────────────────────────────────────────────────── */
.tenant-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 1.4rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.urgency-low    { background: #E8F5E9 !important; color: #2E7D32 !important; }
.urgency-medium { background: #FFF8E1 !important; color: #F57F17 !important; }
.urgency-high   { background: #FFEBEE !important; color: #C62828 !important; }
.status-open        { background: #E3F2FD !important; color: #0D47A1 !important; }
.status-in_progress { background: #FFF3E0 !important; color: #E65100 !important; }
.status-resolved    { background: #E8F5E9 !important; color: #1B5E20 !important; }

/* ── Status circles (tenant dashboard) ──────────────────────────────────── */
.status-circle {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.status-paid    { background: #E8F5E9; color: #2E7D32; }
.status-pending { background: #FFF8E1; color: #F57F17; }
.status-late    { background: #FFEBEE; color: #C62828; }

/* ── Ticket cards ────────────────────────────────────────────────────────── */
.ticket-card { transition: transform .15s, box-shadow .15s; cursor: pointer; }
.ticket-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1) !important; }

/* ── Comment thread ──────────────────────────────────────────────────────── */
.comment-item { padding: 14px 20px; border-bottom: 1px solid #f1f5f9; }
.comment-item:last-child { border-bottom: none; }
.comment-admin  { background: #F0F9FF; }
.comment-tenant { background: #fff; }
.comment-meta   { font-size: .8rem; color: #64748b; margin-bottom: 4px; }
.comment-body   { font-size: .9rem; white-space: pre-line; }

/* ── Chat ────────────────────────────────────────────────────────────────── */
.chat-container { border-radius: 12px; }
.chat-messages  { height: 420px; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; background: #F8FAFC; }
.chat-bubble    { max-width: 70%; padding: 10px 14px; border-radius: 12px; }
.bubble-sent    { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.bubble-received{ align-self: flex-start; background: #fff; border: 1px solid #e2e8f0; border-bottom-left-radius: 4px; }
.chat-subject   { font-size: .75rem; font-weight: 600; opacity: .75; margin-bottom: 3px; }
.chat-text      { font-size: .9rem; white-space: pre-line; }
.chat-time      { font-size: .7rem; opacity: .6; margin-top: 4px; text-align: right; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; background: linear-gradient(135deg, #01579B 0%, #0288D1 50%, #4FC3F7 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-icon   { font-size: 3rem; color: var(--primary); }
.login-title  { font-size: 1.8rem; font-weight: 700; color: #1a2332; margin: 8px 0 4px; }
.login-subtitle { color: #64748b; margin: 0; }
.btn-login    { background: var(--primary); border-color: var(--primary); padding: 10px; font-size: 1rem; font-weight: 600; }
.btn-login:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .page-content { padding: 16px; }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 1.4rem; }
}
