/* PropHQ Shared Styles - Matches landing page dark theme */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:wght@400;500&display=swap');

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

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface-hover: #18182a;
  --border: #1e1e2a;
  --border-focus: #2a2a3a;
  --text: #e8e8ed;
  --muted: #8888a0;
  --accent: #4ade80;
  --accent-dim: #22c55e;
  --accent-bg: rgba(74, 222, 128, 0.08);
  --warm: #f59e0b;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --info: #3b82f6;
  --radius: 10px;
  --radius-sm: 6px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  line-height: 1.15;
}

/* Grain overlay */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1000;
}

/* ─── FORMS ──────────────────────────────── */

.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group textarea { resize: vertical; min-height: 100px; }

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238888a0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ─── BUTTONS ────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #0a0a0f;
}

.btn-primary:hover { background: var(--accent-dim); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-focus); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.15); }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
}
.btn-ghost:hover { color: var(--text); background: var(--surface); }

/* ─── CARDS ──────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-header h3 {
  font-size: 1.1rem;
  letter-spacing: -0.3px;
}

/* ─── STAT CARDS ─────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .stat-icon {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.stat-card .stat-number {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ─── BADGES ─────────────────────────────── */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-green { background: rgba(74, 222, 128, 0.15); color: var(--accent); }
.badge-yellow { background: rgba(245, 158, 11, 0.15); color: var(--warm); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-blue { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge-muted { background: rgba(136, 136, 160, 0.15); color: var(--muted); }

/* ─── TABLE ──────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ─── LAYOUT: AUTH PAGES ─────────────────── */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-box {
  width: 100%;
  max-width: 420px;
}

.auth-box .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 40px;
}

.auth-box .logo span { color: var(--accent); }

.auth-box h2 {
  font-size: 1.6rem;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.auth-box .subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 32px;
}

.auth-box .btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  justify-content: center;
}

.auth-box .auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-box .auth-footer a {
  color: var(--accent);
  text-decoration: none;
}

.auth-error {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 20px;
  display: none;
}

/* ─── LAYOUT: DASHBOARD ─────────────────── */

.dashboard {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 0 24px;
  margin-bottom: 32px;
}

.sidebar .logo span { color: var(--accent); }

.sidebar-nav { flex: 1; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}

.sidebar-nav a.active {
  color: var(--accent);
  background: var(--accent-bg);
  border-left-color: var(--accent);
}

.sidebar-nav a .nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar-nav a .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-user {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.sidebar-user .user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user .user-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-email {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  max-height: 100vh;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.8rem;
  letter-spacing: -0.5px;
}

.page-header .subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ─── EMPTY STATE ────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.2rem;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
  max-width: 400px;
  margin: 0 auto 20px;
}

/* ─── MESSAGE THREAD ─────────────────────── */

.message-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 500px;
  overflow-y: auto;
  padding: 16px 0;
}

.message-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.message-bubble.tenant {
  background: var(--surface);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.message-bubble.landlord {
  background: var(--accent-bg);
  border: 1px solid rgba(74, 222, 128, 0.2);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message-bubble.ai {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message-bubble .message-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 6px;
}

.message-input-area {
  display: flex;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.message-input-area input {
  flex: 1;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
}

.message-input-area input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ─── AI SUGGESTION BOX ──────────────────── */

.ai-suggestion {
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}

.ai-suggestion .ai-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--info);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.ai-suggestion .ai-text {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
}

.ai-suggestion .ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ─── MODAL ──────────────────────────────── */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 24px;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
}

.modal h2 {
  font-size: 1.3rem;
  margin-bottom: 24px;
  letter-spacing: -0.3px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ─── COPY LINK ──────────────────────────── */

.copy-link {
  display: flex;
  gap: 8px;
  align-items: center;
}

.copy-link input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.8rem;
  font-family: monospace;
}

/* ─── PORTAL LAYOUT ──────────────────────── */

.portal-nav {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.portal-nav .container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.portal-nav .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.portal-nav .logo span { color: var(--accent); }

.portal-nav .tenant-info {
  font-size: 0.85rem;
  color: var(--muted);
}

.portal-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 24px;
}

.portal-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.portal-tabs button {
  padding: 12px 20px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
}

.portal-tabs button:hover { color: var(--text); }

.portal-tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ─── TOAST ──────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 0.9rem;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { border-color: rgba(74, 222, 128, 0.3); }
.toast.error { border-color: rgba(239, 68, 68, 0.3); }

/* ─── RESPONSIVE ─────────────────────────── */

@media (max-width: 768px) {
  .dashboard { flex-direction: column; }
  .sidebar {
    width: 100%;
    padding: 12px 0;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .logo { margin-bottom: 0; padding: 0 16px; }
  .sidebar-nav { display: flex; }
  .sidebar-nav a {
    padding: 8px 16px;
    border-left: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
  }
  .sidebar-nav a.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }
  .sidebar-nav a .nav-icon { display: none; }
  .sidebar-user { display: none; }
  .main-content { padding: 20px 16px; max-height: none; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .message-bubble { max-width: 90%; }
}

/* ─── LOADING ────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── CONVERSATION LIST ──────────────────── */

.conversation-list {
  display: flex;
  flex-direction: column;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.conversation-item:hover { background: rgba(255,255,255,0.02); }

.conversation-item.unread { background: var(--accent-bg); }

.conversation-item .conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.conversation-item .conv-info { flex: 1; min-width: 0; }

.conversation-item .conv-name {
  font-weight: 500;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
}

.conversation-item .conv-preview {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item .conv-time {
  font-size: 0.75rem;
  color: var(--muted);
}

.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
