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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f7fa;
    color: #2c3e50;
    line-height: 1.6;
}

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

/* ===== Навигация ===== */
.navbar {
    background: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: 600;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background 0.3s;
}

.nav-link:hover {
    background: #34495e;
}

.nav-link.active {
    background: #3498db;
}

.nav-logout {
    background: #e74c3c;
    font-size: 0.9rem;
}

.nav-logout:hover {
    background: #c0392b;
}

/* ===== Flash Messages ===== */
.flash-messages {
    margin-bottom: 20px;
}

.flash-message {
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    border-radius: 6px;
    font-size: 0.95rem;
    animation: slideIn 0.3s ease-out;
}

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

.flash-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.flash-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.flash-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ===== Заголовки страниц ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #3498db;
}

.page-header h2 {
    color: #2c3e50;
    font-size: 2rem;
}

/* ===== Формы ===== */
.task-form {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.form-section {
    margin-bottom: 30px;
}

.form-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ecf0f1;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 8px;
    color: #34495e;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 15px;
    border: 1px solid #dfe6e9;
    border-radius: 5px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* ===== Кнопки ===== */
.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

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

.btn-danger:hover {
    background: #c0392b;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.9rem;
}

/* ===== Динамические поля ===== */
#dynamicFields {
    margin-top: 30px;
}

/* Отступ для поля объяснения после динамических полей */
.explanation-field {
    margin-top: 30px !important;
    padding-top: 30px;
    border-top: 1px solid #ecf0f1;
}

.dynamic-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #3498db;
}

.dynamic-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

/* ===== Автозаполнение ===== */
.autofill-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
}

.autofill-label {
    font-size: 0.9rem;
    color: #7f8c8d;
    font-weight: 500;
}

.autofill-select {
    padding: 6px 12px;
    border: 1px solid #dfe6e9;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    background: white;
    min-width: 200px;
    max-width: 300px;
    transition: border-color 0.3s;
}

.autofill-select:focus {
    outline: none;
    border-color: #3498db;
}

.autofill-select:disabled {
    background: #ecf0f1;
    cursor: not-allowed;
    color: #95a5a6;
}

.btn-remove {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-remove:hover {
    background: #c0392b;
}

.btn-add {
    background: #2ecc71;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 10px;
    font-size: 0.95rem;
}

.btn-add:hover {
    background: #27ae60;
}

/* ===== Сетка карточек заданий ===== */
.tasks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.task-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    position: relative;
    transition: transform 0.3s, box-shadow 0.3s;
}

.task-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.12);
}

.task-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ecf0f1;
}

.task-id-badge {
    background: #3498db;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.task-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    transition: transform 0.2s;
}

.icon-btn:hover {
    transform: scale(1.2);
}

.edit-btn {
    color: #f39c12;
}

.delete-btn {
    color: #e74c3c;
}

.task-card-body {
    margin-bottom: 10px;
}

.task-detail {
    margin-bottom: 10px;
}

.task-detail-label {
    font-weight: 600;
    color: #7f8c8d;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.task-detail-value {
    color: #2c3e50;
    margin-top: 3px;
    overflow-wrap: break-word;
}

.task-detail-value ol,
.task-detail-value ul {
    margin: 5px 0 0 0;
    padding-left: 20px;
}

.task-detail-value li {
    margin-bottom: 5px;
}

.difficulty-badge,
.type-badge,
.location-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 500;
}

.difficulty-EASY {
    background: #d5f4e6;
    color: #27ae60;
}

.difficulty-MEDIUM {
    background: #ffeaa7;
    color: #f39c12;
}

.difficulty-HARD {
    background: #fab1a0;
    color: #e17055;
}

.difficulty-EXPERT {
    background: #fd79a8;
    color: #d63031;
}

.type-badge {
    background: #dfe6e9;
    color: #2c3e50;
}

.location-badge {
    background: #74b9ff;
    color: #0984e3;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 10px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideIn 0.3s;
}

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

.modal-small {
    max-width: 400px;
}

.close {
    color: #95a5a6;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: #2c3e50;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ===== Уведомления ===== */
.notification {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    background: #2ecc71;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 2000;
    animation: slideInRight 0.3s;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.notification.error {
    background: #e74c3c;
}

.notification.show {
    display: block;
}

/* ===== Сортировка ===== */
.controls-bar {
    margin-bottom: 20px;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-controls label {
    font-weight: 500;
    color: #2c3e50;
}

.sort-controls select {
    padding: 8px 15px;
    border: 1px solid #dfe6e9;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
}

/* ===== Страница помощи ===== */
.help-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* Табы помощи */
.help-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 0;
    border-bottom: 2px solid #ecf0f1;
    background: white;
    padding: 20px 20px 0 20px;
    border-radius: 10px 10px 0 0;
    flex-wrap: wrap;
}

.help-tabs .tab-button {
    padding: 12px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #7f8c8d;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    border-radius: 5px 5px 0 0;
}

.help-tabs .tab-button:hover {
    color: #3498db;
    background: #f8f9fa;
}

.help-tabs .tab-button.active {
    color: #3498db;
    border-bottom-color: #3498db;
    background: #f8f9fa;
}

.help-section {
    margin-bottom: 35px;
}

.help-section h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
    font-size: 1.5rem;
}

.help-section h4 {
    color: #34495e;
    margin-bottom: 10px;
    margin-top: 20px;
    font-size: 1.2rem;
}

.help-section p {
    margin-bottom: 15px;
    line-height: 1.8;
}

.help-section ul,
.help-section ol {
    margin-left: 25px;
    margin-bottom: 15px;
}

.help-section li {
    margin-bottom: 8px;
    line-height: 1.8;
}

.mechanic-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #3498db;
}

.mechanic-card h4 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.mechanic-card p {
    margin-bottom: 10px;
}

/* Карточки "Когда использовать" */
.when-use-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #3498db;
}

.when-use-card h4 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.when-use-card p {
    margin-bottom: 10px;
}

.when-use-card ul {
    margin-left: 20px;
}

/* Описания полей */
.field-description {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #2ecc71;
}

.field-description h4 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.field-description p {
    margin-bottom: 10px;
}

.field-description ul {
    margin-left: 20px;
    margin-bottom: 10px;
}

.field-description li {
    margin-bottom: 5px;
}

/* Карточки примеров */
.example-card {
    background: white;
    border: 3px solid #3498db;
    border-radius: 10px;
    margin-bottom: 30px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.15);
}

.example-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
}

.example-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: white;
    border: none;
    padding: 0;
}

.example-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: white;
}

.example-form {
    padding: 20px;
    background: #fafbfc;
}

.example-form .form-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #e1e8ed;
}

.example-form .form-section h3 {
    color: #2c3e50;
    font-size: 1.1rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ecf0f1;
}

.example-form .form-group label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.example-form .form-group input,
.example-form .form-group textarea {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    padding: 10px 12px;
    border-radius: 5px;
    font-size: 0.95rem;
}

.example-form .form-group input[type="checkbox"] {
    width: auto;
    margin-right: 5px;
}

.example-form .dynamic-item {
    background: #ffffff;
    border: 1px solid #dee2e6;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border-left: 3px solid #3498db;
}

.example-form .dynamic-item-header {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.example-form .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.note {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 12px;
    margin-top: 15px;
    border-radius: 5px;
    color: #856404;
}

.warning {
    color: #e74c3c;
    font-weight: 500;
}

/* ===== Вкладки ===== */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #ecf0f1;
}

.tab-button {
    padding: 12px 25px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #7f8c8d;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-button:hover {
    color: #3498db;
}

.tab-button.active {
    color: #3498db;
    border-bottom-color: #3498db;
}

.tab-content {
    display: none;
}

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

/* ===== Фильтры ===== */
.filter-section {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group strong {
    display: block;
    margin-bottom: 10px;
    color: #2c3e50;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: background 0.2s;
}

.checkbox-label:hover {
    background: #f8f9fa;
}

.filter-checkbox {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* ===== Ответы ===== */
.answers-grid {
    display: flex;
    flex-direction: column;
    gap: 25px;
    margin-top: 20px;
}

.answer-group {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.answer-group-header {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ecf0f1;
}

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

.answer-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.answer-detail {
    margin-bottom: 8px;
    line-height: 1.6;
}

.answer-detail:last-child {
    margin-bottom: 0;
}

.answer-detail strong {
    color: #7f8c8d;
    font-size: 0.9rem;
}

.correct-answer {
    color: #27ae60;
    font-weight: 600;
}

.incorrect-answer {
    color: #e74c3c;
    font-weight: 600;
}

/* ===== Адаптивность ===== */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 15px;
    }

    .nav-menu {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}
