/* ── Юридический помощник — кастомные стили ───────────────────────── */

/* Токены */
:root {
  --brand-primary: #2553A0;
  --brand-primary-dark: #1A3E80;
  --brand-primary-light: #EBF0FA;
  --brand-accent: #3B72D4;

  --risk-high: #DC2626;
  --risk-high-bg: #FEF2F2;
  --risk-high-border: #FCA5A5;

  --risk-medium: #D97706;
  --risk-medium-bg: #FFFBEB;
  --risk-medium-border: #FCD34D;

  --risk-low: #16A34A;
  --risk-low-bg: #F0FDF4;
  --risk-low-border: #86EFAC;

  --text-muted: #64748B;
  --border-color: #E2E8F0;
  --surface: #F8FAFC;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(37,83,160,0.08);
  --shadow: 0 4px 16px rgba(37,83,160,0.10);
}

/* ── Базовые переопределения ── */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--surface);
  color: #1E293B;
}

/* ── Шапка — перекраска ms-header под бренд ── */
.ms-header {
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-accent) 100%);
  color: #fff !important;
  padding: 1.25rem 0;
}
.ms-header h1 {
  color: #fff !important;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ms-header p {
  color: rgba(255,255,255,0.82) !important;
  margin: 0;
  font-size: 0.9rem;
}
.ms-header .ms-shell {
  display: flex;
  flex-direction: column;
}

/* ── Навигация-вкладки (страницы) ── */
.app-nav {
  background: var(--brand-primary-dark);
  padding: 0 1rem;
}
.app-nav .nav-link {
  color: rgba(255,255,255,0.72);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  transition: color 0.15s, border-color 0.15s;
}
.app-nav .nav-link:hover,
.app-nav .nav-link.active {
  color: #fff;
  border-bottom-color: #fff;
  background: transparent;
}

/* ── Карточки ── */
.la-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.la-card-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--brand-primary);
  margin-bottom: 1rem;
}

/* ── Зона загрузки ── */
.dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #fff;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
}
.dropzone .dz-icon {
  font-size: 2rem;
  color: var(--brand-primary);
  margin-bottom: 0.75rem;
}
.dropzone .dz-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: #1E293B;
}
.dropzone .dz-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
}

/* ── Кнопки ── */
.btn-brand {
  background: var(--brand-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.625rem 1.5rem;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.btn-brand:hover { background: var(--brand-primary-dark); color: #fff; }
.btn-brand:active { transform: scale(0.98); }
.btn-brand:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Карточки рисков ── */
.risk-card {
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: #fff;
  margin-bottom: 1rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}
.risk-card:hover { box-shadow: var(--shadow); }

.risk-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem 0.75rem;
}
.risk-stripe {
  width: 4px;
  flex-shrink: 0;
  align-self: stretch;
  border-radius: 4px;
}
.risk-card.high .risk-stripe { background: var(--risk-high); }
.risk-card.medium .risk-stripe { background: var(--risk-medium); }
.risk-card.low .risk-stripe { background: var(--risk-low); }

.risk-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2em 0.65em;
  border-radius: 100px;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.risk-card.high .risk-badge {
  background: var(--risk-high-bg);
  color: var(--risk-high);
  border: 1px solid var(--risk-high-border);
}
.risk-card.medium .risk-badge {
  background: var(--risk-medium-bg);
  color: var(--risk-medium);
  border: 1px solid var(--risk-medium-border);
}
.risk-card.low .risk-badge {
  background: var(--risk-low-bg);
  color: var(--risk-low);
  border: 1px solid var(--risk-low-border);
}

.risk-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #1E293B;
  flex: 1;
}

.risk-body { padding: 0 1.25rem 1.25rem; }

.risk-clause {
  background: var(--surface);
  border-left: 3px solid var(--border-color);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.625rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.risk-explanation {
  font-size: 0.875rem;
  color: #334155;
  line-height: 1.6;
  margin-bottom: 0.625rem;
}

.law-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.law-ref-tag {
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border: 1px solid rgba(37,83,160,0.18);
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2em 0.7em;
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
}

/* ── Сводка ── */
.summary-block {
  background: var(--brand-primary-light);
  border: 1px solid rgba(37,83,160,0.15);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.summary-block p {
  margin: 0;
  font-size: 0.9375rem;
  color: #1E293B;
  line-height: 1.6;
}

/* ── Счётчик рисков ── */
.risk-stats {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.risk-stat {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.3em 0.8em;
  border-radius: 100px;
}
.risk-stat.high { background: var(--risk-high-bg); color: var(--risk-high); }
.risk-stat.medium { background: var(--risk-medium-bg); color: var(--risk-medium); }
.risk-stat.low { background: var(--risk-low-bg); color: var(--risk-low); }

/* ── Прогресс / загрузка ── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1rem;
  gap: 1rem;
}
.spinner-brand {
  width: 3rem;
  height: 3rem;
  border: 3px solid var(--brand-primary-light);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: #334155;
}
.loading-sublabel {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── Прогресс-бар ── */
.analysis-progress {
  width: 100%;
  max-width: 320px;
  height: 4px;
  background: var(--brand-primary-light);
  border-radius: 2px;
  overflow: hidden;
}
.analysis-progress-fill {
  height: 100%;
  background: var(--brand-primary);
  border-radius: 2px;
  animation: progress-pulse 2s ease-in-out infinite;
}
@keyframes progress-pulse {
  0% { width: 5%; }
  60% { width: 85%; }
  100% { width: 5%; }
}

/* ── Чат с вопросами ── */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.25rem 0;
}
.chat-msg {
  max-width: 88%;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.5;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--brand-primary);
  color: #fff;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--border-color);
  color: #1E293B;
}
.chat-msg.assistant.thinking {
  color: var(--text-muted);
  font-style: italic;
}

/* ── Вкладки ── */
.tab-panels .tab-panel { display: none; }
.tab-panels .tab-panel.active { display: block; }

/* ── Форма генерации ── */
.doc-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.doc-type-card {
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
  background: #fff;
}
.doc-type-card:hover { border-color: var(--brand-primary); background: var(--brand-primary-light); }
.doc-type-card.selected {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
}
.doc-type-card .dt-icon {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  color: var(--brand-primary);
}
.doc-type-card .dt-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1E293B;
}
.doc-type-card .dt-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ── Превью документа ── */
.doc-preview {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  font-size: 0.8125rem;
  color: #334155;
  line-height: 1.7;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: 'Inter', monospace;
}

/* ── Кнопки скачивания ── */
.download-btns {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn-download:hover { opacity: 0.85; }
.btn-download.docx {
  background: #2553A0;
  color: #fff;
}
.btn-download.pdf {
  background: #E5392C;
  color: #fff;
}

/* ── Алерты ── */
.la-alert {
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
}
.la-alert.error {
  background: var(--risk-high-bg);
  border: 1px solid var(--risk-high-border);
  color: #991B1B;
}
.la-alert.info {
  background: var(--brand-primary-light);
  border: 1px solid rgba(37,83,160,0.18);
  color: #1E3A6E;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .es-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}
.empty-state .es-title {
  font-size: 1rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.4rem;
}
.empty-state .es-text {
  font-size: 0.875rem;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .ms-header h1 { font-size: 1.2rem; }
  .la-card { padding: 1rem; }
  .doc-type-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Accessibility ── */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .spinner-brand, .analysis-progress-fill { animation: none; }
}
