/* IRP Compliance — Partner Dashboard Styles
   US-014: login view, stats bar, client table, score pills
   ================================================================ */

/* ── Reset / base ─────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  background: var(--gray-50);
  line-height: var(--line-height-normal);
}

/* ── Login view ───────────────────────────────────────────────── */

#view-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl);
}

.login-card {
  background: var(--background);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  box-shadow: none;
  padding: var(--spacing-2xl);
  width: 100%;
  max-width: 440px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xl);
}

.login-logo img {
  height: 32px;
  width: auto;
}

.login-logo__wordmark {
  font-family: var(--font-mono);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-title {
  font-family: var(--font-display);
  font-size: var(--font-size-2xl);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  margin: 0 0 var(--spacing-xs);
  color: var(--text-primary);
  line-height: 1.15;
}

.login-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 var(--spacing-xl);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.form-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--spacing-sm);
}

.form-input {
  width: 100%;
  padding: 12px var(--spacing-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--background);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-input:focus {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(25, 25, 25, 0.06);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  height: 48px;
  padding: 0 var(--spacing-lg);
  background: var(--accent-color);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  border: 1px solid var(--accent-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  width: 100%;
}

.btn-primary:hover  { background: #fff; border-color: var(--accent-color); color: var(--accent-color); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: default; transform: none; }

.login-status {
  font-size: var(--font-size-sm);
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  display: none;
}

.login-status:not(:empty)          { display: block; }
.login-status--success             { background: #ECFDF5; color: #065F46; }
.login-status--error               { background: #FEF2F2; color: #991B1B; }

/* ── Dashboard shell ──────────────────────────────────────────── */

#view-dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ──────────────────────────────────────────────────── */

.dash-topbar {
  background: var(--primary-color);
  color: #fff;
  padding: 0 var(--spacing-xl);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.dash-topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
}

.dash-topbar__brand img {
  height: 28px;
  width: auto;
  border-radius: 50%;
}

.dash-topbar__sep {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
}

.dash-topbar__partner {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: var(--font-size-xs);
  color: rgba(255,255,255,0.75);
  overflow: hidden;
}

.dash-topbar__partner-name {
  color: #fff;
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

.dash-topbar__partner-email {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-shrink: 0;
}

.btn-ghost {
  padding: 6px var(--spacing-md);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.85);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.5);
  color: #fff;
}

/* ── Page content ─────────────────────────────────────────────── */

.dash-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: var(--spacing-xl) var(--spacing-xl) var(--spacing-2xl);
}

/* ── Page header ──────────────────────────────────────────────── */

.dash-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
  flex-wrap: wrap;
}
.dash-page-header__art {
  width: 140px;
  height: 140px;
  flex-shrink: 0;
  pointer-events: none;
}
.dash-page-header__art img { width: 100%; height: 100%; opacity: 0.6; }
@media (max-width: 720px) { .dash-page-header__art { display: none; } }

.dash-page-header__title {
  font-family: var(--font-display);
  font-size: var(--font-size-3xl);
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 var(--spacing-xs);
  letter-spacing: var(--tracking-tight);
  line-height: 1.1;
}

.dash-page-header__sub {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0;
}

/* ── Deadline banner ──────────────────────────────────────────── */

.deadline-banner {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  background: var(--surface-paper);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--accent-warm);
  border-radius: var(--radius-sm);
  padding: var(--spacing-md);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xl);
}

.deadline-banner__icon { color: var(--accent-warm); font-size: 16px; flex-shrink: 0; }

.deadline-banner strong {
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Stats bar ────────────────────────────────────────────────── */

.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-bottom: var(--spacing-xl);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.stat-card {
  background: transparent;
  border: 0;
  border-right: 1px solid var(--rule);
  border-radius: 0;
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  box-shadow: none;
}
.stat-card:last-child { border-right: 0; }

.stat-card__label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-mono);
  color: var(--text-tertiary);
}

.stat-card__value {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: var(--tracking-display);
}

.stat-card--critical .stat-card__value { color: var(--danger-color); }
.stat-card--atrisk   .stat-card__value { color: var(--warning-color); }

.stat-card__hint {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ── Section card ─────────────────────────────────────────────── */

.dash-section {
  background: var(--background);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  box-shadow: none;
  margin-bottom: var(--spacing-lg);
  overflow: hidden;
}

.dash-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--rule);
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.dash-section__title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0;
}

/* ── Invite section ───────────────────────────────────────────── */

.invite-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  flex-wrap: wrap;
}

.invite-url-preview {
  font-size: var(--font-size-sm);
  font-family: var(--font-mono);
  color: var(--text-secondary);
  background: var(--gray-50);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px var(--spacing-md);
  flex: 1;
  min-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: 7px var(--spacing-md);
  background: var(--gray-100);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-secondary:hover { background: var(--gray-200); }

/* ── Client table ─────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
}

.clients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.clients-table thead th {
  text-align: left;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--gray-50);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  user-select: none;
}

.clients-table thead th[data-sort] {
  cursor: pointer;
}

.clients-table thead th[data-sort]:hover {
  color: var(--text-primary);
}

.clients-table thead th[data-sort]::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 4px;
  vertical-align: middle;
  opacity: 0.3;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 2l3 4H3l3-4zm0 8L3 6h6l-3 4z' fill='%236B7280'/%3E%3C/svg%3E") no-repeat center;
}

.clients-table thead th.sort-asc::after {
  opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 2l3 4H3l3-4z' fill='%233B82F6'/%3E%3C/svg%3E");
}

.clients-table thead th.sort-desc::after {
  opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 10L3 6h6l-3 4z' fill='%233B82F6'/%3E%3C/svg%3E");
}

.clients-table tbody td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

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

/* Row left-border accent by score */
.client-row {
  transition: background 0.1s;
}

.client-row:hover,
.client-row:focus-visible { background: var(--gray-50); outline: 2px solid var(--accent-color); outline-offset: -2px; }

.client-row.score-critical { border-left: 3px solid var(--danger-color); }
.client-row.score-atrisk   { border-left: 3px solid var(--warning-color); }
.client-row.score-moderate { border-left: 3px solid #F59E0B; }
.client-row.score-good     { border-left: 3px solid var(--success-color); }

/* Empty state */
.table-empty {
  text-align: center;
  padding: var(--spacing-2xl) var(--spacing-xl) !important;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

/* Company cell */
.col-company { min-width: 180px; }

.company-name {
  display: block;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.company-email {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Score pill */
.score-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.02em;
}

.score-pill.score-critical { background: #FEE2E2; color: #991B1B; }
.score-pill.score-atrisk   { background: #FEF3C7; color: #92400E; }
.score-pill.score-moderate { background: #FEF9C3; color: #713F12; }
.score-pill.score-good     { background: #D1FAE5; color: #065F46; }

/* AI role badge */
.airole-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  background: var(--gray-100);
  color: var(--text-secondary);
  white-space: nowrap;
}

.airole-provider { background: #EDE9FE; color: #5B21B6; }
.airole-deployer { background: #DBEAFE; color: #1E40AF; }
.airole-user     { background: #D1FAE5; color: #065F46; }
.airole-both, .airole-all { background: #FEE2E2; color: #991B1B; }

/* Col widths */
.col-role     { min-width: 120px; color: var(--text-secondary); }
.col-airole   { min-width: 100px; }
.col-score    { min-width: 90px; }
.col-maturity { min-width: 120px; color: var(--text-secondary); }
.col-fine     { min-width: 160px; font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--danger-color); white-space: nowrap; }
.col-date     { min-width: 100px; color: var(--text-secondary); white-space: nowrap; }

/* ── Footer ───────────────────────────────────────────────────── */

.dash-footer {
  text-align: center;
  padding: var(--spacing-xl);
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-color);
  background: var(--background);
}

/* ── Detail drawer ────────────────────────────────────────────── */

.client-row { cursor: pointer; }

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 200;
  backdrop-filter: blur(2px);
}

.drawer-backdrop.is-open { display: block; }

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 100vh;
  background: var(--background);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow: hidden;
}

.detail-drawer.is-open { transform: translateX(0); }
.detail-drawer[hidden] { display: flex !important; transform: translateX(100%); } /* override UA hidden so transition works */

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--spacing-sm);
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.drawer-header__title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.drawer-company {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  word-break: break-word;
}

.drawer-email {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  word-break: break-all;
}

.drawer-close {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.drawer-close:hover { color: var(--text-primary); background: var(--gray-100); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

/* Score hero row */
.drawer-hero {
  display: flex;
  gap: var(--spacing-lg);
  align-items: flex-start;
}

.drawer-hero__score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-xs);
  flex-shrink: 0;
}

.drawer-hero__label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.drawer-score-pill {
  font-size: var(--font-size-xl);
  padding: 8px 18px;
}

.drawer-hero__meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.drawer-meta-row {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-sm);
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--gray-100);
  padding-bottom: var(--spacing-xs);
}

.drawer-meta-row:last-child { border-bottom: none; }

.drawer-meta-label {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.drawer-meta-value {
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
  text-align: right;
}

/* Sections */
.drawer-section__title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.drawer-fine {
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  color: var(--danger-color);
  font-weight: var(--font-weight-semibold);
}

/* Article score bars */
.drawer-articles {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.article-bar {
  display: grid;
  grid-template-columns: 72px 1fr 44px;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: var(--font-size-xs);
}

.article-bar__label {
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
}

.article-bar__track {
  height: 6px;
  background: var(--gray-100);
  border-radius: 100px;
  overflow: hidden;
}

.article-bar__fill {
  height: 100%;
  border-radius: 100px;
  background: var(--accent-color);
  transition: width 0.4s ease;
}

.article-bar__fill.score-critical { background: var(--danger-color); }
.article-bar__fill.score-atrisk   { background: var(--warning-color); }
.article-bar__fill.score-moderate { background: #F59E0B; }
.article-bar__fill.score-good     { background: var(--success-color); }

.article-bar__pct {
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
  text-align: right;
}

/* Actions */
.drawer-actions {
  margin-top: auto;
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-color);
}

.drawer-btn-email {
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Partner-specific dashboard overrides ─────────────────────── */

/* Berget.ai: primary-color is brand-cloud (off-white) — not usable as topbar bg.
   Override to brand-night so the topbar stays dark with legible white text. */
body.berget-ai .dash-topbar {
  background: #090909;
  border-bottom: 1px solid #1A1A1A;
  box-shadow: none;
}

/* Grunden.ai: sort indicator arrows tinted signal-blue */
body.grunden-ai .clients-table thead th.sort-asc::after,
body.grunden-ai .clients-table thead th.sort-desc::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 2l3 4H3l3-4z' fill='%232424FF'/%3E%3C/svg%3E");
}
body.grunden-ai .clients-table thead th.sort-desc::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 10L3 6h6l-3 4z' fill='%232424FF'/%3E%3C/svg%3E");
}

/* Berget.ai: sort arrows tinted moss-green */
body.berget-ai .clients-table thead th.sort-asc::after,
body.berget-ai .clients-table thead th.sort-desc::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 2l3 4H3l3-4z' fill='%233BAF77'/%3E%3C/svg%3E");
}
body.berget-ai .clients-table thead th.sort-desc::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 10L3 6h6l-3 4z' fill='%233BAF77'/%3E%3C/svg%3E");
}

/* Berget.ai: focus ring tinted moss-green */
body.berget-ai .form-input:focus {
  border-color: #3BAF77;
  box-shadow: 0 0 0 3px rgba(59, 175, 119, 0.2);
}

/* Berget.ai: drawer uses dark surface */
body.berget-ai .detail-drawer {
  background: #111111;
  border-left-color: #1A1A1A;
}

body.berget-ai .drawer-meta-row { border-bottom-color: #1A1A1A; }
body.berget-ai .drawer-actions  { border-top-color: #1A1A1A; }
body.berget-ai .drawer-header   { border-bottom-color: #1A1A1A; }
body.berget-ai .article-bar__track { background: #1A1A1A; }

/* Grunden.ai: focus ring tinted signal-blue */
body.grunden-ai .form-input:focus {
  box-shadow: 0 0 0 3px rgba(36, 36, 255, 0.12);
}

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 768px) {
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .dash-content {
    padding: var(--spacing-lg);
  }

  .dash-topbar {
    padding: 0 var(--spacing-md);
  }

  .dash-page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .stats-bar {
    grid-template-columns: 1fr 1fr;
  }

  .dash-topbar__partner-email {
    display: none;
  }
}
