/* ==============================================================================
   TMA Styles: Editorial Academic Ledger
   Strictly following anti-slop-design & copy-taste guidelines.
   No purple gradients. No backdrop-blur. Intentional typography & contrast.
   ============================================================================== */

:root {
  /* Поверхности (Теплая бумага и чистый лист) */
  --bg-canvas: #F7F5F0;
  --bg-surface: #FFFFFF;
  --bg-subtle: #EFECE6;
  --bg-hover: #E8E5DD;

  /* Текст (Строгая иерархия, высокий контраст) */
  --text-primary: #161615;
  --text-secondary: #575653;
  --text-muted: #85837E;

  /* Границы */
  --border-subtle: #E2DFD7;
  --border-strong: #C8C4B8;

  /* Акценты (Академический хвойный & статусы) */
  --accent-primary: #1B4332;
  --accent-primary-hover: #122E22;
  --accent-primary-soft: #E8F0EC;

  --status-approved-fg: #1B4332;
  --status-approved-bg: #E8F0EC;

  --status-pending-fg: #9A3412;
  --status-pending-bg: #FFEDD5;

  --status-danger-fg: #991B1B;
  --status-danger-bg: #FEE2E2;

  /* Шрифты */
  --font-serif: "PT Serif", Georgia, serif;
  --font-sans: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  /* Радиусы по функции */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

body {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 40px;
}

.font-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

.app-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

/* ==============================================================================
   Шапка студента
   ============================================================================== */
.student-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.badge-academic {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-primary);
  background: var(--accent-primary-soft);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.student-name {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 8px;
}

.student-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tag-chip {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

/* Прогресс-бар */
.progress-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.progress-numbers strong {
  font-size: 16px;
  color: var(--accent-primary);
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: var(--border-subtle);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Навигационные табы */
.tma-nav {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
}

.nav-tab {
  flex: 1;
  min-height: 44px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  background: var(--bg-hover);
}

.nav-tab.active {
  background: var(--accent-primary);
  color: #FFFFFF;
  border-color: var(--accent-primary);
}

/* ==============================================================================
   Форма подачи кейса
   ============================================================================== */
.academic-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.section-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-step {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-primary);
  background: var(--accent-primary-soft);
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  margin-top: 2px;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.section-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.req-star {
  color: var(--status-danger-fg);
}

/* Поля ввода */
.field-group {
  margin-bottom: 16px;
}

.field-group:last-child {
  margin-bottom: 0;
}

.fields-row {
  display: flex;
  gap: 12px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.text-input,
.textarea-input {
  width: 100%;
  background: var(--bg-canvas);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.text-input:focus,
.textarea-input:focus {
  background: #FFFFFF;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.textarea-input {
  resize: vertical;
  line-height: 1.5;
}

/* Сетка чипсов (Модули и Сферы) */
.chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  min-height: 44px;
  padding: 8px 14px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.chip-btn.selected {
  background: var(--accent-primary);
  color: #FFFFFF;
  border-color: var(--accent-primary);
  font-weight: 600;
}

/* Дропзона загрузки файлов */
.file-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-canvas);
  text-align: center;
  padding: 24px 16px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.file-dropzone:hover {
  background: var(--bg-hover);
}

.file-hidden-input {
  display: none;
}

.dropzone-label {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.upload-icon {
  font-size: 28px;
}

.upload-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.upload-hints {
  font-size: 11px;
  color: var(--text-muted);
}

.file-selected-badge {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--accent-primary-soft);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--accent-primary);
  font-weight: 600;
}

.btn-remove {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--accent-primary);
  cursor: pointer;
  padding: 0 4px;
}

/* Черновик из чата */
.draft-media-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #FEF9C3;
  border: 1px solid #FDE047;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.draft-media-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.draft-icon {
  font-size: 22px;
}

.draft-sub {
  display: block;
  font-size: 11px;
  color: #713F12;
}

.btn-subtle-sm {
  min-height: 36px;
  padding: 4px 10px;
  background: #FFFFFF;
  border: 1px solid #CA8A04;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #713F12;
  font-weight: 600;
  cursor: pointer;
}

/* Алерт возврата на доработку */
.alert-revision {
  background: var(--status-pending-bg);
  border: 1px solid #FDBA74;
  border-left: 4px solid var(--status-pending-fg);
  border-radius: var(--radius-md);
  padding: 14px;
}

.alert-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--status-pending-fg);
  margin-bottom: 4px;
}

.alert-text {
  font-size: 13px;
  color: var(--text-primary);
}

/* ==============================================================================
   Живой предпросмотр публикации
   ============================================================================== */
.preview-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.preview-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.char-counter {
  font-size: 12px;
  color: var(--text-muted);
}

.char-counter.warning {
  color: var(--status-pending-fg);
  font-weight: 600;
}

.char-counter.danger {
  color: var(--status-danger-fg);
  font-weight: 700;
}

.post-preview-card {
  background: #FFFFFF;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: #000000;
}

.post-preview-card b {
  font-weight: 700;
}

/* ==============================================================================
   Кнопки действий
   ============================================================================== */
.form-actions {
  position: sticky;
  bottom: 12px;
  z-index: 100;
}

.btn-primary-action {
  width: 100%;
  min-height: 50px;
  background: var(--accent-primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(27, 67, 50, 0.25);
  transition: background-color 0.15s ease, transform 0.05s ease;
}

.btn-primary-action:hover {
  background: var(--accent-primary-hover);
}

.btn-primary-action:active {
  transform: scale(0.99);
}

.btn-primary-action:disabled {
  background: var(--border-strong);
  cursor: not-allowed;
  box-shadow: none;
}

/* ==============================================================================
   Список истории кейсов
   ============================================================================== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.case-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.case-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.case-card-date {
  font-size: 11px;
  color: var(--text-muted);
}

.case-status-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.status-approved {
  color: var(--status-approved-fg);
  background: var(--status-approved-bg);
}

.status-pending {
  color: var(--status-pending-fg);
  background: var(--status-pending-bg);
}

.status-revision {
  color: var(--status-danger-fg);
  background: var(--status-danger-bg);
}

.status-rejected {
  color: #6B7280;
  background: #F3F4F6;
}

.case-card-client {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.case-card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.case-card-comment {
  background: var(--status-danger-bg);
  border-left: 3px solid var(--status-danger-fg);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.btn-edit-case {
  min-height: 40px;
  width: 100%;
  background: var(--bg-canvas);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}

.btn-edit-case:hover {
  background: var(--bg-hover);
}

