/* Основные стили */
:root {
    --primary-color: #4285F4;
    --secondary-color: #FFC107;
    --text-color: #333;
    --sidebar-width: 250px;
    --header-height: 60px;
    --content-max-width: 1200px; /* Максимальная ширина контента */
}

body {
    font-family: 'Roboto', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f7fa;
    color: var(--text-color);
    overflow-x: hidden; /* Предотвращаем горизонтальную прокрутку на уровне body */
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%; /* Явно задаем ширину контейнера */
    position: relative; /* Добавляем для корректного позиционирования */
    overflow-x: hidden; /* Предотвращаем горизонтальную прокрутку внутри контейнера */
}

/* Стили для бокового меню */
.sidebar {
    width: var(--sidebar-width);
    background-color: #f8f8f8;
    height: 100%;
    position: fixed;
    left: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e0e0e0;
    z-index: 10; /* Обеспечиваем, чтобы сайдбар был поверх остального контента */
}

.logo {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
}

.logo h2 {
    margin: 0;
    color: var(--primary-color);
}

.logo span {
    background-color: var(--secondary-color);
    color: white;
    padding: 2px 5px;
    border-radius: 4px;
}

.menu {
    flex: 1;
    padding: 20px 0;
}

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

.menu li {
    margin-bottom: 5px;
}

.menu a {
    display: block;
    padding: 8px 16px;
    margin: 0 8px;
    color: var(--text-color);
    text-decoration: none;
    transition: background-color 0.2s;
    border-radius: 8px;
}

.menu a:hover, .menu li.active a {
    background-color: rgba(66, 133, 244, 0.1);
    color: var(--primary-color);
}

.menu a i {
    margin-right: 10px;
}

.bottom-menu {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
}

/* Стили для основного контента */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 20px;
    flex: 1;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden; /* Предотвращаем горизонтальную прокрутку для основного контента */
    width: calc(100% - var(--sidebar-width)); /* Фиксируем ширину основного контента */
    display: flex;
    flex-direction: column;
    align-items: center; /* Центрируем содержимое по горизонтали */
}

.main-content > * {
    width: 100%;
    max-width: var(--content-max-width); /* Максимальная ширина для всех прямых потомков */
}

.header {
    height: auto;
    min-height: 112px;
    margin-bottom: 14px;
    width: 100%;
    max-width: var(--content-max-width);
    background-color: white;
    border: 1px solid #e8edf5;
    border-radius: 14px;
    padding: 10px 18px;
    box-shadow: 0 8px 28px rgba(31, 52, 82, 0.07);
}

.header-content {
    display: grid;
    grid-template-columns: minmax(0, 1.34fr) minmax(380px, 1fr);
    align-items: center;
    gap: 32px;
    min-height: 90px;
    height: auto;
}

.template-summary {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 16px;
}

.header-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.template-meta-row {
    min-height: 30px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;
}

.template-eyebrow {
    color: #7b879d;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
}

.template-title-row {
    min-width: 0;
}

.template-content-accent {
    position: relative;
    min-width: 0;
    margin-top: 3px;
    padding-left: 13px;
}

.template-content-accent::before {
    content: "";
    position: absolute;
    top: 2px;
    bottom: 1px;
    left: 0;
    width: 3px;
    border-radius: 3px;
    background: #3157e5;
}

.template-title-row h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header h1 {
    margin: 0;
    color: #11213f;
    font-size: 25px;
    font-weight: 700;
    line-height: 1.2;
}

.header p {
    margin: 5px 0 0;
    color: #77839a;
    font-size: 14px;
    line-height: 1.35;
}

.template-title-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.template-title-action {
    width: 30px;
    height: 30px;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border: 1px solid #dfe5ee;
    border-radius: 8px;
    color: #33415c;
    background: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.template-title-action:hover,
.template-title-action:focus-visible {
    border-color: #b9cdf9;
    color: var(--primary-color);
    background: #f7faff;
    outline: none;
}

.template-title-action-danger:hover,
.template-title-action-danger:focus-visible {
    border-color: #f1c3c8;
    color: #c63d4b;
    background: #fff7f8;
}

.template-title-action img {
    width: 16px;
    height: 16px;
}

.header-template-file {
    min-width: 0;
}

.template-file-block {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    min-height: 68px;
    padding: 6px 10px;
    border: 1px solid #cfe0ff;
    border-radius: 13px;
    background: #f5f9ff;
}

.template-file-details {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 12px;
    padding-right: 14px;
}

.template-file-icon {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: #fff;
}

.template-file-icon img {
    width: 32px;
    height: 32px;
}

.template-file-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 5px;
}

#templateFileName {
    overflow: hidden;
    color: #14223d;
    font-size: 16px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#templateFileDateBlock {
    color: #7d899e;
    font-size: 13px;
    white-space: nowrap;
}

.template-file-actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 6px;
    padding-left: 12px;
    border-left: 1px solid #dbe6f7;
}

.template-file-action {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 62px;
    min-height: 50px;
    gap: 4px;
    padding: 4px 6px;
    border: 0;
    border-radius: 10px;
    color: #315baf;
    background: transparent;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.template-file-action:hover,
.template-file-action:focus-visible {
    color: #2f6fd7;
    background-color: rgba(66, 133, 244, 0.1);
    outline: none;
}

.template-file-action-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dce7f8;
    border-radius: 9px;
    background: #fff;
}

.template-file-action-icon img {
    width: 17px;
    height: 17px;
    display: block;
    filter: brightness(0) saturate(100%) invert(35%) sepia(89%) saturate(1517%) hue-rotate(214deg) brightness(94%) contrast(91%);
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(0, .78fr) minmax(0, 1.22fr);
    height: 112px;
    min-height: 112px;
    margin-bottom: 14px;
    align-items: stretch;
    width: 100%;
    max-width: var(--content-max-width);
    background-color: white;
    border: 1px solid #e8edf5;
    border-radius: 14px;
    padding: 10px 18px;
    box-shadow: 0 8px 28px rgba(31, 52, 82, 0.07);
}

.toolbar-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 8px;
    padding-right: 18px;
}

.toolbar-group.document-create-block {
    display: flex;
    align-items: center;
}

.toolbar-copy {
    min-width: 0;
}

.toolbar h2 {
    margin: 0;
    color: #11213f;
    font-size: 20px;
    font-weight: 700;
}

.toolbar-copy p {
    margin: 5px 0 0;
    color: #77839a;
    font-size: 14px;
}

.toolbar button {
    padding: 8px 16px;
    font-weight: 500;
}

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

.document-output-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding-left: 18px;
    border-left: 1px solid #e6ebf2;
}

.actions-btn-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.toolbar .actions-btn-group .btn {
    width: auto;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid #e0e5ed;
    border-radius: 10px;
    color: #14223d;
    background: #fff;
    font-weight: 600;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.toolbar .actions-btn-group .btn:hover,
.toolbar .actions-btn-group .btn:focus-visible {
    border-color: #b9cdf9;
    color: var(--primary-color);
    background: #f7faff;
    outline: none;
}

.toolbar .actions-btn-group .primary-output-action {
    border-color: #bfd1fb;
    background: #f3f7ff;
    color: #2455d6;
}

.toolbar .actions-btn-group .primary-output-action:hover,
.toolbar .actions-btn-group .primary-output-action:focus-visible {
    border-color: #8cacfa;
    background: #eaf1ff;
}

.actions-btn-group .btn img {
    display: block;
    width: 22px;
    height: 22px;
}

/* Стили для списка шаблонов */
.templates-list {
    background-color: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: var(--content-max-width);
}

.template-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
    cursor: default;
    position: relative;
    transition: all 0.2s ease;
    pointer-events: none;
}

.template-item:last-child {
    border-bottom: none;
}

.template-item.active {
    background-color: white;
}

.template-item.active::before {
    display: none;
}

.template-icon {
    font-size: 24px;
    margin-right: 15px;
    color: #4285F4;
}

.template-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    cursor: default;
    pointer-events: none;
}

.template-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.template-date {
    font-size: 0.9em;
    color: #666;
}

.template-actions {
    margin-left: auto;
}

.template-actions .btn {
    padding: 4px 8px;
}

/* Стили для табов */
.tabs {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: var(--content-max-width);
}

.nav-tabs {
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 20px;
    display: flex;
    width: 100%;
}

.nav-tabs .nav-item {
    margin-bottom: -2px;
    flex: 1;
}

.nav-tabs .nav-link {
    border: none;
    color: #666;
    font-weight: 500;
    padding: 12px 24px;
    position: relative;
    width: 100%;
    text-align: center;
}

.nav-tabs .nav-link.active {
    border: none;
    color: var(--primary-color);
}

.nav-tabs .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--primary-color);
}

.tab-content {
    padding-top: 20px;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Стили для ввода полей  */
.field-inputs, .table-inputs {
    margin-bottom: 20px;
}

/* Стили для таблиц */
.fields-table, .items-table {
    margin-top: 20px;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background-color: #f8f8f8 !important;
    font-weight: 600 !important;
    border-bottom: 2px solid #f8f8f8 !important;
    color: #495057 !important;
}

.table th#but4 {
    border-radius: 0 8px 8px 0;
}

.table th#but1 {
    border-radius: 8px 0 0 8px;
}

.table td, .table th {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

/* Стили для таблицы товаров */
.table-instruction {
    color: #666;
    font-style: normal;
    margin-bottom: 15px;
}

/* Выделение кликабельных меток в тексте инструкций */
.table-instruction .tag-chip {
    color: #0066cc !important;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: rgba(0, 102, 204, 0.05);
    border: 1px solid rgba(0, 102, 204, 0.1);
    transition: all 0.2s ease;
}

.table-instruction .tag-chip:hover {
    background-color: rgba(0, 102, 204, 0.1);
    border-color: rgba(0, 102, 204, 0.2);
}

/* Стили для кнопок в таблицах - делаем их одинаковыми */
.input-as-th .btn {
    min-height: 38px;
    padding: 8px 16px;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
}

/* Стили для модального окна форматов */
.format-list {
    width: 100%;
    border-collapse: collapse;
}

.format-table {
    width: 100%;
    border-collapse: collapse;
}

.format-table th, .format-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.format-table th {
    background-color: #f8f8f8 !important;
    font-weight: 600 !important;
    border-bottom: 2px solid #dee2e6 !important;
    color: #495057 !important;
}

.format-table tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
    cursor: default;
}

.format-table tr.selected {
    background-color: rgba(0, 123, 255, 0.1);
}

/* Базовые стили для format-id перенесены в конец файла */

.format-value {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Добавляем стили для анимации обновления ячейки */
.format-table .format-value {
    transition: background-color 0.3s ease;
}

.format-table .format-value.updating {
    background-color: #fff8e5;
}

.format-description {
    color: #666;
    max-width: 300px;
}

.format-name {
    font-weight: 500;
}

.format-example {
    color: #666;
    font-style: italic;
}

/* Добавим стили для выделения строки таблицы */
.format-table tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

.format-table tr:hover {
    background-color: #f5f8ff;
}

.format-table tr.selected {
    background-color: #e6f0ff;
    border-left: 3px solid #4285F4;
}

/* Стили для панели инструментов форматирования */
.format-toolbar {
    padding: 10px 15px;
    border-bottom: 1px solid #e9ecef;
    background-color: #f8f9fa;
}

.format-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tool-group {
    display: flex;
    gap: 4px;
    border-right: 1px solid #dee2e6;
    padding-right: 8px;
    margin-right: 4px;
}

.tool-group:last-child {
    border-right: none;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #dee2e6;
    background-color: #ffffff;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

.tool-btn:hover {
    background-color: #f0f2f5;
    border-color: #c6c9cc;
}

.tool-btn.active {
    background-color: #e7f5ff;
    border-color: #90c8f8;
    color: #0d6efd;
}

/* Стили для кнопок форматирования в таблице */
.tool-btn-small {
    padding: 2px 4px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    margin-right: 2px;
    cursor: pointer;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tool-btn-small:hover {
    background: #e9ecef;
}

.tool-btn-small.active {
    background: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

.format-buttons {
    white-space: nowrap;
}

.format-buttons .format-tools {
    display: flex;
    justify-content: center;
    gap: 2px;
}

/* Стили для таблицы форматов */
.format-table {
    width: 100%;
    border-collapse: collapse;
}

.format-table th,
.format-table td {
    border: 1px solid #dee2e6;
    padding: 8px;
    vertical-align: middle;
}

.format-table tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
    cursor: default;
}

.format-table tr.selected {
    background-color: rgba(0, 123, 255, 0.1);
}

/* Скрытие столбца "Формат" в таблице форматов */
.format-table th:nth-child(2),
.format-table td:nth-child(2) {
    display: none; /* Чтобы вернуть столбец "Формат", измените на display: table-cell; */
}

/* Стили для колонки "Значение" (4-я колонка) - для переноса длинных формул */
.format-table td:nth-child(4) {
    max-width: 300px;
    white-space: normal;
    word-break: break-all;
    hyphens: auto;
    line-height: 1.4;
}

/* Адаптивные стили */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    
    .logo h2 {
        font-size: 0;
    }
    
    .logo span {
        font-size: 16px;
    }
    
    .menu a span {
        display: none;
    }
    
    .menu a i {
        margin-right: 0;
        font-size: 20px;
    }
    
    .main-content {
        margin-left: 60px;
        width: calc(100% - 60px);
    }
    
    :root {
        --content-max-width: 100%; /* На маленьких экранах используем всю доступную ширину */
    }
}

/* Универсальные стили для всех экранов с высокой плотностью пикселей */
@media screen and (min-resolution: 144dpi) {
    /* Оптимизируем компоновку для предотвращения прокрутки */
    .container-fluid {
        max-height: 100vh;
        overflow: hidden;
    }

    .main-content {
        display: flex;
        flex-direction: column;
        max-height: calc(100vh - 60px); /* Учитываем высоту навигации */
    }

    .tabs {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .tab-content {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .fields-table, .items-table {
        flex: 1;
        overflow-y: auto;
        max-height: none;
    }

    /* Компактные отступы */
    .header {
        padding: 10px 15px;
        margin-bottom: 10px;
    }

    .toolbar {
        padding: 8px 15px;
        margin-bottom: 10px;
    }

    .nav-tabs {
        margin-bottom: 10px;
    }

    .table td, .table th {
        padding: 8px 10px;
        font-size: 13px;
    }

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

    .field-inputs td, .table-inputs td {
        padding-top: 10px;
    }
}

/* Стили для ноутбуков с высоким разрешением (например, 2880×1620) */
/* Обновленные условия для Retina экранов */
@media screen and (min-device-pixel-ratio: 2) and (max-height: 900px),
       screen and (-webkit-min-device-pixel-ratio: 2) and (max-height: 900px),
       screen and (min-resolution: 192dpi) and (max-height: 900px),
       screen and (min-resolution: 2dppx) and (max-height: 900px) {
    /* Уменьшаем отступы для экономии места */
    .main-content {
        padding: 15px;
    }
    
    .header {
        margin-bottom: 15px;
        padding: 15px;
    }
    
    .toolbar {
        margin-bottom: 15px;
        padding: 10px 15px;
    }
    
    .tabs {
        padding: 15px;
    }
    
    /* Уменьшаем высоту заголовка */
    .header h1 {
        font-size: 22px;
        margin-bottom: 5px;
    }
    
    .header p {
        font-size: 14px;
        margin: 0;
    }
    
    /* Делаем более компактными вкладки */
    .nav-tabs .nav-link {
        padding: 8px 20px;
        font-size: 14px;
    }
    
    /* Увеличиваем высоту таблицы с метками */
    .fields-table, .items-table {
        max-height: calc(100vh - 280px); /* Динамический расчет высоты */
        overflow-y: auto;
    }
    
    /* Уменьшаем отступы в ячейках таблицы */
    .table td, .table th {
        padding: 10px 12px;
    }
    
    /* Делаем форму добавления меток более компактной */
    .field-inputs td, .table-inputs td {
        padding-top: 15px; /* Уменьшаем с 20px */
    }
    
    /* Компактные кнопки в toolbar */
    .toolbar button {
        padding: 6px 14px;
        font-size: 14px;
    }
    
    .actions-btn-group .btn {
        width: 36px;
        height: 36px;
    }
}

/* Дополнительная оптимизация для ноутбуков 15" с высоким разрешением */
@media screen and (max-width: 1440px) and (max-height: 900px) and (min-device-pixel-ratio: 2),
       screen and (max-width: 1440px) and (max-height: 900px) and (-webkit-min-device-pixel-ratio: 2) {
    /* Еще больше уменьшаем отступы */
    .main-content {
        padding: 12px;
    }
    
    .header, .toolbar, .tabs {
        margin-bottom: 12px;
    }
    
    .header {
        padding: 12px;
    }
    
    .toolbar {
        padding: 8px 12px;
    }
    
    .tabs {
        padding: 12px;
    }
    
    /* Максимально увеличиваем высоту таблицы */
    .fields-table, .items-table {
        max-height: calc(100vh - 250px);
        overflow-y: auto;
    }

    /* Оптимизируем высоту всего содержимого */
    body {
        overflow: hidden;
    }

    .container, .container-fluid {
        height: 100vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .main-content {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .tabs {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .tab-content {
        flex: 1;
        overflow: hidden;
    }
    
    /* Более компактные элементы управления */
    .nav-tabs {
        margin-bottom: 15px;
    }
    
    .tab-content {
        padding-top: 15px;
    }
    
    /* Уменьшаем высоту полей ввода */
    .form-control-bottom-border {
        padding: 0.25rem 0;
    }
    
    /* Компактные floating labels */
    .floating-label {
        font-size: 0.8rem;
        transform: translateY(-1.3rem) scale(0.85);
    }
}

@media (min-width: 1600px) {
    :root {
        --content-max-width: 1400px; /* Для очень широких экранов увеличиваем немного */
    }
}

/* Стили для элементов печати */
.print-frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    border: none;
    background: white;
}

.print-close-button {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 10000;
    padding: 8px 15px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background 0.3s;
}

.print-close-button:hover {
    background: #c0392b;
}

.print-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 18px;
}

.print-loading .spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Карточки на страницах шаблонов */
.card {
    width: 100%;
    max-width: var(--content-max-width);
}

/* Стили для модальных окон ошибок с высоким z-index */
#errorModal {
    z-index: 10050 !important;
}

#errorModal .modal-backdrop {
    z-index: 10049 !important;
}

/* Кастомный лоадер для страницы templates */
.custom-loader {
    font-size: 10px;
    width: 1em;
    height: 1em;
    border-radius: 50%;
    position: relative;
    text-indent: -9999em;
    animation: mulShdSpin 1.1s infinite ease;
    transform: translateZ(0);
}

@keyframes mulShdSpin {
    0%,
    100% {
        box-shadow: 0em -2.6em 0em 0em #ffffff, 1.8em -1.8em 0 0em rgba(255,255,255, 0.2), 2.5em 0em 0 0em rgba(255,255,255, 0.2), 1.75em 1.75em 0 0em rgba(255,255,255, 0.2), 0em 2.5em 0 0em rgba(255,255,255, 0.2), -1.8em 1.8em 0 0em rgba(255,255,255, 0.2), -2.6em 0em 0 0em rgba(255,255,255, 0.5), -1.8em -1.8em 0 0em rgba(255,255,255, 0.7);
    }
    12.5% {
        box-shadow: 0em -2.6em 0em 0em rgba(255,255,255, 0.7), 1.8em -1.8em 0 0em #ffffff, 2.5em 0em 0 0em rgba(255,255,255, 0.2), 1.75em 1.75em 0 0em rgba(255,255,255, 0.2), 0em 2.5em 0 0em rgba(255,255,255, 0.2), -1.8em 1.8em 0 0em rgba(255,255,255, 0.2), -2.6em 0em 0 0em rgba(255,255,255, 0.2), -1.8em -1.8em 0 0em rgba(255,255,255, 0.5);
    }
    25% {
        box-shadow: 0em -2.6em 0em 0em rgba(255,255,255, 0.5), 1.8em -1.8em 0 0em rgba(255,255,255, 0.7), 2.5em 0em 0 0em #ffffff, 1.75em 1.75em 0 0em rgba(255,255,255, 0.2), 0em 2.5em 0 0em rgba(255,255,255, 0.2), -1.8em 1.8em 0 0em rgba(255,255,255, 0.2), -2.6em 0em 0 0em rgba(255,255,255, 0.2), -1.8em -1.8em 0 0em rgba(255,255,255, 0.2);
    }
    37.5% {
        box-shadow: 0em -2.6em 0em 0em rgba(255,255,255, 0.2), 1.8em -1.8em 0 0em rgba(255,255,255, 0.5), 2.5em 0em 0 0em rgba(255,255,255, 0.7), 1.75em 1.75em 0 0em #ffffff, 0em 2.5em 0 0em rgba(255,255,255, 0.2), -1.8em 1.8em 0 0em rgba(255,255,255, 0.2), -2.6em 0em 0 0em rgba(255,255,255, 0.2), -1.8em -1.8em 0 0em rgba(255,255,255, 0.2);
    }
    50% {
        box-shadow: 0em -2.6em 0em 0em rgba(255,255,255, 0.2), 1.8em -1.8em 0 0em rgba(255,255,255, 0.2), 2.5em 0em 0 0em rgba(255,255,255, 0.5), 1.75em 1.75em 0 0em rgba(255,255,255, 0.7), 0em 2.5em 0 0em #ffffff, -1.8em 1.8em 0 0em rgba(255,255,255, 0.2), -2.6em 0em 0 0em rgba(255,255,255, 0.2), -1.8em -1.8em 0 0em rgba(255,255,255, 0.2);
    }
    62.5% {
        box-shadow: 0em -2.6em 0em 0em rgba(255,255,255, 0.2), 1.8em -1.8em 0 0em rgba(255,255,255, 0.2), 2.5em 0em 0 0em rgba(255,255,255, 0.2), 1.75em 1.75em 0 0em rgba(255,255,255, 0.5), 0em 2.5em 0 0em rgba(255,255,255, 0.7), -1.8em 1.8em 0 0em #ffffff, -2.6em 0em 0 0em rgba(255,255,255, 0.2), -1.8em -1.8em 0 0em rgba(255,255,255, 0.2);
    }
    75% {
        box-shadow: 0em -2.6em 0em 0em rgba(255,255,255, 0.2), 1.8em -1.8em 0 0em rgba(255,255,255, 0.2), 2.5em 0em 0 0em rgba(255,255,255, 0.2), 1.75em 1.75em 0 0em rgba(255,255,255, 0.2), 0em 2.5em 0 0em rgba(255,255,255, 0.5), -1.8em 1.8em 0 0em rgba(255,255,255, 0.7), -2.6em 0em 0 0em #ffffff, -1.8em -1.8em 0 0em rgba(255,255,255, 0.2);
    }
    87.5% {
        box-shadow: 0em -2.6em 0em 0em rgba(255,255,255, 0.2), 1.8em -1.8em 0 0em rgba(255,255,255, 0.2), 2.5em 0em 0 0em rgba(255,255,255, 0.2), 1.75em 1.75em 0 0em rgba(255,255,255, 0.2), 0em 2.5em 0 0em rgba(255,255,255, 0.2), -1.8em 1.8em 0 0em rgba(255,255,255, 0.5), -2.6em 0em 0 0em rgba(255,255,255, 0.7), -1.8em -1.8em 0 0em #ffffff;
    }
}

/* Убеждаемся, что модальные окна ошибок всегда поверх */
.modal.show#errorModal {
    z-index: 10050 !important;
}

/* Стили для модальных окон успеха */
#successModal {
    z-index: 10050 !important;
}

#successModal .modal-backdrop {
    z-index: 10049 !important;
}

.modal.show#successModal {
    z-index: 10050 !important;
}

/* Форма добавления шаблона */
.mb-4 form {
    width: 100%;
    max-width: var(--content-max-width);
}

/* Стили для плавающих меток в input */
.form-group {
    position: relative;
    margin-bottom: 1rem;
}

.form-control {
    position: relative;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: none !important; /* Убираем свечение по краям при фокусе */
    outline: none !important;
}

/* Новые стили для плавающих меток без изменения размера и положения полей */
.form-control-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.label-float {
    position: absolute;
    left: 12px;
    top: 8px;
    font-size: 13px;
    color: transparent;
    pointer-events: none;
    transform-origin: 0 0;
    transition: transform 0.2s ease, color 0.2s ease, background-color 0.2s ease;
    z-index: 1; 
}

/* Стиль метки когда поле в фокусе или не пустое */
.form-control:focus ~ .label-float,
.form-control:not(:placeholder-shown) ~ .label-float {
    transform: translateY(-130%) scale(0.85);
    color: var(--primary-color);
    background-color: white;
    padding: 0 4px;
    border-radius: 3px;
    box-shadow: 0 0 0 1px white;
    font-weight: 500;
}

/* Отменяем свечение в других стилях */
input:focus, 
textarea:focus, 
select:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* Поддержка для разных браузеров */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0px 1000px white inset !important;
}

/* Стили для select элементов */
select.form-control:focus ~ .label-float,
select.form-control:not([value=""]) ~ .label-float {
    transform: translateY(-130%) scale(0.85);
    color: var(--primary-color);
    background-color: white;
    padding: 0 4px;
}

/* Скрываем placeholder при фокусе */
.form-control::placeholder {
    transition: opacity 0.2s ease;
}

.form-control:focus::placeholder {
    opacity: 0;
    color: transparent;
}

/* Поддержка для разных браузеров */
.form-control:focus::-webkit-input-placeholder {
    opacity: 0;
    color: transparent;
}

.form-control:focus::-moz-placeholder {
    opacity: 0;
    color: transparent;
}

.form-control:focus:-ms-input-placeholder {
    opacity: 0;
    color: transparent;
}

.form-control:focus:-moz-placeholder {
    opacity: 0;
    color: transparent;
}

/* Стили для автодополнения формул */
.autocomplete-dropdown {
    position: absolute;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1050;
}

.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.autocomplete-item:hover, 
.autocomplete-item.selected {
    background-color: #f5f5f5;
}

.autocomplete-item .field-type {
    font-size: 0.8em;
    color: #888;
    margin-left: 8px;
}

.formula-help {
    padding: 8px 12px;
    border-bottom: 1px solid #ddd;
    font-size: 0.8em;
    color: #555;
    background-color: #f8f9fa;
}

/* Стили для валидации формулы */
.formula-error {
    border-color: #dc3545;
}

.formula-valid {
    border-color: #28a745;
}

/* Стили для форматирования формулы */
#formatFormulaBtn {
    margin-left: 10px;
    margin-top: 5px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#formatFormulaBtn i {
    margin-right: 5px;
}

/* Анимация при форматировании */
.formatting-animation {
    background-color: #e9f5ff !important;
    transition: background-color 0.3s ease;
}

/* Стили для блока "Возможности" */
section.features {
    background-color: #fff;
    padding: 60px 0;
}

.features-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.section-title-div {
    text-align: center;
    margin-bottom: 50px;
}

.section-title {
    font-family: 'Lora', serif;
    font-weight: 500;
    font-size: 42px;
    line-height: 1.2;
    color: #2C2C2C;
    margin: 0;
}

.features-boxes-block {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
    margin-bottom: 40px;
}

.features-boxes-block-img {
    flex: 0 0 auto;
}

.features-boxes-block-img-img {
    max-width: 100%;
    height: auto;
}

.features-boxes-block-text {
    flex: 1;
}

.features-boxes-block-p1,
.features-boxes-block-p2,
.features-boxes-block-p3,
.features-boxes-block-p4 {
    font-family: 'Maven Pro', sans-serif;
    font-weight: 600;
    font-size: 18px;
    line-height: 1.4;
    color: #37549E;
    margin: 0 0 20px 0;
}

.features-boxes-block-p4 {
    margin-bottom: 0;
}

.features-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
}

.features-boxes1,
.features-boxes2 {
    flex: 1;
}

.features-numbers {
    flex: 0 0 auto;
    text-align: center;
}

.features-numbers img {
    max-width: 100%;
    height: auto;
}

.features-boxes1-text1,
.features-boxes1-text2,
.features-boxes1-text3,
.features-boxes1-text4 {
    font-family: 'Maven Pro', sans-serif;
    font-weight: 600;
    font-size: 20px;
    line-height: 1.2;
    color: #37549E;
    margin: 0 0 20px 0;
}

.features-boxes1-text1,
.features-boxes1-text2 {
    text-align: right;
}

.features-boxes1-text3,
.features-boxes1-text4 {
    text-align: left;
}

.features-boxes1-text2,
.features-boxes1-text4 {
    margin-bottom: 0;
}

/* Адаптивные стили для мобильных устройств */
@media (max-width: 768px) {
    .section-title {
        font-size: 28px;
    }
    
    .features-boxes-block {
        flex-direction: column;
        text-align: center;
    }
    
    .features-box {
        flex-direction: column;
        text-align: center;
    }
    
    .features-boxes1-text1,
    .features-boxes1-text2,
    .features-boxes1-text3,
    .features-boxes1-text4 {
        text-align: center;
        font-size: 18px;
    }
}

@media (max-width: 430px) {
    .features-boxes-block {
        display: none;
    }
    
    .features-box {
        display: none;
    }
    
    .section-title {
        font-size: 24px;
    }
}

/* Стили для акцентирования меток в столбце "Метка" */
.field-name {
    font-weight: 500;
    transition: all 0.2s ease;
}

.field-name span {
    color: #0066cc !important;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-block;
    background-color: rgba(0, 102, 204, 0.05);
    border: 1px solid rgba(0, 102, 204, 0.1);
}

.field-name span:hover {
    background-color: rgba(0, 102, 204, 0.1);
    border-color: rgba(0, 102, 204, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 102, 204, 0.1);
}

.field-name span:active {
    transform: translateY(0);
    background-color: rgba(0, 102, 204, 0.15);
}

/* Адаптивная компоновка карточек управления шаблоном */
@media (min-width: 1101px) {
    .header {
        height: auto;
        min-height: 112px;
        margin-bottom: 14px;
        padding: 10px 18px;
    }

    .toolbar {
        height: 112px;
        min-height: 112px;
        margin-bottom: 14px;
        padding: 10px 18px;
    }
}

@media (max-width: 1100px) {
    .header,
    .toolbar {
        height: auto;
        min-height: 0;
    }

    .toolbar-group.document-create-block {
        display: flex;
        align-items: flex-start;
    }

    .header-content {
        grid-template-columns: 1fr;
    }

    .template-file-block {
        width: 100%;
    }
}

@media (max-width: 850px) {
    .header,
    .toolbar {
        padding: 20px;
    }

    .toolbar {
        height: auto;
        min-height: 0;
        grid-template-columns: 1fr;
    }

    .toolbar-group {
        padding-right: 0;
        padding-bottom: 22px;
    }

    .document-output-block {
        padding-top: 22px;
        padding-left: 0;
        border-top: 1px solid #e6ebf2;
        border-left: 0;
    }
}

@media (max-width: 620px) {
    .template-summary {
        align-items: flex-start;
    }

    .template-summary-icon {
        width: 54px;
        height: 54px;
        flex-basis: 54px;
        border-radius: 14px;
    }

    .template-summary-icon img {
        width: 28px;
        height: 28px;
    }

    .header h1 {
        font-size: 22px;
    }

    .template-title-actions {
        width: auto;
    }

    .template-title-action {
        width: 30px;
        height: 30px;
        min-height: 30px;
        padding: 6px;
    }

    .template-file-block {
        flex-direction: column;
    }

    .template-file-details {
        padding-right: 0;
        padding-bottom: 14px;
    }

    .template-file-actions {
        justify-content: flex-end;
        padding-top: 12px;
        padding-left: 0;
        border-top: 1px solid #dbe6f7;
        border-left: 0;
    }

    .actions-btn-group {
        grid-template-columns: 1fr;
    }

    .toolbar .actions-btn-group .btn {
        width: 100%;
    }
}

/* Альтернативный стиль для новой версии дизайна, где span не используется */
.field-name:not(:has(span)) {
    color: #0066cc !important;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    background-color: rgba(0, 102, 204, 0.05);
    border: 1px solid rgba(0, 102, 204, 0.1);
    transition: all 0.2s ease;
}

.field-name:not(:has(span)):hover {
    background-color: rgba(0, 102, 204, 0.1);
    border-color: rgba(0, 102, 204, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 102, 204, 0.1);
}

.field-name:not(:has(span)):active {
    transform: translateY(0);
    background-color: rgba(0, 102, 204, 0.15);
}

/* Стили для format-id в модальных окнах */
.format-id {
    color: #0066cc !important;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    background-color: rgba(0, 102, 204, 0.05);
    border: 1px solid rgba(0, 102, 204, 0.1);
    transition: all 0.2s ease;
}

.format-id:hover {
    background-color: rgba(0, 102, 204, 0.1);
    border-color: rgba(0, 102, 204, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 102, 204, 0.1);
}
