/* =========================================
   ProviOS / It's In Writing — Design System
   ========================================= */

:root {
  --bg: #F7F3EE;
  --bg-alt: #EFE9DF;
  --fg: #1C1917;
  --fg-muted: #6B6358;
  --accent: #1B4D4F;
  --accent-warm: #9B3A22;
  --border: #D4CFC7;
  --card-bg: #FDFBF8;
  --card-stroke: #D4CFC7;
  --success: #2D6A4F;
  --error: #9B3A22;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(28,25,23,0.08);
  --shadow-md: 0 4px 12px rgba(28,25,23,0.10);
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Instrument Sans', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Navigation */
.nav {
  padding: 18px 48px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.nav-logo em { font-style: italic; color: var(--fg-muted); font-weight: 400; }
.nav-right { display: flex; align-items: center; gap: 20px; }
.nav-link {
  font-size: 14px;
  color: var(--fg-muted);
  text-decoration: none;
  cursor: pointer;
}
.nav-link:hover { color: var(--fg); }

/* Hero / Page headers */
.page-header {
  padding: 48px 48px 32px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--fg);
  line-height: 1.1;
  margin-bottom: 12px;
}
.page-header p { font-size: 16px; color: var(--fg-muted); max-width: 540px; }

/* Content area */
.content { padding: 32px 48px 64px; max-width: 900px; margin: 0 auto; }

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-stroke);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
}
.card-subtitle { font-size: 13px; color: var(--fg-muted); margin-top: 2px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: #163d3f; }

.btn-secondary {
  background: var(--bg-alt);
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e8e2d8; }

.btn-warm {
  background: var(--accent-warm);
  color: white;
}
.btn-warm:hover { background: #7e2f1a; }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.form-input, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  background: white;
  color: var(--fg);
  transition: border-color 0.15s;
  appearance: none;
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(27,77,79,0.10);
}
.form-input::placeholder { color: #b5aea5; }

.form-hint { font-size: 12px; color: var(--fg-muted); margin-top: 4px; }
.form-error { font-size: 13px; color: var(--error); margin-top: 6px; font-weight: 500; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.badge-solicitor { background: #e8f0fe; color: #1a56db; }
.badge-mediator { background: #f0fdf4; color: #15803d; }
.badge-support { background: #fefce8; color: #a16207; }
.badge-pending { background: var(--bg-alt); color: var(--fg-muted); }
.badge-active { background: #f0fdf4; color: #15803d; }

/* Message thread */
.message-list { display: flex; flex-direction: column; gap: 16px; }
.message {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}
.message-remote { align-self: flex-start; }
.message-local { align-self: flex-end; }

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.message-sender { font-size: 12px; font-weight: 600; color: var(--fg-muted); }
.message-time { font-size: 11px; color: #b5aea5; }

.message-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.55;
}
.message-remote .message-bubble {
  background: white;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.message-local .message-bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

/* Conversation list */
.conv-list { display: flex; flex-direction: column; gap: 2px; }
.conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  color: var(--fg);
  transition: background 0.12s;
}
.conv-item:hover { background: var(--bg-alt); }
.conv-item.active { background: var(--bg-alt); border-left: 3px solid var(--accent); }
.conv-name { font-size: 15px; font-weight: 500; }
.conv-meta { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }

/* Alert / message banners */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 14px;
  font-size: 14px;
  border-bottom: 1px solid var(--bg-alt);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-alt); }

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* Two-column layout */
.two-col {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  min-height: calc(100vh - 65px);
}
.sidebar {
  border-right: 1px solid var(--border);
  padding: 24px 0;
  overflow-y: auto;
}
.sidebar-section { padding: 0 16px; margin-bottom: 24px; }
.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 10px;
  padding: 0 4px;
}

/* Practitioner portal specific */
.portal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.portal-badge {
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
}

/* Invite link box */
.invite-link-box {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  margin-top: 12px;
}
.invite-url { font-family: monospace; color: var(--accent); flex: 1; word-break: break-all; }

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

/* Responsive */
@media (max-width: 700px) {
  .nav { padding: 14px 20px; }
  .page-header { padding: 32px 20px 24px; }
  .content { padding: 24px 20px 48px; }
  .two-col { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}