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

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

.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: block;
}

/* Кнопки */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #545b62;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

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

.btn-success:hover {
    background-color: #1e7e34;
}

/* Анимация нажатия кнопки */
.btn-pressed {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* Сообщения */
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #f5c6cb;
    margin-top: 10px;
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #c3e6cb;
    margin-top: 10px;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

/* Страница авторизации */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.login-container h1 {
    text-align: center;
    color: #007bff;
    margin-bottom: 10px;
    font-size: 24px;
}

.login-container h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #666;
    font-size: 18px;
    font-weight: normal;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.form-group input[readonly] {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
    border-color: #dee2e6;
}

.form-group input[readonly]:focus {
    border-color: #dee2e6;
    box-shadow: none;
}

#login-form button {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    margin-top: 10px;
}

.login-info {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    font-size: 14px;
}

.login-info h3 {
    margin: 0 0 15px 0;
    color: #007bff;
    font-size: 16px;
}

.login-info p {
    margin: 10px 0;
    line-height: 1.5;
}

/* Основная страница */
.app-header {
    background: white;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    color: #007bff;
    font-size: 24px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    font-weight: 500;
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

.actions-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

/* Датасеты */
.datasets-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.dataset-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    position: relative;
}

.dataset-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.dataset-card:active {
    transform: translateY(0px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dataset-card h3 {
    color: #007bff;
    margin-bottom: 10px;
    font-size: 18px;
}

.dataset-meta {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 15px;
    font-size: 14px;
    color: #666;
}

.dataset-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-creating {
    background-color: #fff3cd;
    color: #856404;
}

.status-ready {
    background-color: #d4edda;
    color: #155724;
}

.status-failed {
    background-color: #f8d7da;
    color: #721c24;
}

.status-orphaned {
    background-color: #ffeaa7;
    color: #6c5ce7;
}

.dataset-published {
    background-color: #d1ecf1;
    color: #0c5460;
}

.published-status {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
}

.published-status.published {
    background-color: #d4edda;
    color: #155724;
}

.published-status.not-published {
    background-color: #f8d7da;
    color: #721c24;
}

.dataset-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
}

.delete-dataset-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.delete-dataset-btn:hover {
    opacity: 1;
    background-color: rgba(220, 53, 69, 0.1);
    transform: scale(1.1);
}

/* Страница детализации датасета */
.dataset-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 30px;
    align-items: start; /* Выравнивание по верхнему краю */
}

/* Карточка версий занимает всю ширину во втором ряду */
.versions-card {
    grid-column: 1 / -1; /* Растягиваем на всю ширину */
}

.info-card, .versions-card, .upload-actions-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.info-card h3, .versions-card h3, .upload-actions-card h3 {
    color: #007bff;
    margin-bottom: 15px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

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

.info-label {
    font-weight: 500;
    color: #333;
}

.info-value {
    color: #666;
}

.version-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 10px;
}

.version-item h4 {
    color: #007bff;
    margin-bottom: 5px;
}

.version-meta {
    font-size: 14px;
    color: #666;
}

/* Кнопки загрузки данных */
.upload-actions-card {
    margin: 20px 0;
}

.upload-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.upload-buttons .btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    min-width: 160px;
    justify-content: center;
}

.upload-buttons .btn-icon {
    font-size: 18px;
}

#upload-data-btn {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: 2px solid #007bff;
}

#upload-data-btn:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    border-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

#upload-documents-btn {
    background: white;
    color: #6c757d;
    border: 2px solid #6c757d;
}

#upload-documents-btn:hover {
    background: #6c757d;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.upload-buttons .btn:active {
    transform: translateY(0);
}

/* Адаптивность для планшетов */
@media (max-width: 1024px) and (min-width: 769px) {
    .dataset-info {
        gap: 20px; /* Уменьшаем отступы на планшетах */
    }
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .dataset-info {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    /* На мобильных карточка версий не растягивается */
    .versions-card {
        grid-column: auto;
    }

    .upload-buttons {
        flex-direction: column;
    }

    .upload-buttons .btn {
        min-width: auto;
        width: 100%;
        padding: 14px 16px;
        font-size: 15px;
    }

    .datasets-container {
        grid-template-columns: 1fr;
    }

    .app-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .actions-bar {
        flex-direction: column;
    }
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    color: #007bff;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.close-modal:hover {
    color: #333;
}

/* Страница создания датасета */
.create-dataset-container {
    max-width: 600px;
    margin: 0 auto;
}

.create-dataset-card {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.create-dataset-card h3 {
    color: #007bff;
    margin-bottom: 15px;
    font-size: 24px;
}

.create-dataset-description {
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

.required {
    color: #dc3545;
    font-weight: bold;
}

textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
}

textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.char-counter {
    font-size: 12px;
    color: #666;
    text-align: right;
    margin-top: 5px;
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 25px;
}

.form-actions .btn {
    min-width: 120px;
}

/* ICD-10 Автодополнение */
.icd10-autocomplete-container {
    position: relative;
    width: 100%;
}

.icd10-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 5px 5px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: none;
}

.icd10-autocomplete-dropdown.show {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

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

.icd10-autocomplete-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    display: flex;
    flex-direction: column;
    transition: background-color 0.15s ease;
}

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

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

.icd10-autocomplete-item.selected {
    background-color: #e7f3ff;
}

.icd10-autocomplete-code {
    font-weight: 600;
    color: #007bff;
    font-size: 14px;
    margin-bottom: 2px;
}

.icd10-autocomplete-name {
    color: #333;
    font-size: 13px;
    line-height: 1.4;
}

.icd10-autocomplete-highlight {
    background-color: #fff3cd;
    font-weight: 600;
    padding: 1px 2px;
    border-radius: 2px;
}

.icd10-autocomplete-no-results {
    padding: 15px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

.icd10-autocomplete-loading {
    padding: 15px;
    text-align: center;
    color: #6c757d;
}

.icd10-autocomplete-error {
    padding: 15px;
    text-align: center;
    color: #dc3545;
    background-color: #f8d7da;
    border-radius: 3px;
}

/* Валидация поля МКБ-10 */
.icd10-input.valid {
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

.icd10-input.invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2);
}

.icd10-validation-message {
    margin-top: 5px;
    font-size: 12px;
    display: none;
}

.icd10-validation-message.show {
    display: block;
}

.icd10-validation-message.valid {
    color: #28a745;
}

.icd10-validation-message.invalid {
    color: #dc3545;
}

/* Адаптивность для ICD-10 */
@media (max-width: 768px) {
    .icd10-autocomplete-dropdown {
        max-height: 200px;
    }

    .icd10-autocomplete-item {
        padding: 10px 12px;
    }

    .icd10-autocomplete-code {
        font-size: 13px;
    }

    .icd10-autocomplete-name {
        font-size: 12px;
    }
}