/* ==========================================================================
   Maximum — светлая минималистичная тема.
   Все цвета и размеры заданы переменными: тёмную схему можно добавить позже
   одним блоком, не трогая компоненты.
   ========================================================================== */

:root {
    --bg: #ffffff;
    --surface: #fbfbfc;
    --surface-2: #f4f5f7;
    --border: #e6e8eb;
    --border-strong: #d3d7dd;

    --text: #14161a;
    --text-2: #656d7a;
    --text-3: #9aa1ac;

    --accent: #2f6fed;
    --accent-hover: #1f5bd6;
    --accent-soft: #eef3fe;

    --ok: #0f8a5f;
    --ok-soft: #e8f6f0;
    --warn: #b4780a;
    --warn-soft: #fdf4e3;
    --danger: #c8382f;
    --danger-soft: #fdeceb;

    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(20, 22, 26, .05);
    --shadow-lg: 0 8px 28px rgba(20, 22, 26, .12);

    --sidebar-width: 232px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Roboto", "Helvetica Neue", sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover { text-decoration: underline; }

h1, h2, h3 {
    font-weight: 600;
    letter-spacing: -.01em;
    margin: 0 0 4px;
}

h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

/* --------------------------------------------------------------- Каркас */

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

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    border-right: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    padding: 20px 20px 16px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.02em;
    color: var(--text);
}

.sidebar__brand span {
    color: var(--text-3);
    font-weight: 400;
}

.sidebar__nav {
    padding: 4px 12px;
    flex: 1;
    overflow-y: auto;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 14px;
}

.sidebar__link:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}

.sidebar__link--active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 500;
}

.sidebar__section {
    padding: 16px 10px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
}

.sidebar__footer {
    border-top: 1px solid var(--border);
    padding: 12px;
    font-size: 13px;
    color: var(--text-2);
}

.sidebar__user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.page {
    padding: 28px 32px 56px;
    max-width: 1200px;
    width: 100%;
}

.page__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.page__subtitle {
    color: var(--text-2);
    font-size: 14px;
}

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

.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card__head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card__body { padding: 18px; }

.card__empty {
    padding: 40px 18px;
    text-align: center;
    color: var(--text-3);
    font-size: 14px;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 900px) {
    .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}

.btn:hover {
    background: var(--surface-2);
    text-decoration: none;
}

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

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

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

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

.btn--danger:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
}

.btn--ghost {
    border-color: transparent;
    background: transparent;
    color: var(--text-2);
}

.btn--ghost:hover { background: var(--surface-2); }

.btn--sm {
    padding: 4px 10px;
    font-size: 13px;
}

.btn--block { width: 100%; }

/* ----------------------------------------------------------------- Формы */

.field { margin-bottom: 16px; }

.field__label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
}

.input,
.textarea,
.select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    transition: border-color .12s, box-shadow .12s;
}

.input:focus,
.textarea:focus,
.select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.textarea {
    min-height: 220px;
    resize: vertical;
    line-height: 1.6;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-2);
    cursor: pointer;
}

.checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.field__error,
.validation-summary-errors ul {
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
    color: var(--danger);
    font-size: 13px;
}

.input.input-validation-error,
.textarea.input-validation-error {
    border-color: var(--danger);
}

.form-alert {
    padding: 10px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 14px;
}

.form-alert ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Тег-хелпер сводки оставляет пустой блок, когда ошибок нет. */
.form-alert.validation-summary-valid { display: none; }

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

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

.table th {
    text-align: left;
    padding: 10px 18px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface); }

.table__num {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ----------------------------------------------------------------- Метки */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    background: var(--surface-2);
    color: var(--text-2);
}

.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------ Показатели */

.stat__label {
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 4px;
}

.stat__value {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.stat__hint {
    font-size: 13px;
    color: var(--text-3);
}

/* ------------------------------------------------------------------ Вход */

.auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    padding: 24px;
}

.auth__card {
    width: 100%;
    max-width: 380px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 32px;
}

.auth__brand {
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -.02em;
    margin-bottom: 4px;
}

.auth__hint {
    color: var(--text-2);
    font-size: 14px;
    margin-bottom: 24px;
}

/* ------------------------------------------- Уведомления (вместо alert) */

.toasts {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-3);
    border-radius: var(--radius-sm);
    background: var(--bg);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    animation: toast-in .16s ease-out;
}

.toast--ok { border-left-color: var(--ok); }
.toast--warn { border-left-color: var(--warn); }
.toast--danger { border-left-color: var(--danger); }

.toast--hiding {
    opacity: 0;
    transform: translateX(8px);
    transition: opacity .2s, transform .2s;
}

.toast__close {
    margin-left: auto;
    border: none;
    background: none;
    color: var(--text-3);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: none; }
}

/* ------------------------------ Модальное подтверждение (вместо confirm) */

.modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(20, 22, 26, .32);
}

.modal[hidden] { display: none; }

.modal__card {
    width: 100%;
    max-width: 420px;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    animation: modal-in .14s ease-out;
}

.modal__title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.modal__text {
    color: var(--text-2);
    font-size: 14px;
    margin-bottom: 20px;
}

.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(-8px) scale(.98); }
    to { opacity: 1; transform: none; }
}

/* ------------------------------------------- Превью поста «как в MAX» */

.post-preview {
    min-height: 220px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 15px;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.post-preview code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--surface-2);
    font-family: var(--mono);
    font-size: 13px;
}

.post-preview pre {
    margin: 8px 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-family: var(--mono);
    font-size: 13px;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* ---------------------------------------------------------------- Медиа */

.media-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.media-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.media-item__thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    flex: 0 0 auto;
}

.media-item__info {
    min-width: 0;
    flex: 1;
}

.media-item__name {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-item__actions {
    display: flex;
    gap: 2px;
    flex: 0 0 auto;
}

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

.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

@media (max-width: 1000px) {
    .calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
    .calendar { grid-template-columns: minmax(0, 1fr); }
}

.calendar__day {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    min-height: 140px;
    display: flex;
    flex-direction: column;
}

.calendar__day--weekend { background: var(--surface); }

.calendar__day--today {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.calendar__head {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
}

.calendar__date {
    font-weight: 600;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.calendar__weekday {
    font-size: 11px;
    color: var(--text-3);
}

.calendar__body {
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.calendar__empty {
    color: var(--text-3);
    font-size: 13px;
    text-align: center;
    padding-top: 12px;
}

.calendar__item {
    display: block;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-size: 13px;
    line-height: 1.35;
}

.calendar__item:hover {
    background: var(--accent-soft);
    text-decoration: none;
}

.calendar__item--scheduled { border-left-color: var(--accent); }
.calendar__item--published { border-left-color: var(--ok); }
.calendar__item--review { border-left-color: var(--warn); }
.calendar__item--failed { border-left-color: var(--danger); }

.calendar__time {
    display: block;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-2);
}

.calendar__title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar__legend {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    border-left-width: 3px;
    border-left-style: solid;
    background: var(--surface-2);
    margin-right: 4px;
}

/* --------------------------------------------------------------- Утилиты */

.row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.row--between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
