/* ============================================================
 * COMPONENTS - BUTTONS
 * ============================================================ */

.btn-large {
    padding: 13px 20px !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    border-radius: var(--radius-sm) !important;
}

.btn-send,
.btn-voice {
    width: 32px;
    height: 32px;
    background: #3366A9;
    border: 1px solid #3366A9;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(51, 102, 169, 0.2);
    padding: 0;
}

@media (max-width: 768px) {
    .btn-send,
    .btn-voice {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }
}

.btn-send img,
.btn-voice img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}

/* Стрелка «отправить» крупнее микрофона: она тут главное действие, а в
   круге 32px иконка 16px смотрелась мелкой точкой. */
.btn-send img {
    width: 20px;
    height: 20px;
}

.btn-send:hover:not(:disabled),
.btn-voice:hover:not(:disabled) {
    background: #4A7BC4;
    border-color: #4A7BC4;
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(51, 102, 169, 0.3);
}

.btn-send:active:not(:disabled),
.btn-voice:active:not(:disabled) {
    transform: scale(1.02);
}

.btn-send:disabled,
.btn-voice:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-voice.listening {
    background: #4A7BC4;
    border-color: #4A7BC4;
    animation: modern-pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ============================================================
 * COMPONENTS - MODALS
 * ============================================================ */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    gap: 16px;
}

.modal.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.modal p {
    color: var(--text-secondary);
    font-size: 14px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    font-family: 'Jost', sans-serif;
    animation: slideUp 0.3s ease;
}

.modal-content h3 {
    margin: 0 0 16px 0;
    color: #333;
}

.modal-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 12px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.modal-input:focus {
    outline: none;
    border-color: #114185;
}

.modal-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    color: #666;
    font-size: 14px;
}

.modal-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.3s;
}

.modal-btn:hover {
    opacity: 0.8;
}

.modal-btn-primary {
    background: #667eea;
    color: white;
}

.modal-btn-secondary {
    background: #f0f0f0;
    color: #666;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    font-family: 'Jost', sans-serif;
}

.modal-body {
    padding: 20px;
    background: var(--bg-main);
}

.modal-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 24px;
    color: var(--text-secondary);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    color: var(--text);
    transform: scale(1.1);
}

/* ============================================================
 * COMPONENTS - UPLOAD MODAL
 * ============================================================ */

#upload-modal.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
}

#upload-modal .modal-content {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    width: 90%;
    max-width: 280px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    cursor: default;
    animation: slideUp 0.3s ease;
}

/* ⚠️ Попап выбора загрузки. Раньше это было модальное окно с затемнением
   на весь экран (.modal-overlay) — несоразмерно действию из двух пунктов.
   position: fixed и координаты от кнопки «+» (см. showUploadModal в
   app.js), z-index выше сайдбара (999). */
/* Вид — как меню вложений в ChatGPT: «стеклянная» панель с размытием
   того, что под ней, и пункты с иконкой в круге слева. Цвета — токенами
   ниже, тёмная тема переопределяет их в theme.css. */
.upload-popover {
    --upload-bg: rgba(255, 255, 255, 0.82);
    --upload-border: rgba(0, 0, 0, 0.06);
    --upload-icon-bg: rgba(0, 0, 0, 0.05);
    --upload-hover: rgba(0, 0, 0, 0.05);

    position: fixed;
    z-index: 1200;
    min-width: 232px;
    padding: 8px;
    background: var(--upload-bg);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid var(--upload-border);
    border-radius: 26px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    animation: uploadPopIn 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes uploadPopIn {
    from { opacity: 0; transform: scale(0.9); }
    to   { opacity: 1; transform: scale(1); }
}

.upload-buttons {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
}

.upload-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 8px 14px 8px 8px;
    background: transparent;
    border: none;
    border-radius: 18px;
    cursor: pointer;
    font-family: 'Jost', sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: var(--text);
    text-align: left;
    transition: background 0.15s ease;
}

.upload-btn:hover,
.upload-btn:focus-visible {
    background: var(--upload-hover);
    outline: none;
}

.upload-btn:active {
    transform: scale(0.98);
}

.upload-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--upload-icon-bg);
    color: var(--text);
}

/* На устройствах с мышью камеры в меню нет: capture там игнорируется,
   и пункт открыл бы тот же выбор файла, что и «Фото». */
@media (hover: hover) and (pointer: fine) {
    .upload-btn--camera {
        display: none;
    }
}

/* ============================================================
 * COMPONENTS - CARDS
 * ============================================================ */

.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    transition: all 0.2s;
}

.info-card:hover {
    border-color: rgba(17, 65, 133, 0.3);
    background: var(--bg-hover);
}

.info-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    margin: 0 0 14px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.help-card {
    background: #114185;
    border: none;
    border-radius: 10px;
    padding: 16px 20px;
    color: #FFFFFF;
    cursor: pointer;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(17, 65, 133, 0.3);
    font-family: 'Cormorant Garamond', serif;
    min-height: 62px;
    width: 100%;
    text-align: left;
    position: relative;
    z-index: 20;
}

@media (max-width: 768px) {
    .help-card {
        min-height: 62px;
        padding: 16px 20px;
        width: 100%;
        flex-direction: row;
    }
}

.help-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(17, 65, 133, 0.4);
    background: #3366A9;
}

.help-card:active {
    transform: translateY(-2px);
}

.help-card.active {
    background: #3366A9;
    box-shadow: 0 8px 20px rgba(17, 65, 133, 0.4);
}

.help-icon {
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    flex-shrink: 0;
    order: 2;
}

.help-card-icon {
    width: 24px;
    height: 24px;
}

@media (max-width: 768px) {
    .help-card-icon {
        width: 24px;
        height: 24px;
    }
}

.help-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #FFFFFF;
    font-family: 'Jost', sans-serif;
    order: 1;
    flex: 1;
}

@media (max-width: 768px) {
    .help-title {
        font-size: 14px;
    }
}

/* ============================================================
 * COMPONENTS - INPUTS
 * ============================================================ */

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: 'Jost', sans-serif;
    font-size: 14px;
    resize: none;
    padding: 4px 8px;
    min-width: 0;
    max-height: 120px;
}

@media (max-width: 768px) {
    .message-input {
        padding: 4px 8px;
    }
}

.message-input::placeholder {
    color: var(--text-muted);
}

/* ⚠️ Поле ввода БЕЗ рамки — в обеих темах и на всех экранах. От переписки
   его отделяет собственная подложка (--bg-card), как в ChatGPT и Claude:
   рамка с подсветкой при фокусе выглядела «окном в окне» и спорила с
   круглыми кнопками внутри.
   border: 1px solid transparent (а не border: none) — чтобы высота и
   внутренние отступы не «прыгнули» на пиксель, если рамку когда-нибудь
   вернут через border-color. */
.input-wrapper {
    height: auto;
    min-height: 47px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: 16px;
    padding: 8px 12px;
    transition: background-color 0.2s;
    width: 100%;
    max-width: 327px;
    margin: 0 auto 16px;
    position: relative;
}

/* ⚠️ На телефоне поле ввода — во всю ширину экрана, вровень с клавиатурой
   (было max-width: 327px, то есть узкая плашка посреди экрана), и БЕЗ
   рамки: от чата его отделяет своя подложка, как в ChatGPT и Claude.
   Рамка на тёмном фоне выглядела «окном в окне» и зрительно сужала и без
   того узкий экран. */
@media (max-width: 768px) {
    .chat-container.full-width .input-wrapper,
    .input-wrapper {
        width: auto;
        max-width: none;
        gap: 6px;
        padding: 6px 8px;
        margin: 0 8px 8px;
        border-radius: 24px;
    }

    /* 16px — не только крупнее: при меньшем кегле Safari и Chrome на
       телефоне автоматически «зумят» страницу при фокусе в поле. */
    .message-input {
        font-size: 16px;
        padding: 4px 6px;
    }
}

/* Фокус показываем самой подложкой: ни рамки, ни свечения.
   ⚠️ Правило стоит ПОСЛЕ мобильного блока выше и с той же специфичностью,
   поэтому перебивало его — из-за этого синяя рамка возвращалась на
   телефоне, хотя там её уже убирали. */
.input-wrapper:focus-within {
    border-color: transparent;
    box-shadow: none;
}

.message-input-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    min-width: 0;
}

/* ⚠️ Без подложки и рамки: круг нарисован внутри самой иконки
   (images/icons/attach.svg), и своя окружность давала бы второй круг. */
.hint-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
}

@media (max-width: 768px) {
    .hint-icon {
        width: 32px;
        height: 32px;
    }
}

.hint-icon img {
    /* Круг «+» вровень с круглыми кнопками микрофона и отправки (32px). */
    width: 30px;
    height: 30px;
}

.hint-icon:hover {
    transform: scale(1.06);
    opacity: 0.85;
}

.auth-input {
    width: 100%;
    background: transparent;
    border: 2px solid #114185;
    color: #1C1C1C;
    padding: 14px 8px;
    border-radius: 14px;
    font-family: 'Jost', sans-serif;
    font-size: 14px;
    font-weight: 400;
    resize: none;
    transition: all 0.3s;
    line-height: 1.5;
}

.auth-input:focus {
    outline: none;
    border-color: #114185;
    /* background: #FFFFFF; */
    box-shadow: 0 0 0 3px rgba(17, 65, 133, 0.1);
}

.auth-input::placeholder {
    /* color: #9CA3AF; */
    font-family: 'Jost', sans-serif;
    font-weight: 400;
    font-size: 14px;
}

/* ============================================================
 * COMPONENTS - BADGES
 * ============================================================ */

.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-active {
    background: rgba(5, 150, 105, 0.15);
    color: #059669;
    border: 1px solid rgba(5, 150, 105, 0.2);
}

.badge-inactive {
    background: rgba(220, 38, 38, 0.15);
    color: #DC2626;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

/* ============================================================
 * COMPONENTS - DROPDOWNS
 * ============================================================ */

.examples-dropdown,
.tips-dropdown {
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    animation: slideDown 0.3s ease;
    margin-top: 10px;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    max-height: 300px;
}

@media (max-width: 768px) {
    .examples-dropdown,
    .tips-dropdown {
        max-width: 100%;
        border-radius: 10px;
    }
}

.examples-dropdown.hidden,
.tips-dropdown.hidden {
    display: none !important;
}

.examples-list,
.tips-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.example-item,
.tip-item {
    padding: 16px 20px;
    background: #EFEFEF;
    /* Было #AAAAAA — на #EFEFEF контраст ~2:1, текст почти не читался.
       #4B5563 даёт ~6.5:1. В тёмной теме цвет свой (theme.css). */
    color: #4B5563;
    cursor: pointer;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 400;
    text-align: left;
    font-family: 'Jost', sans-serif;
    transition: all 0.3s ease;
    min-height: 50px;
    display: flex;
    align-items: left;
    border: none;
}

@media (max-width: 768px) {
    .example-item,
    .tip-item {
        font-size: 13px;
    }
}

.tip-item {
    flex-direction: column;
    justify-content: center;
    border: 2px solid var(--border);
}

.example-item:hover,
.tip-item:hover {
    transform: translateX(4px);
}

.example-item:active,
.tip-item:active {
    transform: translateX(2px);
}

/* ============================================================
 * COMPONENTS - SETTINGS BUTTON
 * ============================================================ */

.settings-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #DC3545;
    transition: all 0.2s;
    font-family: 'Jost', sans-serif;
    width: 100%;
}

.settings-btn:hover {
    background: rgba(220, 53, 69, 0.2);
    border-color: #DC3545;
    transform: translateX(2px);
}

.settings-btn:active {
    transform: translateX(1px);
}

.settings-btn-danger {
    background: rgba(220, 53, 69, 0.1);
    color: #DC3545;
    border-color: rgba(220, 53, 69, 0.3);
}

.settings-btn-danger:hover {
    background: rgba(220, 53, 69, 0.2);
    border-color: #DC3545;
    color: #DC3545;
}

/* ============================================================
 * COMPONENTS - ATTACHED FILES - LIGHT THEME
 * ============================================================ */

.attached-files-container {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    max-height: 150px;
    overflow-y: auto;
    background: var(--bg-main);
    flex-shrink: 0;
}

.attached-files-container.show {
    display: flex;
}

.attached-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-family: 'Jost', sans-serif;
    transition: all 0.2s;
    animation: slideDown 0.3s ease;
}

.attached-file-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-dark);
}

.file-icon {
    font-size: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    color: var(--text);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Jost', sans-serif;
}

.file-size {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'Jost', sans-serif;
}

.file-remove-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
    font-weight: 600;
}

.file-remove-btn:hover {
    background-color: rgba(220, 38, 38, 0.1);
    color: #DC2626;
}

.file-remove-btn:active {
    transform: scale(0.9);
}

/* ============================================================
 * COMPONENTS - TABLE EXPORT
 * ============================================================ */

.assistant-table {
    position: relative;
}

.table-export-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--primary-lighter);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Jost', sans-serif;
    position: absolute;
    top: -20px;
    right: 0;
    z-index: 10;
}

.table-export-btn:hover {
    background: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.table-export-btn:active {
    transform: translateY(0);
}