﻿/* ─── CSS-переменные (светлая тема по умолчанию) ─── */
:root {
    --bg-body: #f4f7f6;
    --bg-content: #ffffff;
    --bg-header: #2c3e50;
    --text-primary: #1a2639;
    --text-secondary: #2e405b;
    --text-light: #ffffff;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-heavy: 0 30px 80px rgba(0,0,0,0.45);
    --input-border: #ccc;
    --input-focus: #4f7df3;
    --input-bg: #fafcff;
    --btn-primary: #007bff;
    --btn-primary-hover: #0056b3;
    --btn-login: #3498db;
    --btn-login-hover: #2980b9;
    --table-header: #e9ecef;
    --table-hover: #f8f9fa;
    --modal-bg: #ffffff;
    --modal-shadow: 0 30px 80px rgba(0,0,0,0.45);
    --overlay-bg: rgba(0,0,0,0.55);
    --toast-bg: #ffffff;
    --toast-border: #007bff;
    --toast-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

/* ─── Тёмная тема ─── */
body.dark-theme {
    --bg-body: #1a1e2b;
    --bg-content: #2a2f3f;
    --bg-header: #0e121c;
    --text-primary: #eaeef2;
    --text-secondary: #c8d0da;
    --text-light: #eaeef2;
    --border-color: #3a4055;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-heavy: 0 30px 80px rgba(0,0,0,0.7);
    --input-border: #4a5068;
    --input-focus: #6c8cf5;
    --input-bg: #1e2333;
    --btn-primary: #4f7df3;
    --btn-primary-hover: #6c8cf5;
    --btn-login: #4f7df3;
    --btn-login-hover: #6c8cf5;
    --table-header: #343b4f;
    --table-hover: #2f364a;
    --modal-bg: #2a2f3f;
    --modal-shadow: 0 30px 80px rgba(0,0,0,0.8);
    --overlay-bg: rgba(0,0,0,0.75);
    --toast-bg: #2a2f3f;
    --toast-border: #4f7df3;
    --toast-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

/* ─── Общие стили ─── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.3s, color 0.3s;
}

/* ─── ШАПКА ─── */
.header {
    background: var(--bg-header);
    color: var(--text-light);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    flex-shrink: 0;
    transition: background 0.3s;
}

.logo {
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 1px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-toggle {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
}

    .theme-toggle:hover {
        background: rgba(255,255,255,0.3);
        transform: scale(1.05);
    }

.dark-theme .theme-toggle {
    background: rgba(255,255,255,0.1);
}

    .dark-theme .theme-toggle:hover {
        background: rgba(255,255,255,0.25);
    }

.login-btn {
    background: var(--btn-login);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

    .login-btn:hover {
        background: var(--btn-login-hover);
    }

/* ─── ОСНОВНОЙ КОНТЕНТ ─── */
.content {
    max-width: 900px;
    margin: 30px auto;
    padding: 25px 30px;
    background: var(--bg-content);
    border-radius: 8px;
    box-shadow: var(--shadow);
    width: 100%;
    flex: 1;
    transition: background 0.3s, box-shadow 0.3s;
}

    .content h1,
    .content h2 {
        color: var(--text-primary);
    }

    .content h1 {
        margin-top: 0;
    }

    .content h2 {
        margin-top: 30px;
    }

/* ─── ФОРМА ДОБАВЛЕНИЯ ─── */
#addForm {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

    #addForm input {
        flex: 1;
        min-width: 150px;
        padding: 12px 15px;
        border: 1px solid var(--input-border);
        border-radius: 6px;
        font-size: 16px;
        background: var(--input-bg);
        color: var(--text-primary);
        transition: border-color 0.25s, background 0.3s;
    }

        #addForm input:focus {
            border-color: var(--input-focus);
            outline: none;
        }

    #addForm button {
        padding: 12px 25px;
        background: var(--btn-primary);
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 16px;
        cursor: pointer;
        transition: background 0.2s;
    }

        #addForm button:hover {
            background: var(--btn-primary-hover);
        }

/* ─── ТАБЛИЦА ─── */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    transition: border-color 0.3s;
}

th {
    background: var(--table-header);
    color: var(--text-primary);
    font-weight: 600;
}

tr:hover {
    background: var(--table-hover);
}

td {
    color: var(--text-secondary);
}

/* ─── МОДАЛЬНОЕ ОКНО ВХОДА ─── */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: background 0.3s;
}

    .overlay.active {
        display: flex;
    }

.popup {
    background: var(--modal-bg);
    border-radius: 28px;
    max-width: 440px;
    width: 92%;
    padding: 36px 32px 32px;
    box-shadow: var(--modal-shadow);
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    position: relative;
}

.overlay.active .popup {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

    .popup-header h2 {
        font-size: 1.7rem;
        font-weight: 700;
        color: var(--text-primary);
        letter-spacing: -0.5px;
    }

.close-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: #f1f4fa;
    border-radius: 50%;
    font-size: 1.6rem;
    line-height: 1;
    color: #5b6f87;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

    .close-btn:hover {
        background: #e2e8f2;
        color: #1a2639;
    }

.dark-theme .close-btn {
    background: #3a4055;
    color: #c8d0da;
}

    .dark-theme .close-btn:hover {
        background: #4a5068;
        color: #eaeef2;
    }

.tabs {
    display: flex;
    gap: 6px;
    background: #f1f4fa;
    border-radius: 16px;
    padding: 5px;
    margin-bottom: 28px;
}

.dark-theme .tabs {
    background: #343b4f;
}

.tab-btn {
    flex: 1;
    padding: 10px 0;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    color: #5b6f87;
    background: transparent;
    cursor: pointer;
    transition: 0.25s;
}

.dark-theme .tab-btn {
    color: #a0aec0;
}

.tab-btn.active {
    background: #ffffff;
    color: #1a2639;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.dark-theme .tab-btn.active {
    background: #2a2f3f;
    color: #eaeef2;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.tab-btn:not(.active):hover {
    color: #1a2639;
    background: rgba(255,255,255,0.4);
}

.dark-theme .tab-btn:not(.active):hover {
    color: #eaeef2;
    background: rgba(255,255,255,0.05);
}

.form-container {
    position: relative;
    min-height: 320px;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    transform: translateX(12px);
}

    .form.active {
        opacity: 1;
        visibility: visible;
        transform: translateX(0);
        position: relative;
    }

    .form.inactive {
        transform: translateX(-12px);
    }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

    .form-group label {
        font-size: 0.85rem;
        font-weight: 600;
        color: var(--text-secondary);
    }

    .form-group input {
        padding: 12px 16px;
        border: 2px solid var(--input-border);
        border-radius: 14px;
        font-size: 1rem;
        background: var(--input-bg);
        color: var(--text-primary);
        transition: border-color 0.25s, box-shadow 0.25s, background 0.3s;
        outline: none;
    }

        .form-group input:focus {
            border-color: var(--input-focus);
            box-shadow: 0 0 0 4px rgba(79,125,243,0.15);
        }

        .form-group input.error {
            border-color: #e74c5e;
            box-shadow: 0 0 0 4px rgba(231,76,94,0.12);
        }

    .form-group .error-text {
        font-size: 0.75rem;
        color: #e74c5e;
        margin-top: 2px;
        display: none;
    }

        .form-group .error-text.visible {
            display: block;
        }

.submit-btn {
    padding: 14px;
    border: none;
    border-radius: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    background: var(--input-focus);
    cursor: pointer;
    transition: background 0.25s, transform 0.15s;
    margin-top: 6px;
    box-shadow: 0 6px 20px rgba(79,125,243,0.3);
}

    .submit-btn:hover {
        background: #3b63d4;
    }

    .submit-btn:active {
        transform: scale(0.97);
    }

    .submit-btn:disabled {
        opacity: 0.7;
        cursor: not-allowed;
    }

.form-message {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 10px;
    border-radius: 12px;
    margin-top: 4px;
    display: none;
}

    .form-message.success {
        display: block;
        background: #e6f7ec;
        color: #1a7a4a;
    }

    .form-message.error {
        display: block;
        background: #fde8ea;
        color: #b33a48;
    }

.dark-theme .form-message.success {
    background: #1a3a2a;
    color: #8cdfb0;
}

.dark-theme .form-message.error {
    background: #3a1a1e;
    color: #f5a0a8;
}

/* ─── МОДАЛЬНОЕ ОКНО УВЕДОМЛЕНИЙ ─── */
.notification-overlay {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

    .notification-overlay.active {
        display: flex !important;
    }

.notification-modal {
    background: var(--modal-bg);
    border-radius: 20px;
    max-width: 420px;
    width: 90%;
    padding: 30px 28px 24px;
    box-shadow: var(--modal-shadow);
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.notification-overlay.active .notification-modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

    .notification-header h3 {
        font-size: 1.3rem;
        font-weight: 700;
        color: var(--text-primary);
        margin: 0;
    }

.notification-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #f1f4fa;
    border-radius: 50%;
    font-size: 1.4rem;
    color: #5b6f87;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

    .notification-close:hover {
        background: #e2e8f2;
        color: #1a2639;
    }

.dark-theme .notification-close {
    background: #3a4055;
    color: #c8d0da;
}

    .dark-theme .notification-close:hover {
        background: #4a5068;
        color: #eaeef2;
    }

.notification-body {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-secondary);
    padding: 8px 0 16px;
}

    .notification-body p {
        margin: 0;
    }

.notification-footer {
    display: flex;
    justify-content: flex-end;
}

.notification-btn {
    padding: 10px 28px;
    background: var(--input-focus);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

    .notification-btn:hover {
        background: #3b63d4;
    }

/* ─── АДАПТИВНОСТЬ (МОБИЛЬНЫЕ) ─── */
@media (max-width: 600px) {
    .header {
        padding: 0 12px;
        height: 56px;
    }

    .logo {
        font-size: 18px;
    }

    .header-controls {
        gap: 6px;
    }

    .login-btn {
        padding: 6px 14px;
        font-size: 14px;
    }

    .theme-toggle {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .content {
        margin: 12px 10px;
        padding: 16px 14px;
    }

        .content h1 {
            font-size: 1.3rem;
        }

        .content h2 {
            font-size: 1.1rem;
            margin-top: 20px;
        }

    #addForm {
        flex-direction: column;
        gap: 8px;
    }

        #addForm input {
            min-width: 100%;
            padding: 10px 12px;
            font-size: 15px;
        }

        #addForm button {
            width: 100%;
            padding: 12px;
        }

    table {
        font-size: 14px;
    }

    th, td {
        padding: 8px 10px;
    }

        td:last-child {
            font-size: 12px;
        }

    .popup {
        padding: 24px 16px 20px;
        width: 95%;
    }

    .popup-header h2 {
        font-size: 1.3rem;
    }

    .tabs .tab-btn {
        font-size: 0.85rem;
        padding: 8px 0;
    }

    .form-group input {
        padding: 10px 12px;
        font-size: 0.95rem;
    }

    .submit-btn {
        padding: 12px;
        font-size: 1rem;
    }

    .notification-modal {
        padding: 20px 16px 18px;
    }

    .notification-header h3 {
        font-size: 1.1rem;
    }

    .notification-body {
        font-size: 0.95rem;
    }

    .notification-btn {
        padding: 8px 20px;
        font-size: 0.95rem;
    }
}

/* ─── НОВЫЕ СТИЛИ ДЛЯ СТРАНИЦЫ С ОГЛАВЛЕНИЕМ ─── */

/* Контейнер страницы */
.page-with-toc {
    display: flex;
    gap: 30px;
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

/* Боковое меню (оглавление) */
.toc-sidebar {
    flex: 0 0 250px;
    background: var(--bg-content);
    border-radius: 8px;
    padding: 20px 16px;
    box-shadow: var(--shadow);
    height: fit-content;
    position: sticky;
    top: 20px;
    transition: background 0.3s, box-shadow 0.3s;
}

    .toc-sidebar h3 {
        margin-top: 0;
        font-size: 1.1rem;
        color: var(--text-primary);
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 10px;
    }

.toc-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0;
}

    .toc-list li {
        margin: 6px 0;
    }

    .toc-list a {
        display: block;
        padding: 6px 10px;
        color: var(--text-secondary);
        text-decoration: none;
        border-radius: 4px;
        transition: background 0.2s, color 0.2s;
        font-size: 0.95rem;
    }

        .toc-list a:hover {
            background: var(--table-hover);
            color: var(--text-primary);
        }

        .toc-list a.active {
            background: var(--input-focus);
            color: #fff;
        }

/* Основной контент */
.toc-content {
    flex: 1;
    background: var(--bg-content);
    border-radius: 8px;
    padding: 30px;
    box-shadow: var(--shadow);
    transition: background 0.3s, box-shadow 0.3s;
}

/* Центральные блоки */
.content-block {
    margin-bottom: 40px;
}

    .content-block:last-child {
        margin-bottom: 0;
    }

    .content-block h2 {
        font-size: 1.8rem;
        margin-top: 0;
        color: var(--text-primary);
        border-bottom: 2px solid var(--border-color);
        padding-bottom: 8px;
    }

    .content-block p {
        font-size: 1rem;
        line-height: 1.6;
        color: var(--text-secondary);
        margin: 12px 0;
    }

    .content-block img {
        max-width: 100%;
        height: auto;
        border-radius: 8px;
        box-shadow: var(--shadow);
        display: block;
        margin: 12px 0;
    }

/* Картинка с подписью */
.image-caption {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 4px;
}

/* Навигационный бар (в шапке) – добавляем ссылки */
.header-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

    .header-nav a {
        color: var(--text-light);
        text-decoration: none;
        font-size: 16px;
        padding: 4px 0;
        border-bottom: 2px solid transparent;
        transition: border-color 0.2s;
    }

        .header-nav a:hover {
            border-bottom-color: #fff;
        }

        .header-nav a.active {
            border-bottom-color: #fff;
        }

/* Адаптив для мобильных */
@media (max-width: 768px) {
    .page-with-toc {
        flex-direction: column;
        padding: 0 10px;
        margin: 15px auto;
    }

    .toc-sidebar {
        flex: 1 1 auto;
        position: static;
        order: -1; /* оглавление сверху */
        padding: 16px;
    }

    .toc-content {
        padding: 20px;
    }

    .content-block h2 {
        font-size: 1.4rem;
    }

    .header-nav {
        gap: 12px;
    }

        .header-nav a {
            font-size: 14px;
        }
}

.logo-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 8px;
}

.content-block img {
    display: block;
    margin: 16px auto;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.image-caption {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ─── СТРАНИЦА ПРОФИЛЯ ─── */
.profile-page {
    display: flex;
    gap: 30px;
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

.profile-sidebar {
    flex: 0 0 220px;
    background: var(--bg-content);
    border-radius: 8px;
    padding: 20px 16px;
    box-shadow: var(--shadow);
    height: fit-content;
    position: sticky;
    top: 20px;
}

    .profile-sidebar h3 {
        margin-top: 0;
        color: var(--text-primary);
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 10px;
    }

.profile-tabs {
    list-style: none;
    padding: 0;
    margin: 10px 0 0;
}

    .profile-tabs li {
        margin: 6px 0;
    }

.tab-link {
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    font-size: 0.95rem;
}

    .tab-link:hover {
        background: var(--table-hover);
        color: var(--text-primary);
    }

    .tab-link.active {
        background: var(--input-focus);
        color: #fff;
    }

.profile-content {
    flex: 1;
    background: var(--bg-content);
    border-radius: 8px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.tab-content {
    display: none;
}

    .tab-content.active {
        display: block;
    }

.profile-info p {
    font-size: 1rem;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.profile-info strong {
    color: var(--text-primary);
}

.profile-actions {
    margin-top: 20px;
}

    .profile-actions input {
        padding: 8px 12px;
        border: 1px solid var(--input-border);
        border-radius: 4px;
        background: var(--input-bg);
        color: var(--text-primary);
        margin-right: 10px;
    }

    .profile-actions button {
        padding: 8px 18px;
        background: var(--btn-primary);
        color: #fff;
        border: none;
        border-radius: 4px;
        cursor: pointer;
    }

        .profile-actions button:hover {
            background: var(--btn-primary-hover);
        }

.users-table, .records-table {
    width: 100%;
    border-collapse: collapse;
}

    .users-table th, .users-table td,
    .records-table th, .records-table td {
        padding: 10px 12px;
        border-bottom: 1px solid var(--border-color);
        text-align: left;
    }

    .users-table th, .records-table th {
        background: var(--table-header);
        color: var(--text-primary);
    }

.role-select {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-primary);
}

/* Адаптив */
@media (max-width: 768px) {
    .profile-page {
        flex-direction: column;
        padding: 0 10px;
        margin: 15px auto;
    }

    .profile-sidebar {
        flex: 1 1 auto;
        position: static;
        padding: 14px;
    }

    .profile-tabs {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

        .profile-tabs li {
            flex: 1 1 auto;
            min-width: 100px;
            margin: 2px 0;
        }

    .tab-link {
        text-align: center;
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .profile-content {
        padding: 16px;
    }
}

.metrics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-top: 10px;
}

    .metrics-table th, .metrics-table td {
        padding: 8px 10px;
        border-bottom: 1px solid var(--border-color);
        text-align: left;
    }

    .metrics-table th {
        background: var(--table-header);
        color: var(--text-primary);
        position: sticky;
        top: 0;
    }

.refresh-btn {
    padding: 8px 18px;
    background: var(--btn-primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin: 10px 0;
}

    .refresh-btn:hover {
        background: var(--btn-primary-hover);
    }