/* Основные стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2c3e50;
    --secondary: #6d8fb5;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --light: #ecf0f1;
    --dark: #2c3e50;
    --border: #bdc3c7;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    /* Светло-серо-синий фон */
    background: linear-gradient(135deg, #eaeff5 0%, #d4dfea 100%);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

header {
    /* Шапка светлее */
    background: linear-gradient(135deg, #5b87b5 0%, #8fb4d6 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Вкладки */
.tabs {
    display: flex;
    background: var(--light);
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1em;
    color: var(--dark);
    transition: all 0.3s ease;
    font-weight: 500;
}

.tab-btn:hover {
    background: rgba(109, 143, 181, 0.1);
}

.tab-btn.active {
    background: var(--secondary);
    color: white;
    border-bottom: 3px solid var(--secondary);
}

/* Содержимое вкладок */
.tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

.section {
    margin-bottom: 30px;
}

.section h2 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.8em;
    border-bottom: 3px solid var(--secondary);
    padding-bottom: 10px;
}

/* Формы */
.form-group {
    margin-bottom: 20px;
}

.form-group label,
.question-block label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

.form-group textarea,
.criteria-input,
.question-block input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1em;
    transition: border-color 0.3s ease;
    resize: vertical;
    min-height: 100px;
}

.criteria-input,
.question-block input {
    min-height: 60px;
}

textarea:focus,
input:focus {
    border-color: var(--secondary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(109, 143, 181, 0.1);
}

/* Критерии */
.criteria-check {
    background: var(--light);
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.criteria-check h3 {
    color: var(--primary);
    margin-bottom: 15px;
}

.question-block {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.question-block:last-child {
    border-bottom: none;
}

.question-block label {
    font-size: 1.05em;
}

.criterion-result {
    display: inline-block;
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9em;
}

.criterion-result.valid {
    background: #d4edda;
    color: #155724;
}

.criterion-result.invalid {
    background: #f8d7da;
    color: #721c24;
}

/* Кнопки */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-right: 10px;
    margin-bottom: 10px;
}

.btn-primary {
    background: var(--secondary);
    color: white;
}

.btn-primary:hover {
    background: #5b87b5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(109, 143, 181, 0.4);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #229954;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.4);
}

.btn-secondary {
    background: var(--dark);
    color: white;
}

.btn-secondary:hover {
    background: #1a252f;
    transform: translateY(-2px);
}

/* Результаты */
.result-box {
    background: #e8f5e9;
    border-left: 4px solid var(--success);
    padding: 20px;
    border-radius: 6px;
    margin-top: 20px;
    display: none;
}

.result-box.show {
    display: block;
}

.result-box.error {
    background: #ffebee;
    border-left-color: var(--danger);
}

.result-box h3 {
    color: var(--primary);
    margin-bottom: 10px;
}

.result-box p {
    margin-bottom: 8px;
    line-height: 1.8;
}

/* Шаги анализа */
.analysis-step,
.construct-step {
    background: var(--light);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid var(--secondary);
}

.analysis-step h3,
.construct-step h3,
.analysis-step h4,
.construct-step h4 {
    color: var(--primary);
    margin-bottom: 12px;
}

.analysis-step textarea,
.construct-step textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
    min-height: 100px;
}

.analysis-step textarea:focus,
.construct-step textarea:focus {
    border-color: var(--secondary);
    outline: none;
}

/* Секция этики */
.ethics-section {
    background: #fff3cd;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border-left: 4px solid var(--warning);
}

.ethics-section h3 {
    color: var(--dark);
    margin-bottom: 20px;
}

/* Элементы конструирования */
.sub-item {
    background: white;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 1px solid var(--border);
}

.sub-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary);
}

.sub-item input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 4px;
}

.sub-item input:focus {
    border-color: var(--secondary);
    outline: none;
}

/* История */
.history-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.history-item {
    background: var(--light);
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.history-item:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.history-item h4 {
    color: var(--primary);
    margin-bottom: 8px;
}

.history-item p {
    color: #7f8c8d;
    font-size: 0.9em;
    margin-bottom: 8px;
}

.history-item .date {
    font-size: 0.85em;
    color: #95a5a6;
}

.placeholder {
    text-align: center;
    color: #95a5a6;
    padding: 40px 20px;
}

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

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: var(--dark);
}

.close-modal:hover {
    color: var(--danger);
}

#report-content {
    background: var(--light);
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    line-height: 1.8;
}

#report-content h3 {
    color: var(--primary);
    margin-top: 20px;
    margin-bottom: 10px;
}

#report-content p {
    margin-bottom: 12px;
}

/* Экран входа */
.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 62, 80, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    padding: 36px 34px;
    width: 100%;
    max-width: 380px;
}

.login-card h2 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 6px;
}

.login-card .login-subtitle {
    text-align: center;
    color: #7f8c8d;
    margin-bottom: 24px;
    font-size: 0.95em;
}

.login-card .form-group {
    margin-bottom: 18px;
}

.login-card input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 1em;
}

.login-card input:focus {
    border-color: var(--secondary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(109, 143, 181, 0.1);
}

/* Кнопки-утилиты */
.btn-block {
    width: 100%;
    margin: 0;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.88em;
    margin: 0;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

/* Шапка: инфо о пользователе */
.user-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.35);
}

.user-nav #current-user {
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.user-nav .btn {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: none;
}

.user-nav .btn:hover {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: none;
}

/* Сообщения об ошибках API */
.api-error {
    color: var(--danger);
    font-weight: 600;
    margin: 8px 0 16px;
    min-height: 1em;
}

/* Панель пользователей */
.user-item {
    padding: 20px;
}

.user-item h4 {
    color: var(--primary);
    margin-bottom: 8px;
}

.user-item .user-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.user-item .user-actions .btn {
    flex: 1 1 auto;
    margin: 0;
    font-size: 0.85em;
}

select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1em;
    background: white;
}

select:focus {
    border-color: var(--secondary);
    outline: none;
}

/* Адаптивность */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .tabs {
        flex-direction: column;
    }

    .tab-btn {
        border-bottom: 2px solid var(--border);
    }

    .tab-btn.active {
        border-bottom: 3px solid var(--secondary);
    }

    .tab-content {
        padding: 20px;
    }

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

    .btn {
        width: 100%;
        margin-right: 0;
    }

    .modal-content {
        width: 90%;
        padding: 20px;
    }
}

/* Печать */
@media print {
    body {
        background: white;
    }

    .tabs,
    .btn,
    .close-modal {
        display: none;
    }

    .modal-content {
        box-shadow: none;
    }
}
