/* ============================================
   Портал заявок — help.aura.morally.site

   Оформление то же, что в кабинете на сайте: те же переменные, тот же
   градиент фона, стеклянные карточки и фиолетовый #7c2e8a. Заказчик видит
   один продукт, а не два разных сайта под одним названием.

   Раскладка — две колонки: список заявок и то, с чем сейчас работают.
   На узком экране колонки показываются по очереди.
   ============================================ */

:root {
    /* Тёмная тема для системных элементов браузера: полос прокрутки,
       выбора файла, календарей. Иначе они рисуются светлыми. */
    color-scheme: dark;

    --dash-bg: linear-gradient(135deg, #0a0510 0%, #150a1c 100%);
    --dash-panel: rgba(18, 10, 26, 0.6);
    --dash-card: rgba(255, 255, 255, 0.03);
    --dash-border: rgba(255, 255, 255, 0.08);
    --dash-primary: #7c2e8a;
    --dash-primary-hover: #5a2166;
    --dash-accent: #cda0d9;
    --dash-text: #f5f0f4;
    --dash-text-muted: #9c8fa0;
    --dash-success: #10b981;
    --dash-warning: #f59e0b;
    --dash-danger: #ef4444;
    --dash-surface-light: rgba(255, 255, 255, 0.05);
    --glass-blur: blur(24px) saturate(180%);

    --topbar-h: 66px;
}

* { box-sizing: border-box; }

/* Атрибут hidden скрывает элемент через display:none из стиля браузера, и
   любое авторское правило display его перебивает. Блоки здесь почти все
   flex — без этой строки «скрытый» экран остаётся на виду. */
[hidden] { display: none !important; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--dash-bg);
    color: var(--dash-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.01em; }

/* ---------- логотип ---------- */

.brand { display: flex; align-items: center; gap: 13px; }

.brand-mark {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
}

.brand-mark.small { width: 30px; height: 30px; }

.brand-name {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--dash-text);
}

.brand-name.small { font-size: 19px; }

.brand-sub { font-size: 14px; color: var(--dash-text-muted); }

/* ---------- поля ---------- */

.field { display: flex; flex-direction: column; gap: 7px; }

.field-label {
    font-size: 13px;
    color: var(--dash-text-muted);
    font-weight: 500;
}

.field input,
.field textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--dash-border);
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--dash-text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.field textarea { resize: vertical; min-height: 90px; }

.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--dash-primary);
}

.field input::placeholder,
.field textarea::placeholder { color: var(--dash-text-muted); }

.form-error {
    margin: 0;
    color: var(--dash-danger);
    font-size: 13px;
}

/* ---------- подсказки по салонам ---------- */

.suggest-field { position: relative; }

.suggest {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    margin: 6px 0 0;
    padding: 5px;
    list-style: none;
    background: #1a1024;
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--dash-border);
    border-radius: 12px;
    /* Список салонов бывает длинным — прокручиваем его, а не растягиваем
       форму на весь экран. */
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.suggest li {
    padding: 10px 12px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 14px;
}

.suggest li:hover,
.suggest li.active { background: var(--dash-surface-light); }

/* ---------- кнопки ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--dash-primary);
    color: #fff;
    border: 1px solid transparent;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.btn:hover:not(:disabled) { background: var(--dash-primary-hover); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-ghost {
    background: transparent;
    border-color: var(--dash-border);
    color: var(--dash-text);
}

.btn-ghost:hover { background: transparent; border-color: var(--dash-primary); }

.btn-wide { width: 100%; }

/* Кнопка выхода из заявки видна на любой ширине. На широком экране список
   слева никуда не девается, но снять выбор без неё нечем. */
.btn-back { flex-shrink: 0; }

/* ---------- вход ---------- */

#loginScreen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--dash-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--dash-border);
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.login-card .brand { margin-bottom: 22px; }

.login-hint { margin: 0 0 24px; color: var(--dash-text-muted); font-size: 14px; }

#loginForm { display: flex; flex-direction: column; gap: 18px; }

.login-foot {
    margin: 24px 0 0;
    font-size: 13px;
    color: var(--dash-text-muted);
    text-align: center;
}

/* ---------- шапка ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--topbar-h);
    padding: 0 24px;
    background: var(--dash-panel);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--dash-border);
}

.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }

.divider { width: 1px; height: 20px; background: var(--dash-border); }

.unit {
    font-weight: 600;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- рабочая область ---------- */

.workspace {
    display: grid;
    /* Список фиксированной ширины, переписка забирает остальное. Растягивать
       список на полэкрана незачем: в нём тема и дата, больше ничего. */
    grid-template-columns: 380px minmax(0, 1fr);
    height: calc(100vh - var(--topbar-h));
}

.col-list {
    background: var(--dash-panel);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--dash-border);
    padding: 24px 20px 30px;
    /* Своя прокрутка: длинный список не должен уносить переписку за экран. */
    overflow-y: auto;
}

/* Колонка не прокручивается сама: прокрутка внутри переписки, иначе поле
   ввода уезжает за экран вместе с сообщениями. */
.col-detail {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.col-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 20px;
}

.detail-pane {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Форма новой заявки прокручивается целиком — она короткая. */
#newView { overflow-y: auto; padding: 24px 28px 40px; }

#newView > .panel { max-width: 820px; }

.detail-blank {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--dash-text-muted);
    font-size: 14px;
}

.panel {
    background: var(--dash-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--dash-border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.panel .btn { align-self: flex-start; }

/* ---------- список заявок ---------- */

.tickets { display: flex; flex-direction: column; gap: 10px; }

.ticket {
    background: var(--dash-card);
    border: 1px solid var(--dash-border);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: inherit;
    font-size: inherit;
    width: 100%;
    transition: border-color 0.2s, background 0.2s;
}

.ticket:hover { border-color: var(--dash-primary); }

/* Открытая заявка подсвечена — иначе на длинном списке теряешь, что читаешь. */
.ticket.current {
    border-color: var(--dash-primary);
    background: var(--dash-surface-light);
}

.ticket-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 5px;
}

.ticket-subject {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ticket-meta { color: var(--dash-text-muted); font-size: 12px; }

.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.badge-open { background: rgba(16, 185, 129, 0.15); color: var(--dash-success); }
.badge-closed { background: rgba(156, 143, 160, 0.15); color: var(--dash-text-muted); }
.badge-answer { background: rgba(245, 158, 11, 0.15); color: var(--dash-warning); }

/* ---------- пусто ---------- */

.empty-state {
    background: var(--dash-card);
    border: 1px solid var(--dash-border);
    border-radius: 16px;
    padding: 34px 20px;
    text-align: center;
}

.empty-title { margin: 0 0 6px; font-weight: 600; font-size: 15px; }
.empty-text { margin: 0; color: var(--dash-text-muted); font-size: 13px; }

/* ---------- переписка ---------- */

.chat-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 28px;
    border-bottom: 1px solid var(--dash-border);
}

.thread-title { min-width: 0; }
.thread-meta { margin: 5px 0 0; color: var(--dash-text-muted); font-size: 13px; }

/* Сообщения занимают всю оставшуюся высоту и прокручиваются внутри себя.
   min-height:0 обязателен: без него flex-элемент не даёт себя сжать ниже
   содержимого, и прокрутка уезжает на всю страницу. */
.thread {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px 28px;
    background: rgba(0, 0, 0, 0.2);
}

/* Свои сообщения справа, ответы поддержки слева — как в любом мессенджере.
   Подсвечена при этом поддержка: свою реплику человек и так помнит, а ждёт
   он ответа, и глаз должен цепляться именно за него. */
.msg {
    align-self: flex-end;
    background: var(--dash-card);
    border: 1px solid var(--dash-border);
    border-radius: 14px;
    padding: 14px 16px;
    max-width: 78%;
}

.msg.from-admin {
    align-self: flex-start;
    background: rgba(124, 46, 138, 0.18);
    border-color: var(--dash-primary);
}

.msg-who {
    font-size: 11px;
    font-weight: 600;
    color: var(--dash-text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.msg.from-admin .msg-who { color: var(--dash-accent); }

.msg-text { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 14px; }

.msg-time { margin: 8px 0 0; font-size: 11px; color: var(--dash-text-muted); }

.msg-file { display: inline-block; margin-top: 10px; }

/* Картинку показываем сразу, а не ссылкой: заявка чаще всего и есть
   скриншот, и открывать его отдельной вкладкой — лишний шаг. Высоту
   ограничиваем, чтобы одно вложение не занимало весь чат. */
.msg-file img {
    max-width: 100%;
    max-height: 320px;
    border-radius: 10px;
    display: block;
}

.msg-file.is-doc {
    color: var(--dash-accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

/* ---------- строка ввода ---------- */

.chat-foot {
    border-top: 1px solid var(--dash-border);
    background: rgba(255, 255, 255, 0.02);
}

.chat-foot .form-error { padding: 10px 28px 0; }

/* Один в один с кабинетом на сайте: скрепка, поле-«таблетка», круглая
   кнопка отправки. */
/* Выравнивание по нижнему краю, а не по центру: плашка выбранного файла и
   выросшее поле ввода добавляют высоту сверху, и при центрировании скрепка
   с кнопкой отправки прыгали вслед за новым центром. */
.chat-input-area {
    padding: 16px 28px;
    display: flex;
    align-items: flex-end;
    gap: 16px;
}

.chat-input-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-input-area textarea {
    width: 100%;
    background: var(--dash-surface-light);
    border: 1px solid var(--dash-border);
    border-radius: 24px;
    padding: 14px 20px;
    color: var(--dash-text);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area textarea:focus { border-color: var(--dash-primary); }
.chat-input-area textarea::placeholder { color: var(--dash-text-muted); }
.chat-input-area textarea:disabled { opacity: 0.6; cursor: not-allowed; }

.chat-attach-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--dash-text-muted);
    cursor: pointer;
    flex-shrink: 0;
    line-height: 0;
    transition: color 0.2s;
}

/* Скрепка ниже кнопки отправки, поэтому её приподнимаем: так значок стоит
   по центру поля ввода, а не по его нижней кромке. */
.chat-attach-btn { margin-bottom: 14px; }

.chat-attach-btn svg { width: 20px; height: 20px; }
.chat-attach-btn:hover:not(:disabled) { color: var(--dash-accent); }
.chat-attach-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--dash-primary);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s, background 0.2s;
}

.chat-send-btn svg { width: 19px; height: 19px; }

.chat-send-btn:hover:not(:disabled) {
    background: var(--dash-primary-hover);
    transform: scale(1.05);
}

.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ---------- вложения ---------- */

/* Выбранный файл — «таблеткой» над полем ввода, как в кабинете: видно, что
   приложено, и убирается одним нажатием. */
.attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(124, 46, 138, 0.18);
    color: var(--dash-accent);
    font-size: 12px;
}

.attach-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

.attach-clear {
    background: none;
    border: none;
    color: inherit;
    font-size: 16px;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
    opacity: 0.75;
}

.attach-clear:hover { opacity: 1; }

/* В форме новой заявки вложение — обычная кнопка: там это не чат, а поле
   среди других полей. */
.attach-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.attach-btn {
    display: inline-block;
    padding: 10px 16px;
    border: 1px dashed var(--dash-border);
    border-radius: 8px;
    color: var(--dash-text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s, color 0.2s;
}

.attach-btn:hover { border-color: var(--dash-primary); color: var(--dash-text); }

.attach-row .attach-name { font-size: 13px; color: var(--dash-text); max-width: 260px; }

.attach-row .attach-clear { color: var(--dash-danger); font-size: 13px; }

/* ---------- прокрутка ---------- */

.col-list::-webkit-scrollbar,
.thread::-webkit-scrollbar,
#newView::-webkit-scrollbar,
.suggest::-webkit-scrollbar { width: 8px; }

.col-list::-webkit-scrollbar-thumb,
.thread::-webkit-scrollbar-thumb,
#newView::-webkit-scrollbar-thumb,
.suggest::-webkit-scrollbar-thumb {
    background: var(--dash-border);
    border-radius: 4px;
}

/* ---------- узкий экран ---------- */

/* До этой ширины двум колонкам рядом тесно: список сжимается до нечитаемого,
   а переписка всё равно упирается в края. Показываем их по очереди. */
@media (max-width: 900px) {
    .workspace {
        display: block;
        height: auto;
    }

    .col-list {
        overflow: visible;
        border-right: none;
        padding: 20px 14px 40px;
    }

    /* На телефоне чат занимает весь экран под шапкой — так же, как любой
       мессенджер, к которому человек привык. */
    .col-detail { height: calc(100vh - var(--topbar-h)); }

    /* Пока заявка не открыта, правой колонки нет вовсе — заглушка на
       телефоне только занимает экран. */
    .detail-blank { display: none; }

    .workspace.detail-open .col-list { display: none; }
    .workspace:not(.detail-open) .col-detail { display: none; }

    .col-head { flex-direction: column; align-items: stretch; }
    .col-head .btn { width: 100%; }

    .chat-head { padding: 14px; }
    .chat-input-area { padding: 12px 14px; gap: 10px; }
    .chat-foot .form-error { padding-left: 14px; padding-right: 14px; }
    .thread { padding: 16px 14px; }
    #newView { padding: 20px 14px 40px; }

    h1 { font-size: 20px; }
    .msg { max-width: 92%; }
}
