/* Базовые настройки в стиле Bitrix.Admin */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f6f9;
    color: #333;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* ==================== СТРАНИЦА АВТОРИЗАЦИИ ==================== */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: #fff;
    padding: 30px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #dce1e6;
}

.login-container h1 {
    font-size: 22px;
    margin-bottom: 5px;
    text-align: center;
    color: #111;
}

.login-container p {
    font-size: 13px;
    color: #777;
    text-align: center;
    margin-bottom: 25px;
}

/* Универсальные стили для ВСЕХ текстовых полей ввода */
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="datetime-local"],
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dce1e6;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
    background-color: #f8f9fa;
    color: #333;
    transition: border-color 0.2s, background-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: #a1c4fd;
    background-color: #fff;
    outline: none;
}

/* ==================== ШАПКА И НАВИГАЦИЯ ==================== */
header {
    background: #fff;
    border-bottom: 1px solid #e2e7eb;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    padding: 0 25px;
    height: 60px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    height: 33px;
}

/* На десктопе .header-top становится невидимым контейнером, чтобы лого и профиль выстроились в ряд */
.header-top {
    display: contents;
}

.logo {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
    text-decoration: none;
    order: 1;
}

.logo span {
    color: #007bff;
}

.header-bottom {
    order: 2;
    width: auto;
    background: transparent;
    padding: 0;
    overflow-x: visible;
    display: flex;
    align-items: center;
    margin-left: 40px;
    height: 33px;
}

.top-nav {
    display: flex;
    gap: 4px;
}

.nav-link {
    background: none;
    border: none;
    padding: 8px 14px;
    font-size: 13px;
    color: #4b5563;
    cursor: pointer;
    border-radius: 4px;
    text-decoration: none;
    display: inline-block;
}

.nav-link:hover {
    background: #eeeff1;
    color: #111;
}

.nav-link.active {
    background: #e1f0ff;
    color: #007bff;
    font-weight: 500;
}

.user-block {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #4b5563;
    order: 3;
    margin-left: auto;
    white-space: nowrap;
}

.btn-logout {
    color: #9ca3af;
    text-decoration: none;
    font-weight: 500;
    margin-left: 2px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-logout:hover {
    color: #dc2626;
}

.logout-icon {
    font-size: 15px;
}

/* ==================== МЕДИА-ЗАПРОСЫ ДЛЯ МОБИЛЬНЫХ ЭКРАНОВ ==================== */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: 0;
        height: auto;
    }

    .header-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 12px 20px;
        box-sizing: border-box;
        border-bottom: 1px solid #f3f4f6;
    }

    .header-bottom {
        order: unset;
        width: 100%;
        background: #fafafa;
        padding: 6px 15px;
        box-sizing: border-box;
        overflow-x: auto;
        white-space: nowrap;
        margin-left: 0;
        display: flex;
        align-items: center;
    }

    .header-bottom::-webkit-scrollbar {
        display: none;
    }

    .logo {
        order: unset;
    }

    .user-block {
        order: unset;
        margin-left: 0;
    }

    .btn-logout .logout-text {
        display: none;
    }

    .btn-logout {
        padding: 4px 6px;
        background: #f1f5f9;
        border-radius: 4px;
    }
}

/* Приветственный экран */
.welcome-card {
    background: #fff;
    padding: 40px;
    text-align: center;
    border-radius: 6px;
    border: 1px solid #e2e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* ==================== ОСНОВНОЙ КОНТЕНТ ==================== */
.container {
    max-width: 1400px;
    margin: 25px auto;
    padding: 0 20px;
    flex-grow: 1;
    /* Растягивает область контента, прижимая футер */
    width: 100%;
}

/* ==================== ПОДВАЛ (FOOTER) ==================== */
.app-footer {
    background: #fff;
    border-top: 1px solid #e2e7eb;
    padding: 15px 20px;
    text-align: center;
    font-size: 13px;
    color: #64748b;
    margin-top: auto;
    /* Прижимает к низу */
}

.app-footer a {
    color: #0284c7;
    text-decoration: none;
    font-weight: 600;
}

.app-footer a:hover {
    text-decoration: underline;
}

h2 {
    font-size: 20px;
    color: #111;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 13px;
    color: #777;
    margin-bottom: 25px;
}

/* Сетка формы: две колонки */
.form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    align-items: start;
}

.form-card {
    background: #fff;
    padding: 25px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e7eb;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    margin-bottom: 8px;
}

/* Кнопка Опубликовать */
.btn-submit-green {
    background: #10b981;
    color: white;
    border: none;
    padding: 14px;
    font-size: 15px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    margin-top: 15px;
    transition: background 0.2s;
}

.btn-submit-green:hover {
    background: #059669;
}

/* Драг-энд-дроп зоны */
.upload-zone {
    border: 2px dashed #cbd5e1;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 25px;
    text-align: center;
    cursor: pointer;
    color: #64748b;
    font-size: 13px;
    margin-bottom: 15px;
    transition: all 0.2s;
}

.upload-zone:hover {
    border-color: #3b82f6;
    background: #eff6ff;
    color: #1d4ed8;
}

.upload-zone svg {
    width: 28px;
    height: 28px;
    margin-bottom: 6px;
    fill: currentColor;
}

/* Чекбоксы дополнительных опций */
.options-group {
    margin-top: 15px;
    border-top: 1px solid #e5e7eb;
    padding-top: 15px;
}

.options-group h4 {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #444;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #333;
    margin-bottom: 8px;
    cursor: pointer;
}

/* Таблицы */
.news-table-wrapper {
    width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 15px;
    border: 1px solid #e2e7eb;
    border-radius: 6px;
}

.news-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    min-width: 600px !important;
    /* Гарантируем, что таблица не сожмется меньше 600px и скролл сработает */
}

.news-table th,
.news-table td {
    padding: 12px 15px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid #efefef;
}

.news-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #444;
}

.badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.bg-danger {
    background: #fee2e2;
    color: #dc2626;
}

.bg-info {
    background: #e0f2fe;
    color: #0369a1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}


/* Десктоп-версия теперь является стандартной по умолчанию */

/* Сетка выбора кадров в модальном окне (пропорции 16:9) */
#modal-thumbs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
    overflow-y: auto;
    flex: 1;
    padding: 10px 5px;
    align-items: start;
    grid-auto-rows: min-content;
    /* Схлопывает пустую высоту строк */
}

.thumb-wrapper {
    cursor: pointer;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    transition: 0.2s;
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}

.thumb-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@media (max-width: 600px) {
    #modal-thumbs-grid {
        grid-template-columns: 1fr;
        /* На мобильном 1 столбец */
    }
}

/* Адаптивность для формы */
@media (max-width: 900px) {
    .form-grid {
        grid-template-columns: 1fr !important;
        /* На узких экранах медиа-блоки уходят под тексты */
        gap: 20px;
    }

    .container {
        padding: 0 10px;
        margin: 15px auto;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }

    .form-card {
        padding: 15px;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }

    body,
    html {
        max-width: 100vw;
        overflow-x: hidden;
    }
}