/* Marketolog — сайт под телефон (issue #3). Один файл, mobile-first, без сборщиков. */

:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #16171a;
  --muted: #6b7280;
  --border: #e2e4e8;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --success: #16a34a;
  --warning: #d97706;

  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214;
    --surface: #1c1c1f;
    --text: #f0f0f2;
    --muted: #9aa0aa;
    --border: #303136;
    --accent: #4f8cff;
    --accent-text: #0b0b0d;
    --danger: #f87171;
    --danger-bg: #3a1414;
    --success: #4ade80;
    --warning: #fbbf24;
  }
}

:root[data-theme="dark"] {
  --bg: #121214;
  --surface: #1c1c1f;
  --text: #f0f0f2;
  --muted: #9aa0aa;
  --border: #303136;
  --accent: #4f8cff;
  --accent-text: #0b0b0d;
  --danger: #f87171;
  --danger-bg: #3a1414;
  --success: #4ade80;
  --warning: #fbbf24;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

img {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--accent);
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 16px calc(96px + env(safe-area-inset-bottom, 0px));
}

.page-title {
  font-size: 1.25rem;
  margin: 4px 0 16px;
}

/* -------- навигация -------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}

.topnav-link {
  flex: 1;
  text-align: center;
  padding: 14px 8px;
  min-height: 44px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.95rem;
}

.topnav-logout {
  flex: 0 0 auto;
  margin: 0;
}

.topnav-logout-btn {
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
}

.badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--border);
  color: var(--text);
  font-size: 0.75rem;
  margin-left: 4px;
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

/* -------- кнопки -------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 10px 12px;
}

.btn-block {
  width: 100%;
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}

/* -------- формы -------- */

.inline-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.inline-form label {
  font-size: 0.85rem;
  color: var(--muted);
}

.inline-form input,
.filter-form select {
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.filter-form {
  margin-bottom: 12px;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 16px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

.login-form input {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

.error {
  color: var(--danger);
  background: var(--danger-bg);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 0 0 12px;
}

.empty-hint {
  color: var(--muted);
  padding: 12px 0;
}

/* -------- карточки -------- */

.item-card,
.failure-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
}

.item-card-time {
  font-weight: 600;
  min-width: 44px;
}

.item-card-title,
.batch-row-title {
  flex: 1 1 100%; /* своя строка в flex-wrap контейнере, до времени/меты */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 600;
  line-height: 1.3;
}

.status-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8rem;
  background: var(--border);
}

.status-ready { border-left-color: var(--warning); }
.status-ready .status-badge, .status-badge.status-ready { background: var(--warning); color: #1a1200; }
.status-approved { border-left-color: var(--success); }
.status-approved .status-badge, .status-badge.status-approved { background: var(--success); color: #06210f; }
.status-publishing { border-left-color: var(--accent); }
.status-publishing .status-badge, .status-badge.status-publishing { background: var(--accent); color: var(--accent-text); }
.status-done { border-left-color: var(--success); }
.status-done .status-badge, .status-badge.status-done { background: var(--success); color: #06210f; }
.status-failed { border-left-color: var(--danger); }
.status-failed .status-badge, .status-badge.status-failed { background: var(--danger-bg); color: var(--danger); }
.status-rejected { border-left-color: var(--muted); }
.status-rejected .status-badge, .status-badge.status-rejected { background: var(--border); color: var(--muted); }
.status-story .status-badge, .status-badge.status-story,
.status-script .status-badge, .status-badge.status-script,
.status-render .status-badge, .status-badge.status-render { background: var(--border); color: var(--muted); }

/* -------- черновик -------- */

.draft-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.draft-title {
  font-size: 1.15rem;
  margin: 0 0 12px;
}

.draft-video {
  width: 100%;
  max-height: 70vh;
  border-radius: 10px;
  background: #000;
  margin-bottom: 12px;
}

.draft-body {
  white-space: pre-wrap;
  margin: 0 0 16px;
}

/* -------- пачка -------- */

.batch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 44px;
}

.batch-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
}

.batch-row-link {
  margin-left: auto;
}

/* -------- календарь -------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.toolbar-title {
  font-weight: 600;
}

.calendar-grid {
  display: block;
}

.calendar-day {
  margin-bottom: 20px;
}

.calendar-day-title {
  font-size: 1rem;
  color: var(--muted);
  margin: 0 0 8px;
}

.calendar-day-today {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

.calendar-day-today .calendar-day-title {
  color: var(--accent);
  font-weight: 600;
}

@media (min-width: 900px) {
  .calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
  }
  .calendar-day {
    margin-bottom: 0;
  }
}
