/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

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

/* Заголовок */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 10px;
}

.back-link {
    color: white;
    text-decoration: none;
    font-size: 14px;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.back-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Фильтр */
.filter-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.filter-section label {
    font-weight: 500;
    color: #555;
}

.filter-section input[type="date"] {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.filter-section input[type="date"]:focus {
    outline: none;
    border-color: #667eea;
}

#refreshBtn {
    padding: 8px 20px;
    background-color: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

#refreshBtn:hover {
    background-color: #5568d3;
}

/* Список записей */
.records-list {
    display: grid;
    gap: 15px;
}

.record-item {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.record-item:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.record-time {
    font-size: 24px;
    font-weight: 600;
    color: #667eea;
    min-width: 60px;
}

.record-info {
    flex: 1;
    min-width: 0;
}

.record-phone {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 5px;
    color: #333;
}

.record-result {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.record-date {
    font-size: 13px;
    color: #999;
    margin-bottom: 10px;
}

.copy-opros-btn {
    padding: 6px 12px;
    background-color: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.2s;
    margin-top: 8px;
}

.copy-opros-btn:hover {
    background-color: #5568d3;
}

.copy-opros-btn:active {
    transform: scale(0.98);
}

.record-short-result {
    flex: 1;
    min-width: 200px;
    max-width: 1200px;
    padding: 10px;
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: small;
    color: #555;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 120px;
    overflow-y: auto;
}

.no-records {
    background: white;
    padding: 40px;
    text-align: center;
    border-radius: 8px;
    color: #999;
    font-size: 16px;
}

/* Детальная информация */
.detail-section {
    background: white;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.detail-section h2 {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.detail-item label {
    font-weight: 500;
    color: #666;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-item span {
    color: #333;
    font-size: 15px;
}

.detail-item-full {
    margin-bottom: 20px;
}

.detail-item-full label {
    display: block;
    font-weight: 500;
    color: #666;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.readonly-field {
    background-color: #f9f9f9;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    color: #333;
    min-height: 40px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Форматирование текста в readonly блоках */
.formatted-text .text-heading {
    font-weight: 700;
    margin: 6px 0 8px;
    color: #333;
}

.formatted-text .text-heading.h1 { font-size: 18px; }
.formatted-text .text-heading.h2 { font-size: 17px; }
.formatted-text .text-heading.h3 { font-size: 16px; }
.formatted-text .text-heading.h4 { font-size: 15px; }
.formatted-text .text-heading.h5 { font-size: 14px; }
.formatted-text .text-heading.h6 { font-size: 13px; }

.formatted-text .text-line {
    margin: 4px 0;
}

.formatted-text .text-list {
    margin: 6px 0 6px 18px;
    padding: 0;
}

.formatted-text .text-list.ordered {
    list-style: decimal;
}

.formatted-text .text-list li {
    margin: 3px 0;
}

.formatted-text .text-spacer {
    height: 6px;
}

.formatted-text .text-muted {
    color: #999;
}

.editable-field {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s ease;
    line-height: 1.5;
    overflow-y: auto;
}

.editable-field.collapsed {
    max-height: 0;
    overflow-y: hidden;
    padding: 0;
    border-width: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.editable-field.expanded {
    max-height: 600px;
    overflow-y: auto;
    opacity: 1;
    pointer-events: auto;
}

.editable-field:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.editable-field:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

/* Предпросмотр форматированного текста */
.formatted-preview {
    display: none;
    margin-top: 8px;
    padding: 12px;
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    color: #333;
    min-height: 40px;
    line-height: 1.5;
    max-height: 7.5em;
    overflow: hidden;
    cursor: pointer;
}

.formatted-preview.preview-expanded {
    max-height: 1000px;
    overflow: auto;
}

.editable-field.collapsed + .formatted-preview {
    display: block;
}

.editable-field.expanded + .formatted-preview {
    display: none;
}

/* Кнопки действий под полями */
.field-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.save-btn {
    background-color: #667eea;
    color: white;
}

.save-btn:hover {
    background-color: #5568d3;
}

.copy-btn {
    background-color: #28a745;
    color: white;
}

.copy-btn:hover {
    background-color: #218838;
}

.clean-btn {
    background-color: #ffc107;
    color: #333;
}

.clean-btn:hover {
    background-color: #e0a800;
}

.action-btn:active {
    transform: scale(0.98);
}

/* Статус сохранения */
.save-status {
    margin-top: 5px;
    font-size: 12px;
    min-height: 16px;
}

.save-status.saving {
    color: #667eea;
}

.save-status.saved {
    color: #28a745;
}

.save-status.error {
    color: #dc3545;
}

/* Сообщения об ошибках */
.error-message {
    background-color: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 4px;
    border-left: 4px solid #dc3545;
    margin-bottom: 20px;
}

/* Загрузка */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 16px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 22px;
    }

    .filter-section {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-section input[type="date"],
    #refreshBtn {
        width: 100%;
    }

    .record-item {
        flex-direction: column;
        gap: 10px;
    }

    .record-time {
        min-width: auto;
    }

    .record-short-result {
        min-width: auto;
        max-width: 100%;
        max-height: 150px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* Стили для результатов оценки по клиническим протоколам */
.clinic-result-container {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-top: 10px;
}

.clinic-result-empty {
    color: #999;
    font-style: italic;
    padding: 10px;
}

.clinic-result-error {
    color: #d32f2f;
    padding: 10px;
    background: #ffebee;
    border-radius: 4px;
    margin-top: 10px;
}

.clinic-result-error pre {
    margin-top: 10px;
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 12px;
}

.clinic-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.clinic-section:last-child {
    border-bottom: none;
}

.section-title {
    color: #667eea;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.subsection {
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
}

.subsection h4 {
    color: #764ba2;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

/* Стили для сворачиваемых подразделов */
.collapsible-subsection {
    position: relative;
}

.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    margin: -10px -10px 12px -10px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.collapsible-header:hover {
    background-color: #f0f0f0;
}

.collapse-icon {
    display: inline-block;
    font-size: 12px;
    transition: transform 0.2s;
    color: #667eea;
    min-width: 16px;
}

.collapsible-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
}

.collapsible-content:not(.collapsed) {
    max-height: 5000px;
    opacity: 1;
}

.data-item {
    margin-bottom: 10px;
    padding: 8px;
    background: #fff;
    border-left: 3px solid #667eea;
    padding-left: 12px;
}

.data-item strong {
    color: #333;
    display: inline-block;
    min-width: 150px;
}

.data-item ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.data-item li {
    margin-bottom: 5px;
}

/* ICD10 стили */
.icd10-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.icd10-item {
    background: #fff;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #4caf50;
}

.icd10-code {
    font-size: 18px;
    font-weight: 700;
    color: #4caf50;
    margin-bottom: 5px;
}

.icd10-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.icd10-confidence {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.icd10-rationale {
    margin-top: 10px;
    font-size: 14px;
}

.icd10-rationale ul {
    margin: 5px 0 0 20px;
    padding: 0;
}

/* Checklist стили */
.checklist {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checklist-item {
    display: flex;
    gap: 15px;
    padding: 12px;
    background: #fff;
    border-radius: 6px;
    border-left: 4px solid #ff9800;
}

.checklist-status {
    min-width: 100px;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
    height: fit-content;
}

.checklist-status.status-missing {
    background: #ffeb3b;
    color: #f57f17;
}

.checklist-status.status-present {
    background: #4caf50;
    color: #fff;
}

.checklist-status.status-warning {
    background: #ff9800;
    color: #fff;
}

.checklist-content {
    flex: 1;
}

.checklist-item-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.checklist-why {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

/* Protocol refs стили */
.protocol-refs {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.protocol-ref {
    margin-bottom: 8px;
    font-size: 13px;
}

.protocol-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    margin-right: 8px;
}

.protocol-link:hover {
    text-decoration: underline;
    color: #764ba2;
}

.protocol-quote {
    color: #666;
    font-style: italic;
    display: block;
    margin-top: 4px;
    padding-left: 15px;
}

/* Red flags стили */
.red-flags {
    list-style: none;
    padding: 0;
}

.red-flags li {
    padding: 10px;
    margin-bottom: 8px;
    background: #ffebee;
    border-left: 4px solid #d32f2f;
    border-radius: 4px;
    color: #c62828;
}

/* Uncertainties стили */
.uncertainties {
    list-style: none;
    padding: 0;
}

.uncertainties li {
    padding: 10px;
    margin-bottom: 8px;
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    border-radius: 4px;
    color: #e65100;
}

/* Orders стили */
.orders-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.order-item {
    padding: 15px;
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    border-radius: 6px;
}

.order-name {
    font-size: 16px;
    font-weight: 600;
    color: #1976d2;
    margin-bottom: 8px;
}

.order-why {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

/* Warnings стили */
.warnings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.warning-item {
    padding: 12px;
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    border-radius: 6px;
}

.warning-text {
    font-size: 14px;
    color: #e65100;
    margin-bottom: 8px;
}

/* Адаптивность для клинических результатов */
@media (max-width: 768px) {
    .clinic-result-container {
        padding: 15px;
    }
    
    .section-title {
        font-size: 18px;
    }
    
    .checklist-item {
        flex-direction: column;
        gap: 10px;
    }
    
    .checklist-status {
        min-width: auto;
        width: fit-content;
    }
    
    .data-item strong {
        min-width: auto;
        display: block;
        margin-bottom: 5px;
    }
}

