/* ==================================================
   Worship Songs · Админ-панель
   ================================================== */

:root {
  --bg: #f3f4f8;
  --panel: #ffffff;
  --border: #e4e7ee;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --danger: #dc2626;
  --ok: #16a34a;
  --sidebar-bg: #1e2333;
  --sidebar-text: #c7cbd8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

[hidden],
.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

/* ==================================================
   Экран входа
   ================================================== */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-title {
  margin: 0;
  font-size: 26px;
  text-align: center;
}

.login-subtitle {
  margin: 4px 0 24px;
  text-align: center;
  color: var(--muted);
}

/* ==================================================
   Каркас приложения
   ================================================== */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  padding: 20px 16px;
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  flex: 1;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
  font-size: 15px;
  padding: 11px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.tab.is-active {
  background: var(--primary);
  color: #fff;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-user {
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content {
  flex: 1;
  padding: 28px;
  max-width: 1100px;
}

@media (max-width: 720px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
  }

  .tabs {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .content {
    padding: 16px;
  }
}

/* ==================================================
   Заголовки страниц, панели
   ================================================== */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: 24px;
}

.count {
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
}

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

.toolbar .input {
  flex: 1;
  min-width: 220px;
}

/* ==================================================
   Формы
   ================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 560px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.input,
textarea.input,
select.input {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.textarea {
  resize: vertical;
  min-height: 120px;
}

.form-error {
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 14px;
}

/* ==================================================
   Кнопки
   ================================================== */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  background: #f7f8fa;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

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

.btn-danger {
  color: var(--danger);
  border-color: #f3c9c9;
}

.btn-danger:hover {
  background: #fdecec;
}

.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--sidebar-text);
}

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

.btn-block {
  width: 100%;
}

.btn-small {
  padding: 5px 9px;
  font-size: 13px;
}

/* ==================================================
   Статистика
   ================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-icon {
  font-size: 26px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

/* ==================================================
   Таблицы
   ================================================== */

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #fafbfd;
}

.table tr:last-child td {
  border-bottom: 0;
}

.row-actions {
  white-space: nowrap;
}

.tag {
  display: inline-block;
  background: #eef0ff;
  color: var(--primary-dark);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  margin: 1px 2px;
}

.badge {
  display: inline-block;
  background: #f3f4f8;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
}

.badge-ok {
  background: #e7f6ec;
  color: var(--ok);
}

.badge-warn {
  background: #fff4e0;
  color: #b45309;
}

.badge-danger {
  background: #fdeaea;
  color: #dc2626;
}

.small {
  font-size: 12px;
  word-break: break-all;
}

.stat-card-link {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

/* ==================================================
   Пагинация
   ================================================== */

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.page-info {
  color: var(--muted);
  font-size: 14px;
}

/* ==================================================
   Списки (темы, категории, медиа)
   ================================================== */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.media-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.media-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-size {
  color: var(--muted);
  font-size: 13px;
}

.player {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.player audio {
  flex: 1;
  min-width: 240px;
}

/* ==================================================
   Модальные окна
   ================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 35, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}

.modal {
  background: var(--panel);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
}

.modal-title {
  margin: 0;
  font-size: 19px;
}

.modal-close {
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.modal-close:hover {
  color: var(--text);
  background: #f3f4f8;
}

.modal-body {
  padding: 16px 20px 20px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 20px 20px;
}

/* Чипы-чекбоксы (темы и категории) */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f3f4f8;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}

.chip:has(input:checked) {
  background: #eef0ff;
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* ==================================================
   Тосты
   ================================================== */

#toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  max-width: 360px;
}

.toast {
  background: #232a3b;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: #14532d;
}

.toast-error {
  background: #7f1d1d;
}

/* ==================================================
   Планы служений
   ================================================== */

.plan-section-title {
  margin: 16px 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.plan-song-list,
.plan-song-results {
  max-height: 220px;
  overflow-y: auto;
}
