/* portal.css — client portal design system
 * Palette: charcoal #1F2326, navy #0a0e17, champagne gold #C8B88F
 * Typography: Playfair Display (headings), Libre Franklin (body)
 */

/* ─── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0a0e17;
  --surface:      #131820;
  --surface-2:    #1a2130;
  --surface-3:    #1f2736;
  --border:       rgba(200, 184, 143, 0.12);
  --border-mid:   rgba(200, 184, 143, 0.25);
  --border-strong:rgba(200, 184, 143, 0.45);
  --text:         #e8edf4;
  --text-muted:   #8899aa;
  --text-dim:     #5a6a7a;
  --accent:       #C8B88F;
  --accent-dim:   rgba(200,184,143,0.12);
  --accent-hover: #D6C9A8;
  --success:      #4ade80;
  --success-dim:  rgba(74,222,128,0.1);
  --warning:      #fbbf24;
  --warning-dim:  rgba(251,191,36,0.1);
  --error:        #f87171;
  --error-dim:    rgba(248,113,113,0.1);
  --info:         #60a5fa;
  --sidebar-w:    240px;
  --radius:       8px;
  --radius-lg:    12px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Libre Franklin', 'Inter', -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: 'Playfair Display', Georgia, serif;
  color: var(--text);
  line-height: 1.3;
}

/* ─── Layout shell ──────────────────────────────────────────────────────────── */
.portal-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
.portal-sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.sidebar-brand-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 0.15rem;
}

.sidebar-user {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.sidebar-nav {
  padding: 0.75rem 0;
  flex: 1;
}

.sidebar-section {
  padding: 0.5rem 1.25rem 0.25rem;
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.6rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
  cursor: pointer;
  text-decoration: none;
}

.sidebar-link:hover { color: var(--text); background: var(--accent-dim); text-decoration: none; }
.sidebar-link.active { color: var(--accent); background: var(--accent-dim); }
.sidebar-link .icon { width: 16px; text-align: center; flex-shrink: 0; }

.sidebar-badge {
  margin-left: auto;
  background: var(--error);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 0.1rem 0.4rem;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.sidebar-logout {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  transition: color 0.15s;
}
.sidebar-logout:hover { color: var(--error); text-decoration: none; }

/* ─── Main content area ─────────────────────────────────────────────────────── */
.portal-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.portal-topbar {
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.topbar-actions { display: flex; gap: 0.75rem; align-items: center; }

.portal-content {
  padding: 2rem;
  flex: 1;
  max-width: 1200px;
}

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

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

.card-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  font-family: 'Libre Franklin', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn-primary { background: var(--accent); color: #0a0e17; }
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; color: #0a0e17; }

.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-mid); }
.btn-secondary:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.btn-danger { background: var(--error-dim); color: var(--error); border: 1px solid rgba(248,113,113,0.3); }
.btn-danger:hover { background: rgba(248,113,113,0.2); text-decoration: none; color: var(--error); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }

/* ─── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-discovery  { background: rgba(96,165,250,0.12); color: var(--info); }
.badge-assessment { background: rgba(251,191,36,0.12); color: var(--warning); }
.badge-implementation { background: rgba(200,184,143,0.12); color: var(--accent); }
.badge-review     { background: rgba(167,139,250,0.12); color: #a78bfa; }
.badge-complete   { background: var(--success-dim); color: var(--success); }
.badge-active     { background: var(--success-dim); color: var(--success); }
.badge-inactive   { background: var(--error-dim); color: var(--error); }
.badge-draft      { background: rgba(148,163,184,0.1); color: var(--text-muted); }
.badge-sent       { background: rgba(96,165,250,0.12); color: var(--info); }
.badge-paid       { background: var(--success-dim); color: var(--success); }
.badge-void       { background: var(--error-dim); color: var(--error); }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.form-label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); letter-spacing: 0.03em; text-transform: uppercase; }
.form-input, .form-select, .form-textarea {
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Libre Franklin', sans-serif;
  font-size: 0.9rem;
  padding: 0.65rem 0.9rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-select { cursor: pointer; }
.form-hint { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ─── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  border: 1px solid;
}
.alert-error   { background: var(--error-dim); border-color: rgba(248,113,113,0.3); color: var(--error); }
.alert-success { background: var(--success-dim); border-color: rgba(74,222,128,0.3); color: var(--success); }
.alert-info    { background: rgba(96,165,250,0.08); border-color: rgba(96,165,250,0.25); color: var(--info); }
.alert-warning { background: var(--warning-dim); border-color: rgba(251,191,36,0.3); color: var(--warning); }

/* ─── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(200,184,143,0.03); }

/* ─── KPI grid ───────────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}
.kpi-label { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.kpi-value { font-size: 1.75rem; font-weight: 700; color: var(--accent); margin-top: 0.3rem; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ─── Project stages (Kanban-style) ─────────────────────────────────────────── */
.stage-bar {
  display: flex;
  align-items: stretch;
  gap: 2px;
  border-radius: var(--radius);
  overflow: hidden;
  height: 6px;
  background: var(--surface-2);
  margin: 0.5rem 0 1rem;
}
.stage-segment { flex: 1; }
.stage-discovery    { background: var(--info); }
.stage-assessment   { background: var(--warning); }
.stage-implementation { background: var(--accent); }
.stage-review       { background: #a78bfa; }
.stage-complete     { background: var(--success); }
.stage-segment.inactive { opacity: 0.2; }

/* ─── Messages thread ────────────────────────────────────────────────────────── */
.messages-thread { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.25rem; max-height: 500px; overflow-y: auto; padding-right: 0.25rem; }
.message {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}
.message.from-admin { align-self: flex-start; }
.message.from-client { align-self: flex-end; }
.message-bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.from-admin .message-bubble  { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; color: var(--text); }
.from-client .message-bubble { background: var(--accent-dim); border: 1px solid var(--border-mid); border-bottom-right-radius: 4px; color: var(--text); }
.message-meta { font-size: 0.7rem; color: var(--text-dim); margin-top: 0.25rem; }
.from-client .message-meta { text-align: right; }

/* ─── Login page ─────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(200,184,143,0.07) 0%, transparent 65%), var(--bg);
  padding: 2rem;
}
.login-box {
  width: 100%;
  max-width: 400px;
}
.login-brand {
  margin-bottom: 2rem;
}
.login-brand-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}
.login-brand-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.login-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.login-subtitle { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 2rem; }

/* ─── Deliverables grid ──────────────────────────────────────────────────────── */
.deliverables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.deliverable-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.deliverable-icon { font-size: 1.5rem; }
.deliverable-title { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.deliverable-meta { font-size: 0.75rem; color: var(--text-dim); }

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}
.empty-state-icon { font-size: 2rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state-text { font-size: 0.9rem; }

/* ─── Section header ─────────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.section-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

/* ─── Project list cards ─────────────────────────────────────────────────────── */
.project-cards { display: flex; flex-direction: column; gap: 0.75rem; }
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 1rem;
  align-items: center;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.project-card:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
.project-card-name { font-weight: 600; color: var(--text); font-size: 0.95rem; }
.project-card-meta { font-size: 0.78rem; color: var(--text-muted); }

/* ─── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab {
  padding: 0.65rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  transition: color 0.15s;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ─── QR code area ───────────────────────────────────────────────────────────── */
.qr-wrap { text-align: center; padding: 1.5rem; background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--border); }
.qr-img { background: #fff; padding: 0.75rem; border-radius: var(--radius); display: inline-block; }
.qr-secret { font-family: monospace; font-size: 0.8rem; color: var(--text-muted); word-break: break-all; margin-top: 0.75rem; background: var(--surface-3); padding: 0.5rem 0.75rem; border-radius: 4px; }

/* ─── Invoice amount ─────────────────────────────────────────────────────────── */
.amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.amount-large { font-size: 1.4rem; color: var(--accent); }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .portal-sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .portal-main { margin-left: 0; }
  .portal-content { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .deliverables-grid { grid-template-columns: 1fr; }
}

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

/* ─── Meeting note markdown content ─────────────────────────────────────────── */
.note-content h1, .note-content h2, .note-content h3 {
  font-family: 'Playfair Display', Georgia, serif;
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
}
.note-content p { margin-bottom: 0.75rem; }
.note-content ul, .note-content ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.note-content li { margin-bottom: 0.25rem; }
.note-content code { background: var(--surface-3); padding: 0.1rem 0.35rem; border-radius: 3px; font-size: 0.85em; }
