/* =================================================================
   Brand Intelligence — Dashboard styles
   Uses existing CSS vars from styles.css
   ================================================================= */

/* ---- Input form ---- */
.bi-form {
  max-width: 640px;
  margin: 40px auto;
  padding: var(--s-6);
}
.bi-form-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--s-2);
}
.bi-form-sub {
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: var(--s-6);
  line-height: 1.5;
}
.bi-input-group {
  margin-bottom: var(--s-4);
}
.bi-input-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: var(--s-1);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.bi-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.bi-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}
.bi-input::placeholder {
  color: var(--text-3);
}

/* Competitor inputs */
.bi-competitors {
  margin-top: var(--s-4);
}
.bi-competitor-row {
  display: flex;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
  align-items: center;
}
.bi-competitor-row .bi-input {
  flex: 1;
}
.bi-remove-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  transition: color 0.15s, background 0.15s;
}
.bi-remove-btn:hover {
  color: var(--bad);
  background: var(--bad-bg);
}
.bi-add-comp-btn {
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  width: 100%;
  transition: border-color 0.15s, color 0.15s;
}
.bi-add-comp-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

/* Submit */
.bi-submit {
  margin-top: var(--s-6);
  width: 100%;
  padding: 12px 20px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.bi-submit:hover {
  background: var(--brand-dark);
}
.bi-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Loading state ---- */
.bi-loading {
  text-align: center;
  padding: 80px var(--s-6);
}
.bi-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: bi-spin 0.8s linear infinite;
  margin: 0 auto var(--s-4);
}
@keyframes bi-spin {
  to { transform: rotate(360deg); }
}
.bi-loading-text {
  color: var(--text-2);
  font-size: 15px;
}

/* ---- Dashboard ---- */
.bi-dashboard {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--s-4) var(--s-6);
}

/* Header */
.bi-header {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  margin-bottom: var(--s-6);
  padding: var(--s-5) var(--s-6);
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.bi-brand-name {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  flex: 1;
}
.bi-brand-domain {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}
.bi-score-ring {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}
.bi-score-ring svg {
  width: 80px;
  height: 80px;
  transform: rotate(-90deg);
}
.bi-score-ring .ring-bg {
  fill: none;
  stroke: var(--surface-3);
  stroke-width: 6;
}
.bi-score-ring .ring-fg {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}
.bi-score-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}
.bi-score-label {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Back button */
.bi-back-btn {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  margin-bottom: var(--s-4);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s, background 0.15s;
}
.bi-back-btn:hover {
  color: var(--brand);
  background: var(--brand-light);
}

/* ---- Dimension grid ---- */
.bi-dimensions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-4);
  margin-bottom: var(--s-6);
}
@media (max-width: 768px) {
  .bi-dimensions {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 480px) {
  .bi-dimensions {
    grid-template-columns: 1fr;
  }
}

/* Dimension card */
.bi-dim-card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--s-5);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border-subtle);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.bi-dim-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}
.bi-dim-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.bi-dim-icon {
  font-size: 20px;
}
.bi-dim-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.bi-dim-score {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: var(--s-2);
}
.bi-dim-summary {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: var(--s-3);
}
.bi-dim-signals {
  list-style: none;
  padding: 0;
  margin: 0;
}
.bi-dim-signals li {
  font-size: 12px;
  color: var(--text-3);
  padding: 3px 0;
  border-top: 1px solid var(--border-subtle);
}
.bi-dim-signals li:first-child {
  border-top: none;
}

/* Score colors */
.score-excellent { color: #059669; }
.score-good { color: var(--good); }
.score-average { color: var(--warn); }
.score-weak { color: #ea580c; }
.score-poor { color: var(--bad); }

/* ---- Narrative section ---- */
.bi-narrative {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--s-5) var(--s-6);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--s-6);
}
.bi-narrative-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.bi-narrative-body {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.7;
}
.bi-narrative-body h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: var(--s-4) 0 var(--s-2);
}
.bi-narrative-body h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: var(--s-3) 0 var(--s-1);
}
.bi-narrative-body p {
  margin: 0 0 var(--s-3);
}
.bi-narrative-body b, .bi-narrative-body strong {
  color: var(--text);
  font-weight: 600;
}
.bi-narrative-body ul {
  padding-left: 20px;
  margin: var(--s-2) 0;
}
.bi-narrative-body li {
  margin-bottom: var(--s-1);
}

/* ---- Raw data accordion ---- */
.bi-raw-section {
  margin-bottom: var(--s-6);
}
.bi-raw-toggle {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: 10px var(--s-4);
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  transition: background 0.15s;
}
.bi-raw-toggle:hover {
  background: var(--surface-2);
}
.bi-raw-toggle .arrow {
  transition: transform 0.2s;
}
.bi-raw-toggle.open .arrow {
  transform: rotate(90deg);
}
.bi-raw-content {
  display: none;
  padding: var(--s-4);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  font-size: 12px;
  font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
}
.bi-raw-content.open {
  display: block;
}

/* ---- Competitor comparison ---- */
.bi-competitors-section {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--s-5) var(--s-6);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--s-6);
}
.bi-competitors-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--s-4);
}
.bi-comp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.bi-comp-table th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 2px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.bi-comp-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
}
.bi-comp-table tr:last-child td {
  border-bottom: none;
}

/* Clickable brand name in peer analysis */
.brand-link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s;
  border-bottom: 1px dashed var(--brand);
  padding-bottom: 1px;
}
.brand-link:hover {
  color: var(--brand-dark);
  border-bottom-style: solid;
}

/* ---- Error state ---- */
.bi-error {
  text-align: center;
  padding: 60px var(--s-6);
  color: var(--text-2);
}
.bi-error-icon {
  font-size: 40px;
  margin-bottom: var(--s-4);
}
.bi-error-msg {
  font-size: 15px;
  margin-bottom: var(--s-4);
}
.bi-retry-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 20px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  transition: border-color 0.15s;
}
.bi-retry-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}
