:root {
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    /* Основной синий */
    --accent-hover: #2980b9;
    --bg-color: #f4f6f9;
    /* Чуть холоднее, чем раньше */
    --text-color: #34495e;
    --sidebar-width: 280px;
}

body {
    background-color: var(--bg-color);
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    /* Сглаживание шрифтов */
}

/* --- ХЕДЕР --- */
.header-bg {
    background: #ffffff;
    /* Делаем хедер белым для свежести */
    color: var(--primary-color);
    padding: 12px 25px;
    box-shadow: 0 1px 10px rgba(0, 0, 0, 0.05);
    /* Очень мягкая тень */
    border-bottom: 1px solid #eee;
    z-index: 1020;
}

/* Логотип */
.header-bg h4 {
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* --- ПОИСК --- */
.input-group-text {
    background-color: #f8f9fa;
    border-color: #e9ecef;
}

#global-pub-search {
    background-color: #f8f9fa;
    transition: all 0.2s;
}

#global-pub-search:focus {
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

#search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid #eee;
    max-height: 400px;
    overflow-y: auto;
}

/* --- КАРТОЧКИ И КОНТЕЙНЕРЫ --- */
.card {
    /* Relying on theme-enterprise.css for borders and radius */
    box-shadow: none;
    /* Forced flat */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
}

/* --- САЙДБАР (ЛЕВОЕ МЕНЮ) --- */
#settingsTabs .list-group-item {
    border: none;
    border-radius: 8px;
    margin-bottom: 6px;
    color: #6c757d;
    font-weight: 500;
    padding: 10px 15px;
    transition: all 0.2s;
}

#settingsTabs .list-group-item:hover {
    background-color: #eef2f7;
    color: var(--primary-color);
}

#settingsTabs .list-group-item.active {
    background-color: #eef6ff;
    /* Светло-голубой фон */
    color: var(--accent-color);
    font-weight: 600;
}

#settingsTabs .list-group-item i {
    width: 20px;
    text-align: center;
}

/* --- НОВЫЙ БЛОК ИНФО О ФОРМЕ --- */
/* Стили для кнопок внутри карточки формы */
.btn-white {
    background-color: #fff;
    color: #555;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-white:hover {
    background-color: #f8f9fa;
    color: #333;
    border-color: #ccc;
}

/* Заголовок формы (который можно редактировать) */
.editable-title {
    border-bottom: 1px dashed transparent;
    transition: all 0.2s;
}

.editable-title:hover {
    color: var(--accent-color) !important;
    border-bottom-color: var(--accent-color);
}

/* Поле ввода главного заголовка */
#inp-pub-title {
    font-size: 1.25rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-bottom: 2px solid #eee;
    background: transparent;
    padding-left: 0;
    border-radius: 0;
    color: var(--primary-color);
}

#inp-pub-title:focus {
    box-shadow: none;
    border-bottom-color: var(--accent-color);
    background: #fff;
    padding-left: 10px;
    /* Чтобы текст не прилипал при вводе */
}

/* --- КОНТЕНТ --- */
.tab-content {
    padding: 5px;
    /* Убрали лишние отступы, так как теперь есть карточки */
    min-height: calc(100vh - 150px);
}

.tab-pane {
    animation: fadeIn 0.3s ease-in-out;
}

/* --- BUILDER AREA --- */
#builder-container {
    border-top: 2px dashed #eee;
    padding-top: 20px;
}

.formbuilder-parent {
    background: #fff;
    border: 1px solid #eee;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.02);
}

/* --- УТИЛИТЫ --- */
.border-left-warning {
    border-left: 4px solid #ffc107 !important;
    background-color: #fffcf0;
    color: #856404;
}

/* Анимация появления */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Скроллбары */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

/* --- ACCESSIBILITY (WCAG 2.1 AA) --- */

/* Skip Link */
.sr-only-focusable:focus {
    clip: auto !important;
    clip-path: none !important;
    display: block !important;
    height: auto !important;
    margin: 0 !important;
    overflow: visible !important;
    position: fixed !important;
    top: 10px !important;
    left: 10px !important;
    width: auto !important;
    z-index: 10001 !important;
    padding: 10px 20px !important;
    background: var(--accent-color) !important;
    color: white !important;
    border-radius: 4px !important;
    text-decoration: none !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
}

/* Фокус-индикатор для клавиатурных пользователей */
:focus-visible {
    outline: 3px solid #2563eb !important;
    /* Using a clear blue for focus */
    outline-offset: 3px !important;
    box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.3) !important;
}

/* Убираем стандартный аутлайн там, где есть focus-visible */
:focus:not(:focus-visible) {
    outline: none !important;
}

/* Улучшение контраста для второстепенного текста */
.text-muted,
small.text-muted,
.text-secondary {
    color: #4b5563 !important;
    /* Darker gray (Slate 600) for 4.5:1 ratio */
}

/* Контрастные плейсхолдеры */
::placeholder {
    color: #666 !important;
    opacity: 1;
    /* Firefox */
}

/* Обеспечиваем видимость фокуса на интерактивных элементах */
.btn:focus,
.form-control:focus,
.list-group-item:focus {
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25) !important;
}

/* Специальный фокус для кастомных переключателей (Bootstrap switches) */
.custom-control-input:focus~.custom-control-label::before {
    box-shadow: 0 0 0 1px #fff, 0 0 0 0.25rem rgba(37, 99, 235, 0.45) !important;
    border-color: #2563eb !important;
}

/* Только при фокусе с клавиатуры для современных браузеров */
.custom-control-input:focus-visible~.custom-control-label::before {
    box-shadow: 0 0 0 2px #fff, 0 0 0 0.4rem rgba(37, 99, 235, 0.6) !important;
}

/* --- НОВЫЕ КНОПКИ И ПЕРЕКЛЮЧАТЕЛИ --- */
#btn-new-publication {
    font-weight: bold;
    border-radius: 8px;
}

.custom-switch-lg .custom-control-label::before {
    left: -3.5rem;
    width: 3rem;
    height: 1.5rem;
    border-radius: 1rem;
}

.custom-switch-lg .custom-control-label::after {
    top: calc(.25rem + 2px);
    left: calc(-3.5rem + 2px);
    width: calc(1.5rem - 4px);
    height: calc(1.5rem - 4px);
    border-radius: 1rem;
}

.custom-switch-lg .custom-control-input:checked~.custom-control-label::after {
    transform: translateX(1.5rem);
}

.custom-switch-lg {
    padding-left: 4.25rem;
    padding-top: 0.2rem;
}

/* --- МОБИЛЬНАЯ АДАПТАЦИЯ САЙДБАРА --- */
@media (max-width: 768px) {
    #settingsTabs {
        flex-direction: row;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    #settingsTabs .list-group-item {
        border-left: none;
        border-bottom: 3px solid transparent;
        border-radius: 8px 8px 0 0;
        display: inline-block;
        margin-bottom: 0;
        padding: 10px 15px;
    }

    #settingsTabs .list-group-item.active {
        border-left: none;
        border-bottom: 3px solid var(--accent-color);
        border-radius: 8px 8px 0 0;
    }
}

/* Sidebar Collapse & Sticky */
.sidebar-column {
    transition: all 0.3s ease;
    position: sticky;
    top: 76px;
    /* header (~52px) + container mt-4 (24px) */
    align-self: flex-start;
    height: calc(100vh - 90px);
    /* viewport minus header + spacing */
    z-index: 100;
}

.sidebar-column .card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1) !important;
}

.sidebar-column nav {
    flex: 0 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-bottom {
    flex-shrink: 0;
    margin-top: auto;
    background: transparent !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
    transition: all 0.3s ease;
    background: transparent !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Ensure auth.js badge-success doesn't break our sidebar layout */
.sidebar-footer #status-badge.badge {
    display: block;
    width: 100%;
    background: transparent !important;
    color: #cbd5e1 !important;
    /* Slate 300 to match theme */
    text-align: left;
    padding: 0;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: none !important;
}

/* Removed redundant sidebar-bottom collapsed styles */

.sidebar-collapsed .sidebar-footer {
    padding: 0.75rem 0 !important;
    text-align: center;
    display: flex;
    justify-content: center;
}

.sidebar-collapsed .sidebar-footer .btn {
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.sidebar-collapsed .sidebar-footer .btn span {
    display: none !important;
}

.sidebar-collapsed .sidebar-footer .btn i {
    margin-right: 0 !important;
    font-size: 1.1rem;
}

/* Hide scrollbar for cleaner look if needed */
.sidebar-column::-webkit-scrollbar {
    width: 4px;
}

.sidebar-column::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.main-column {
    transition: all 0.3s ease;
    min-height: calc(100vh - 100px);
}

.sidebar-collapsed .sidebar-column {
    flex: 0 0 90px;
    max-width: 90px;
}

.sidebar-collapsed .main-column {
    flex: 0 0 calc(100% - 90px);
    max-width: calc(100% - 90px);
}

/* --- Sidebar text labels: smooth fade transition --- */
.sidebar-column .list-group-item span,
.sidebar-column .list-group-item .badge {
    display: inline-block;
    opacity: 1;
    max-width: 200px;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease, max-width 0.25s ease, margin 0.25s ease;
}

.sidebar-collapsed .sidebar-column .list-group-item {
    padding: 0.8rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sidebar-collapsed .sidebar-column .list-group-item i {
    margin-right: 0 !important;
    font-size: 1.2rem;
    transition: margin 0.25s ease, font-size 0.25s ease;
}

.sidebar-collapsed .sidebar-column .list-group-item span,
.sidebar-collapsed .sidebar-column .list-group-item .badge {
    opacity: 0;
    max-width: 0;
    margin-left: 0;
    margin-right: 0;
    pointer-events: none;
}

.sidebar-collapsed .sidebar-toggle-container {
    text-align: center !important;
}

.sidebar-collapsed #btn-toggle-sidebar i {
    transform: rotate(180deg);
}

.sidebar-toggle-container button {
    transition: transform 0.3s ease;
}

@media (max-width: 768px) {
    .sidebar-toggle-container {
        display: none !important;
    }
}

/* Отключение интерактивности (кликов, загрузок) для компонентов внутри конструктора HTML */
#formio-builder .formio-component-file .fileSelector,
#formio-builder .formio-component-button button {
    pointer-events: none !important;
}