/* ============================================
   ОСНОВНЫЕ СТИЛИ
   ============================================ */

.form-section {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid #0d6efd;
    transition: all 0.3s ease;
}

.form-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.form-section .section-header h4 {
    color: #0d6efd;
    margin: 0;
}

.form-section .section-header .table-ref {
    font-size: 0.8rem;
    color: #6c757d;
    background: #e9ecef;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
}

/* ============================================
   ПОЛЯ ФОРМЫ - ВЫРАВНИВАНИЕ ПО ГОРИЗОНТАЛИ
   ============================================ */

.form-section .field-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
    height: 100%;
}

.form-section .field-group label {
    font-weight: 500;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.25rem;
    flex-shrink: 0;
    min-height: 2.4rem;
    line-height: 1.2;
}

/* Выравнивание полей в строке */
.row.align-items-end .field-group {
    justify-content: flex-end;
}

.row.align-items-end .field-group label {
    margin-bottom: 0.25rem;
}

.row.align-items-end .field-group .form-control,
.row.align-items-end .field-group .form-select {
    flex: 0 1 auto;
    min-height: 38px;
    width: 100%;
}

.form-section .field-group .required-field:after {
    content: " *";
    color: red;
}

.form-section .field-group .form-control,
.form-section .field-group .form-select {
    flex: 1;
    min-height: 38px;
    width: 100%;
}

.form-section .row.align-items-stretch {
    align-items: stretch;
}

/* ============================================
   ПОЛЯ С ТЕКСТОВЫМ ОПИСАНИЕМ - ВОЗМОЖНОСТЬ ИЗМЕНЕНИЯ РАЗМЕРА
   ============================================ */

.field-group textarea.form-control {
    min-height: 60px;
    resize: vertical;
}

.field-group textarea.form-control[rows="4"] {
    min-height: 120px;
}

.field-group textarea.form-control[rows="2"] {
    min-height: 60px;
}

.form-section .field-group textarea {
    resize: vertical;
    min-height: 60px;
}

.form-section .field-group textarea.form-control {
    width: 100%;
}

#authority_text {
    min-height: 120px !important;
}

#notary_additional_info {
    min-height: 60px !important;
}

/* ============================================
   ПРЕДПРОСМОТР XML
   ============================================ */

.xml-preview {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 0;
    border-radius: 0.5rem;
    max-height: 500px;
    overflow: auto;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    counter-reset: line;
}

.xml-preview pre {
    margin: 0;
    padding: 1rem;
    white-space: pre-wrap;
    word-break: break-all;
    counter-reset: line;
}

.xml-preview pre .line {
    display: block;
    counter-increment: line;
}

.xml-preview pre .line::before {
    content: counter(line);
    display: inline-block;
    width: 2.5rem;
    padding-right: 1rem;
    text-align: right;
    color: #6c757d;
    user-select: none;
}

/* ============================================
   КАРТОЧКА
   ============================================ */

.card-header {
    background: linear-gradient(135deg, #0d6efd, #0a58ca);
    color: white;
}

.card-header .subtitle {
    font-size: 0.85rem;
    opacity: 0.85;
    margin-top: 0.25rem;
}

.card-header .subtitle a {
    color: #fff;
    text-decoration: underline;
}

.card-header .subtitle a:hover {
    color: #ffd700;
}

/* ============================================
   КНОПКИ
   ============================================ */

.btn-group-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
}

.btn-group-actions .btn {
    min-width: 180px;
}

/* Кнопка подписи всегда синяя */
#signBtn {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    color: white !important;
}

#signBtn:hover {
    background-color: #0b5ed7 !important;
    border-color: #0a58ca !important;
}

/* ============================================
   ТОСТ УВЕДОМЛЕНИЙ
   ============================================ */

.copy-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    background: #198754;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.copy-toast.show {
    opacity: 1;
}

/* ============================================
   СПЕЦИАЛЬНЫЕ ГРУППЫ ПОЛЕЙ
   ============================================ */

.label-with-code {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.label-with-code .label-main {
    font-weight: 500;
}

.label-with-code .label-code {
    font-size: 0.7rem;
    color: #6c757d;
    font-weight: 400;
}

.general-field-group {
    display: flex;
    flex-direction: column;
}

.general-field-group .form-label {
    min-height: 2.4rem;
    margin-bottom: 0.25rem;
}

/* ============================================
   ДОВЕРИТЕЛЬ И ПРЕДСТАВИТЕЛЬ
   ============================================ */

.trustor-fields, .rep-fields {
    width: 100%;
}

.trustor-fields .row, .rep-fields .row {
    margin: 0 -0.5rem;
}

.trustor-fields .field-group, .rep-fields .field-group {
    padding: 0 0.5rem;
}

/* ============================================
   НОТАРИУС
   ============================================ */

.notary-fields {
    border-top: 1px solid #dee2e6;
    padding-top: 1rem;
    margin-top: 0.5rem;
}

/* ============================================
   ЕИО (Единоличный исполнительный орган)
   ============================================ */

.eio-checkbox-group {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    padding-top: 0.25rem;
}

.eio-checkbox-group .form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
}

.eio-checkbox-group .form-check-input {
    margin: 0;
    width: 1.1rem;
    height: 1.1rem;
}

.eio-checkbox-group .form-check-label {
    font-weight: 400;
    font-size: 0.9rem;
}

/* ============================================
   ЛИЦО БЕЗ ДОВЕРЕННОСТИ
   ============================================ */

.lico-bez-dov-group {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-top: 0.5rem;
    background: #fff;
}

.lico-bez-dov-group .form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.lico-bez-dov-group .form-check-input {
    margin: 0;
    width: 1.1rem;
    height: 1.1rem;
}

.lico-bez-dov-group .form-check-label {
    font-weight: 400;
    font-size: 0.9rem;
}

.lico-bez-dov-group .form-check:last-child {
    margin-bottom: 0;
}

.lico-bez-dov-group .form-text {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

/* ============================================
   БИНАРНАЯ ИНФОРМАЦИЯ
   ============================================ */

.binary-info {
    background: #e9ecef;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.binary-info code {
    background: #d4d4d4;
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
}

/* ============================================
   ОШИБКИ ВАЛИДАЦИИ
   ============================================ */

.field-errors {
    color: #dc3545;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.field-group.has-error label {
    color: #dc3545;
}

.field-group.has-error .form-control,
.field-group.has-error .form-select {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}

/* ============================================
   СТАТУСНЫЕ УВЕДОМЛЕНИЯ
   ============================================ */

.signature-status {
    margin-top: 1rem;
}

.signature-status .alert {
    margin-bottom: 0.5rem;
}

/* ============================================
   АДАПТИВ ДЛЯ КНОПОК
   ============================================ */

@media (max-width: 768px) {
    .btn-group-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-group-actions .btn {
        min-width: unset;
    }
}

/* ============================================
   НОМЕРА СТРОК В XML
   ============================================ */

.xml-preview {
    counter-reset: line;
}

.xml-preview .line {
    display: block;
    counter-increment: line;
}

.xml-preview .line::before {
    content: counter(line);
    display: inline-block;
    width: 2.5rem;
    padding-right: 1rem;
    text-align: right;
    color: #6c757d;
    user-select: none;
}

/* ============================================
   СКРЫТЫЕ ЭЛЕМЕНТЫ
   ============================================ */

#xmlOriginal {
    display: none !important;
}

/* ============================================
   ФЛЕШ-СООБЩЕНИЯ
   ============================================ */

.alert pre {
    white-space: pre-wrap;
    word-break: break-all;
}

/* ============================================
   ВЫРАВНИВАНИЕ ПОЛЕЙ В РАЗДЕЛЕ 1
   ============================================ */

.row.align-items-end .field-group {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.row.align-items-end .field-group label {
    margin-bottom: 0.25rem;
}

/* Гарантируем, что все поля в строке имеют одинаковую высоту */
.row.align-items-end .field-group .form-control,
.row.align-items-end .field-group .form-select {
    height: 38px;
    flex: 0 0 auto;
}

/* Для date полей */
.row.align-items-end .field-group input[type="date"] {
    height: 38px;
}