/* ============================================
   БАЗОВЫЕ СТИЛИ
   ============================================ */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f1f5f9;
    color: #0f172a;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('logo.svg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 50%;
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
}

/* Главный контейнер по центру страницы */
.container {
    max-width: 720px;
    margin: 40px auto;
    padding: 32px 36px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
}

/* ============================================
   ЗАГОЛОВКИ И ТЕКСТ
   ============================================ */

h1 {
    margin: 0 0 24px;
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.3px;
}

h2 {
    margin: 0 0 12px;
    font-size: 20px;
    font-weight: 600;
    color: #0f172a;
}

h3 {
    margin: 24px 0 10px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

p {
    margin: 0 0 12px;
    color: #334155;
}

.subtitle {
    color: #64748b;
    margin-bottom: 20px;
    font-size: 15px;
}

/* ============================================
   ФОРМЫ
   ============================================ */

input[type="text"] {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    margin-bottom: 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ============================================
   КНОПКИ
   ============================================ */

button {
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    background-color: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.05s ease;
}

button:hover {
    background-color: #1d4ed8;
}

button:active {
    transform: translateY(1px);
}

/* Главная кнопка действия (Выполнено) */
#done-button {
    margin-top: 24px;
    padding: 12px 28px;
    font-size: 16px;
    background-color: #16a34a;
}

#done-button:hover {
    background-color: #15803d;
}

/* Стиль кнопки "Отменить выполнение" */
#done-button.button-outline {
    background-color: #ffffff;
    color: #475569;
    border: 1px solid #cbd5e1;
}

#done-button.button-outline:hover {
    background-color: #f8fafc;
    color: #0f172a;
}

/* Кнопка "Назад" — текстовая ссылка */
.back-button {
    background: none;
    color: #2563eb;
    padding: 4px 0;
    font-size: 14px;
    margin-bottom: 8px;
}

.back-button:hover {
    background: none;
    color: #1d4ed8;
    text-decoration: underline;
}

/* Кнопка "Удалить проект" — деликатная, рядом со списком */
.reset-button {
    background-color: transparent;
    color: #b91c1c;
    border: 1px solid #fecaca;
    margin-top: 28px;
    font-size: 14px;
    padding: 8px 16px;
}

.reset-button:hover {
    background-color: #fef2f2;
    color: #991b1b;
}

/* ============================================
   ПРОГРЕСС
   ============================================ */

.progress-info {
    margin: 16px 0 24px;
    padding: 16px 18px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.progress-text {
    font-size: 14px;
    color: #475569;
    margin-bottom: 10px;
}

.progress-text strong {
    color: #0f172a;
    font-weight: 600;
}

.progress-bar {
    height: 8px;
    background-color: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    border-radius: 999px;
    transition: width 0.4s ease;
}

/* ============================================
   СПИСОК ШАГОВ
   ============================================ */

#steps-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#steps-list li {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

#steps-list li:hover {
    border-color: #93c5fd;
    background-color: #f8fafc;
    transform: translateX(2px);
}

.step-title {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: #0f172a;
}

.step-arrow {
    color: #cbd5e1;
    font-size: 18px;
    transition: color 0.15s ease, transform 0.15s ease;
}

#steps-list li:hover .step-arrow {
    color: #2563eb;
    transform: translateX(3px);
}

/* Выполненный шаг — зелёная карточка */
#steps-list li.done {
    background-color: #f0fdf4;
    border-color: #bbf7d0;
}

#steps-list li.done::before {
    content: '✓';
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background-color: #16a34a;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid #16a34a;
    margin-right: 14px;
}

#steps-list li.done .step-title {
    color: #166534;
}

/* ============================================
   СТРАНИЦА ШАГА
   ============================================ */

#step-description {
    color: #334155;
    background-color: #f8fafc;
    padding: 14px 16px;
    border-radius: 8px;
    border-left: 3px solid #2563eb;
    margin: 0;
}

#step-documents,
#step-norms {
    padding-left: 20px;
    margin: 0;
}

#step-documents li,
#step-norms li {
    margin-bottom: 6px;
    color: #334155;
    line-height: 1.55;
}

/* ============================================
   УТИЛИТЫ
   ============================================ */

.hidden {
    display: none;
}
.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #ddd;
    border-radius: 10px;
    margin-top: 10px;
    overflow: hidden;
}

#progress-bar-fill {
    height: 100%;
    width: 0%;
    background-color: #4caf50;
    border-radius: 10px;
    transition: width 0.3s ease;
}
.sidebar {
    position: fixed;
    top: 68px;
    left: 0;
    width: 200px;
    height: calc(100vh - 68px);
    background: #1f2937;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 10px;
}

.sidebar button {
    padding: 10px;
    border: none;
    background: #374151;
    color: white;
    border-radius: 6px;
    cursor: pointer;
}

.sidebar button:hover {
    background: #4b5563;
}
@media print {
    body * {
        visibility: hidden;
    }

    #act-result, #act-result * {
        visibility: visible;
    }

    #act-result {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
}
.doc-category {
    margin-top: 20px;
}

.doc-category h3 {
    margin-bottom: 20px;
}

.doc-card {
    background: #f8fafc;
    border: 1px solid #dbe4ee;
    border-radius: 10px;
    padding: 16px;
    box-sizing: border-box;
}

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

.doc-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.doc-links a {
    text-decoration: none;
    padding: 8px 12px;
    background: #f1f5f9;
    border-radius: 8px;
    color: #1e293b;
    font-size: 14px;
    transition: 0.2s;
}

.doc-links a:hover {
    background: #dbeafe;
}
.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}
.doc-header {
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 0;
    color: #334155;
}
.doc-links {
    display: none;
}

/* ============================================
   ПОИСК
   ============================================ */

.search-block {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    align-items: flex-start;
}

.search-block input[type="text"] {
    flex: 1;
    margin-bottom: 0;
}

.search-block button {
    flex-shrink: 0;
    white-space: nowrap;
}

#search-results {
    margin-bottom: 20px;
}

.search-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.search-count {
    font-size: 13px;
    color: #64748b;
    margin: 0;
}

.search-close-btn {
    background: none;
    color: #94a3b8;
    border: none;
    padding: 2px 6px;
    font-size: 13px;
    cursor: pointer;
}

.search-close-btn:hover {
    color: #0f172a;
    background: none;
}

.search-empty {
    font-size: 14px;
    color: #94a3b8;
    padding: 12px 0;
}

.search-card {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 14px;
}

.search-card-title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    text-transform: none;
    letter-spacing: normal;
}

.search-card-summary {
    font-size: 14px;
    color: #334155;
    margin-bottom: 12px;
}

.search-card-docs {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.search-card-link {
    font-size: 13px;
    color: #2563eb;
    text-decoration: none;
    padding: 6px 10px;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #dbeafe;
    transition: background 0.15s;
}

.search-card-link:hover {
    background: #dbeafe;
}

.search-card-step-btn {
    background: none;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
}

.search-card-step-btn:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

/* ============================================
   ДЕСКТОП: контейнер отступает от сайдбара
   ============================================ */

.container {
    margin-left: 220px;
}

/* ============================================
   АДАПТИВНАЯ ВЁРСТКА (мобильные устройства)
   ============================================ */

@media (max-width: 640px) {

    /* Сайдбар — нижняя панель навигации */
    .sidebar {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: space-around;
        padding: 8px 4px;
        gap: 4px;
        z-index: 100;
        box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
    }

    .sidebar button {
        flex: 1;
        padding: 8px 4px;
        font-size: 12px;
        border-radius: 6px;
    }

    /* Контейнер — убираем отступ слева, добавляем снизу под панель */
    .container {
        margin-left: auto;
        margin-bottom: 72px;
        margin-top: 16px;
        padding: 20px 16px;
    }

    /* Заголовок поменьше */
    h1 {
        font-size: 20px;
        margin-bottom: 16px;
    }

    h2 {
        font-size: 17px;
    }

    /* Сетка документов — одна колонка */
    .documents-grid {
        grid-template-columns: 1fr;
    }

    /* Поисковая строка — кнопка под полем */
    .search-block {
        flex-direction: column;
    }

    .search-block button {
        width: 100%;
    }

    /* Прогресс-бар */
    .progress-info {
        padding: 12px 14px;
    }

    /* Шаги — убираем горизонтальный сдвиг при hover */
    #steps-list li:hover {
        transform: none;
    }

    /* Чат — кнопка под полем */
    .chat-input-row {
        flex-direction: column;
    }

    .chat-input-row button {
        width: 100%;
    }
}

/* ============================================
   AI ЧАТ
   ============================================ */

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 80px;
    max-height: 420px;
    overflow-y: auto;
    margin-bottom: 16px;
    padding: 4px 0;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 88%;
}

.chat-message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-message.ai {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.chat-message.user .chat-bubble {
    background-color: #2563eb;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.chat-message.ai .chat-bubble {
    background-color: #f1f5f9;
    color: #0f172a;
    border-bottom-left-radius: 4px;
}

.chat-message.ai .chat-bubble.loading {
    color: #94a3b8;
    font-style: italic;
}

.chat-message.ai .chat-bubble.error {
    background-color: #fef2f2;
    color: #dc2626;
}

.chat-label {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
    font-weight: 500;
}

.chat-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.chat-input-row input[type="text"] {
    flex: 1;
    margin-bottom: 0;
}

.chat-input-row button {
    flex-shrink: 0;
    white-space: nowrap;
}

#chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-doc-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-doc-link {
    font-size: 13px;
    color: #2563eb;
    text-decoration: none;
    padding: 6px 10px;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #dbeafe;
    transition: background 0.15s;
}

.chat-doc-link:hover {
    background: #dbeafe;
}

/* ============================================
   АВТОРИЗАЦИЯ И ШАПКА
   ============================================ */

/* Шапка сайта */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 68px;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    height: 56px;
    width: auto;
}

.header-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
}

.header-title-ispool {
    color: #3b82f6;
}

.header-title-dok {
    color: #0f172a;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-email {
    font-size: 14px;
    color: #64748b;
}

.header-logout-btn {
    padding: 6px 14px;
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    color: #0f172a;
    cursor: pointer;
    transition: all 0.2s;
}

.header-logout-btn:hover {
    background-color: #e2e8f0;
    border-color: #94a3b8;
}

/* Экран авторизации */
.auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.auth-container {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 48px 40px;
    box-shadow: 0 4px 6px rgba(15, 23, 42, 0.07), 0 20px 25px rgba(15, 23, 42, 0.1);
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.auth-logo {
    height: 113px;
    width: auto;
    display: block;
    margin: 0 auto 32px;
}

.auth-container h2 {
    margin: 0 0 24px;
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
}

.auth-title-ispool {
    color: #3b82f6;
}

.auth-title-dok {
    color: #0f172a;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.auth-input {
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    color: #0f172a;
    transition: all 0.2s;
}

.auth-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.auth-input::placeholder {
    color: #94a3b8;
}

.auth-btn {
    padding: 12px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-btn-primary {
    background-color: #3b82f6;
    color: #ffffff;
}

.auth-btn-primary:hover {
    background-color: #2563eb;
}

.auth-btn-secondary {
    background-color: #f1f5f9;
    color: #0f172a;
    border: 1px solid #cbd5e1;
}

.auth-btn-secondary:hover {
    background-color: #e2e8f0;
}

.auth-note {
    font-size: 12px;
    color: #64748b;
    margin: 0;
}

/* Основной контент (с отступом сверху и слева под sidebar) */
.main-wrapper {
    margin-top: 68px;
    margin-left: 200px;
    position: relative;
    z-index: 1;
}

.sidebar {
    margin-top: 0;
}

.container {
    position: relative;
    z-index: 1;
}

/* Мобильные устройства */
@media (max-width: 768px) {
    .header {
        padding: 0 16px;
    }

    .header-logo {
        height: 32px;
    }

    .header-title {
        font-size: 16px;
    }

    .header-email {
        font-size: 12px;
    }

    /* Сайдбар — нижняя панель на мобильных */
    .sidebar {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        min-height: 60px;
        background: #2d3748;
        border-top: 1px solid #4a5568;
        border-radius: 12px 12px 0 0;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0;
        z-index: 100;
    }

    .sidebar button {
        flex: 1 1 20%;
        min-width: 0;
        padding: 6px 3px;
        font-size: 12px;
        line-height: 1.3;
        white-space: normal;
        word-break: break-word;
        height: auto;
        min-height: 56px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    /* Основной контент — убираем отступы, занимаем всю ширину */
    .main-wrapper {
        margin-left: 0 !important;
        margin-top: 68px;
        margin-bottom: 60px;
    }

    .container {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 16px !important;
        max-width: 100% !important;
    }

    /* AI помощник на мобильных — чат не выходит за края */
    .chat-messages {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .chat-message {
        max-width: 90%;
    }

    .chat-bubble {
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .chat-input-row {
        width: 100%;
        max-width: 100%;
    }

    .chat-input-row input[type="text"] {
        min-width: 0;
    }

    .auth-container {
        padding: 32px 20px;
        max-width: calc(100% - 32px);
    }

    .auth-logo {
        height: 70px;
    }

    .auth-container h2 {
        font-size: 20px;
    }
}