/* KaiNest design system — tokens match the landing page */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --deep: #0a0f1a;
  --ocean: #0e1b2e;
  --surface: #142238;
  --foam: #1e3a5f;
  --teal: #2dd4bf;
  --teal-dim: rgba(45,212,191,0.15);
  --teal-border: rgba(45,212,191,0.25);
  --coral: #f97066;
  --sand: #f5f0e8;
  --text: #c8d6e5;
  --text-bright: #eef2f7;
  --text-muted: #6e8caa;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--deep);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
h1, h2, h3, h4, h5 { font-family: 'Space Grotesk', system-ui, sans-serif; color: var(--text-bright); }
a { color: var(--teal); text-decoration: none; }
a:hover { opacity: 0.85; }

/* ── APP SHELL ── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; min-height: 100vh;
  background: var(--ocean);
  border-right: 1px solid var(--teal-border);
  display: flex; flex-direction: column;
  padding: 1.5rem 0;
  flex-shrink: 0;
}
.sidebar-logo {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--teal-border);
  margin-bottom: 1rem;
}
.sidebar-logo .logo-word { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.3rem; color: var(--teal); }
.sidebar-logo .logo-word span { color: var(--text-bright); }
.sidebar-logo .logo-tag { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 2px; color: var(--text-muted); margin-top: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.65rem 1.5rem;
  color: var(--text); font-size: 0.9rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--teal-dim); color: var(--text-bright); }
.nav-item.active { background: var(--teal-dim); color: var(--teal); border-left-color: var(--teal); }
.nav-item svg { opacity: 0.7; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--coral);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--teal-border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ocean);
}
.topbar h1 { font-size: 1.2rem; font-weight: 600; }
.topbar-actions { display: flex; gap: 0.75rem; align-items: center; }

.page-body { padding: 2rem; flex: 1; overflow-y: auto; }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--teal-border);
  border-radius: 10px;
  padding: 1.5rem;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-title { font-size: 1rem; font-weight: 600; color: var(--text-bright); }

/* ── STATS ROW ── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--teal-border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.stat-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text-bright); font-family: 'Space Grotesk', sans-serif; }
.stat-value.teal { color: var(--teal); }
.stat-value.coral { color: var(--coral); }
.stat-value.success { color: var(--success); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 7px;
  font-size: 0.875rem; font-weight: 500;
  cursor: pointer; border: none;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--teal); color: #0a0f1a; }
.btn-primary:hover { opacity: 0.9; color: #0a0f1a; }
.btn-secondary { background: var(--foam); color: var(--text-bright); border: 1px solid var(--teal-border); }
.btn-secondary:hover { background: var(--teal-dim); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--teal-border); }
.btn-ghost:hover { background: var(--teal-dim); color: var(--text-bright); }
.btn-danger { background: rgba(248,113,113,0.15); color: var(--danger); border: 1px solid rgba(248,113,113,0.25); }
.btn-danger:hover { background: rgba(248,113,113,0.25); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── FORMS ── */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.4rem; }
.form-control {
  width: 100%;
  background: var(--ocean);
  border: 1px solid var(--teal-border);
  border-radius: 7px;
  padding: 0.6rem 0.9rem;
  color: var(--text-bright);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-dim); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.3rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ── MESSAGE LIST ── */
.message-list { display: flex; flex-direction: column; gap: 0.75rem; }
.message-item {
  background: var(--surface);
  border: 1px solid var(--teal-border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex; align-items: flex-start; gap: 1rem;
  transition: border-color 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.message-item:hover { border-color: var(--teal); background: rgba(45,212,191,0.03); }
.message-item.unread { border-left: 3px solid var(--coral); }

.message-avatar {
  width: 38px; height: 38px;
  background: var(--foam);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 700; color: var(--teal);
  flex-shrink: 0;
}
.message-body { flex: 1; min-width: 0; }
.message-meta { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.2rem; }
.message-name { font-weight: 600; font-size: 0.9rem; color: var(--text-bright); }
.message-property { font-size: 0.75rem; color: var(--teal); }
.message-time { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }
.message-preview { font-size: 0.85rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── STATUS BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-pending { background: rgba(251,191,36,0.15); color: var(--warning); }
.badge-replied { background: rgba(45,212,191,0.15); color: var(--teal); }
.badge-reviewed { background: rgba(52,211,153,0.15); color: var(--success); }

/* ── CONVERSATION BUBBLE ── */
.conversation { display: flex; flex-direction: column; gap: 1rem; }
.bubble { max-width: 80%; padding: 0.9rem 1.1rem; border-radius: 12px; font-size: 0.9rem; line-height: 1.6; }
.bubble-guest { background: var(--foam); border-bottom-left-radius: 4px; align-self: flex-start; }
.bubble-ai {
  background: var(--teal-dim);
  border: 1px solid var(--teal-border);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  white-space: pre-wrap;
}
.bubble-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 0.3rem; }
.bubble-guest .bubble-label { color: var(--text-muted); }
.bubble-ai .bubble-label { color: var(--teal); text-align: right; }

/* ── PROPERTY CARDS ── */
.property-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.property-card {
  background: var(--surface);
  border: 1px solid var(--teal-border);
  border-radius: 10px;
  padding: 1.25rem;
  transition: border-color 0.15s;
}
.property-card:hover { border-color: var(--teal); }
.property-card-name { font-size: 1rem; font-weight: 600; color: var(--text-bright); margin-bottom: 0.25rem; }
.property-card-address { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.property-card-actions { display: flex; gap: 0.5rem; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 4rem 2rem; }
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state h3 { color: var(--text-bright); margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-muted); font-size: 0.9rem; max-width: 360px; margin: 0 auto 1.5rem; }

/* ── ALERTS ── */
.alert { padding: 0.75rem 1rem; border-radius: 7px; font-size: 0.875rem; margin-bottom: 1rem; }
.alert-success { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.3); color: var(--success); }
.alert-error { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); color: var(--danger); }

/* ── LOADING ── */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--teal-border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TABS ── */
.tab-bar { display: flex; gap: 0; border-bottom: 1px solid var(--teal-border); margin-bottom: 1.5rem; }
.tab-btn {
  padding: 0.6rem 1.25rem;
  background: none; border: none;
  color: var(--text-muted); font-size: 0.875rem;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--text-bright); }
.tab-btn.active { color: var(--teal); border-bottom-color: var(--teal); }

/* ── GUEST FORM (public-facing) ── */
.guest-form-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem;
  background: var(--deep);
}
.guest-form-card {
  width: 100%; max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--teal-border);
  border-radius: 14px;
  padding: 2.5rem;
}
.guest-form-logo { text-align: center; margin-bottom: 2rem; }
.guest-form-logo .logo-word { font-family: 'Space Grotesk', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--teal); }
.guest-form-logo .logo-word span { color: var(--text-bright); }
.guest-form-logo p { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }

.reply-box {
  background: var(--ocean);
  border: 1px solid var(--teal-border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-top: 1.5rem;
  display: none;
}
.reply-box.visible { display: block; }
.reply-box-label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px;
  color: var(--teal); margin-bottom: 0.5rem;
}
.reply-box-text { font-size: 0.9rem; color: var(--text); line-height: 1.6; white-space: pre-wrap; }

/* ── MOBILE ── */
@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .page-body { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; min-height: auto; flex-direction: row; flex-wrap: wrap; }
}
