/* ==========================================================================
   Reset + base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

/* ==========================================================================
   Тема: переменные. Меняются через [data-theme="dark"] на <html>
   ========================================================================== */
:root, [data-theme="light"] {
  --bg:           #f7f7f8;
  --surface:      #ffffff;
  --surface-2:    #f0f0f3;
  --border:       #e4e4e7;
  --border-strong:#cccccf;
  --text:         #1a1a1a;
  --text-muted:   #6b6b70;
  --text-faint:   #9a9a9f;

  --accent:       #2563eb;   /* blue 600 */
  --accent-bg:    #eff6ff;   /* blue 50 */
  --accent-text:  #1d4ed8;

  --success:      #16a34a;
  --success-bg:   #dcfce7;
  --success-text: #15803d;

  --warning:      #ea580c;
  --warning-bg:   #ffedd5;
  --warning-text: #c2410c;

  --danger:       #dc2626;
  --danger-bg:    #fee2e2;
  --danger-text:  #b91c1c;

  --radius:    8px;
  --radius-lg: 12px;
  --shadow-focus: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

[data-theme="dark"] {
  --bg:           #0f0f10;
  --surface:      #1a1a1c;
  --surface-2:    #232327;
  --border:       #303033;
  --border-strong:#42424a;
  --text:         #e8e8ea;
  --text-muted:   #a1a1a6;
  --text-faint:   #6b6b70;

  --accent:       #3b82f6;
  --accent-bg:    #1e293b;
  --accent-text:  #93c5fd;

  --success:      #22c55e;
  --success-bg:   #14291c;
  --success-text: #86efac;

  --warning:      #f97316;
  --warning-bg:   #2a1a0c;
  --warning-text: #fdba74;

  --danger:       #ef4444;
  --danger-bg:    #2a1414;
  --danger-text:  #fca5a5;

  --shadow-focus: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

/* ==========================================================================
   Header
   ========================================================================== */
.header {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header__brand { display: flex; align-items: center; gap: 12px; }
.header__logo {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-bg);
  color: var(--accent-text);
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
}
.header__title { font-weight: 600; font-size: 15px; }
.header__sub { font-size: 12px; color: var(--text-muted); }
.header__right { display: flex; align-items: center; gap: 10px; }

/* Виджет состояния сервера */
.server-status {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-muted);
}
.server-status__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.server-status--free  .server-status__dot { background: var(--success); }
.server-status--free  .server-status__text { color: var(--success-text); }
.server-status--busy  .server-status__dot { background: var(--warning); }
.server-status--busy  .server-status__text { color: var(--warning-text); }
.server-status--full  .server-status__dot { background: var(--danger); }
.server-status--full  .server-status__text { color: var(--danger-text); }

/* Кнопка темы */
.theme-toggle {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.theme-toggle:hover { background: var(--surface-2); border-color: var(--border-strong); }
.theme-toggle__icon { display: none; }
[data-theme="light"] .theme-toggle__icon--moon { display: block; }
[data-theme="dark"]  .theme-toggle__icon--sun  { display: block; }

/* ==========================================================================
   Main
   ========================================================================== */
.main { max-width: 760px; margin: 0 auto; padding: 0 20px 40px; }

/* Dropzone */
.dropzone {
  margin-bottom: 12px;
  padding: 36px 20px;
  background: var(--surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}
.dropzone:hover,
.dropzone--active {
  background: var(--accent-bg);
  border-color: var(--accent);
}
.dropzone__icon { color: var(--text-faint); margin-bottom: 8px; }
.dropzone:hover .dropzone__icon,
.dropzone--active .dropzone__icon { color: var(--accent); }
.dropzone__title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.dropzone__sub { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.btn--primary:hover:not(:disabled) { background: var(--accent-text); border-color: var(--accent-text); }
.btn--small { padding: 6px 12px; font-size: 12px; }
.btn__count {
  background: rgba(255,255,255,0.25);
  padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600;
}

/* Controls */
.controls {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
}
.controls__label { font-size: 13px; color: var(--text-muted); }
.controls__spacer { flex: 1; min-width: 0; }
.radio { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; user-select: none; }
.radio input { margin: 0; cursor: pointer; accent-color: var(--accent); }

/* Алерты */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 13px;
  border: 1px solid transparent;
}
.alert--info    { background: var(--accent-bg);  color: var(--accent-text);  border-color: var(--accent); }
.alert--danger  { background: var(--danger-bg);  color: var(--danger-text);  border-color: var(--danger); }
.alert--warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning); }
.alert__close { float: right; background: none; border: none; color: inherit; font-size: 16px; line-height: 1; padding: 0 0 0 8px; }

/* Files section */
.files-section { margin-top: 4px; }
.files-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 4px 8px;
}
.files-header__title { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.files-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }

/* Карточка файла */
.file-card {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.file-card__row { display: flex; align-items: center; gap: 10px; }
.file-card__icon {
  width: 22px; height: 22px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-faint);
}
.file-card__body { flex: 1; min-width: 0; }
.file-card__name {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-card__status { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.file-card__right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Прогресс-бар */
.file-card__bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 10px;
}
.file-card__bar-fill {
  height: 100%; width: 0%;
  background: var(--text-faint);
  transition: width 0.4s ease, background 0.2s;
}

/* Состояния карточек */
.file-card[data-status="pending"]    .file-card__icon  { color: var(--text-faint); }
.file-card[data-status="pending"]    .file-card__status{ color: var(--text-muted); }

.file-card[data-status="uploading"]  .file-card__icon,
.file-card[data-status="uploading"]  .file-card__status,
.file-card[data-status="uploading"]  .file-card__bar-fill { color: var(--accent); background: var(--accent); }
.file-card[data-status="uploading"]  .file-card__icon,
.file-card[data-status="uploading"]  .file-card__status { background: none; color: var(--accent-text); }

.file-card[data-status="processing"] .file-card__icon,
.file-card[data-status="processing"] .file-card__status { color: var(--accent-text); }
.file-card[data-status="processing"] .file-card__bar-fill { background: var(--accent); }

.file-card[data-status="done"]       .file-card__icon,
.file-card[data-status="done"]       .file-card__status { color: var(--success-text); }
.file-card[data-status="done"]       .file-card__bar-fill { background: var(--success); width: 100%; }

.file-card[data-status="warning"]    .file-card__icon,
.file-card[data-status="warning"]    .file-card__status { color: var(--warning-text); }
.file-card[data-status="warning"]    .file-card__bar-fill { background: var(--warning); width: 100%; }

.file-card[data-status="error"]      .file-card__icon,
.file-card[data-status="error"]      .file-card__status { color: var(--danger-text); }
.file-card[data-status="error"]      .file-card__bar-fill { background: var(--danger); width: 100%; }

/* Анимация "крутилки" для processing/uploading иконки */
.file-card[data-status="processing"] .file-card__icon svg,
.file-card[data-status="uploading"]  .file-card__icon svg {
  animation: spin 1.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Бэйдж размера */
.size-badge {
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 8px;
  background: var(--surface-2);
  border-radius: var(--radius);
  white-space: nowrap;
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px 12px 8px;
  font-size: 12px;
  color: var(--text-faint);
}

/* Адаптив */
@media (max-width: 540px) {
  .header { padding: 12px 14px; }
  .header__sub { display: none; }
  .main { padding: 0 14px 30px; }
  .dropzone { padding: 28px 14px; }
  .controls { padding: 10px 12px; gap: 10px; }
  .controls__label { width: 100%; }
  .file-card__right .btn { padding: 6px 10px; font-size: 11px; }
}

/* ===========================================================================
   Состояние "staged" — файл выбран, ждёт нажатия "Обработать"
   =========================================================================== */
.file-card[data-status="staged"] .file-card__icon     { color: var(--accent-text); }
.file-card[data-status="staged"] .file-card__status   { color: var(--text-muted); }
.file-card[data-status="staged"] .file-card__bar-fill { background: var(--accent); width: 0%; }

/* Кнопка удаления файла из списка ожидания (крестик ×) */
.btn-remove {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 18px; line-height: 1;
  padding: 0;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-remove:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger-text);
}
