/* support.css -- the support chat: the floating window above every page and editor
 * modal (tickets list, new-ticket form, the thread, the input footer with pasted-image previews) and the full-screen
 * image zoom that the admin tickets tab borrows too. Loaded by the site's pages and by the editor's pages; reads only
 * the --f-* tokens, which both tokens.css files define. */

/* ---------------------------------------------------------------- the window
   Fixed bottom-right, above everything; the header is the drag handle. */
.desk-chat {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    width: 380px;
    height: 540px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    overflow: hidden;
    border: 1px solid var(--f-surface-6);
    border-radius: 12px;
    background: var(--f-surface-2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    color: var(--f-fg);
    font-size: 14px;
}
.desk-chat[hidden] { display: none; }

.desk-chat-header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--f-surface-6);
    background: var(--f-surface-3);
    cursor: grab;
    user-select: none;
}
.desk-chat-header.is-dragging { cursor: grabbing; }

.desk-chat-title {
    flex: 1;
    overflow: hidden;
    color: var(--f-fg);
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.desk-chat-close {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--f-fg-3);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.desk-chat-close:hover { color: var(--f-fg); }

/* the scrolling middle: a thread, the tickets list or the new-ticket form */
.desk-chat-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
}
.desk-chat-body::-webkit-scrollbar { width: 8px; }
.desk-chat-body::-webkit-scrollbar-thumb { border-radius: 4px; background: var(--f-surface-6); }

.desk-chat-footer {
    flex-shrink: 0;
    padding: 8px;
    border-top: 1px solid var(--f-surface-6);
    background: var(--f-surface-2);
}

/* ---------------------------------------------------------------- the tickets list */
.desk-tickets { display: flex; flex-direction: column; }

.desk-tickets-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--f-surface-6);
}

.desk-tickets-list { flex: 1; overflow-y: auto; }

.desk-ticket-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--f-surface-6);
    cursor: pointer;
    transition: background 0.15s ease;
}
.desk-ticket-row:hover { background: rgba(255, 255, 255, 0.04); }

.desk-ticket-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.desk-ticket-subject {
    flex: 1;
    overflow: hidden;
    color: var(--f-fg);
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.desk-ticket-row-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--f-fg-3);
    font-size: 11px;
}

/* category and status chips */
.desk-ticket-cat {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--f-fg-2);
    font-size: 10px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.desk-ticket-cat.is-bug     { background: rgba(252, 77, 100, 0.15); color: var(--f-danger); }
.desk-ticket-cat.is-idea    { background: rgba(39, 180, 224, 0.15); color: var(--f-hue-sky); }
.desk-ticket-cat.is-payment { background: rgba(243, 173, 56, 0.15); color: var(--f-warn); }

.desk-ticket-status {
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    text-transform: uppercase;
}
.desk-ticket-status.is-open   { background: rgba(62, 189, 65, 0.15); color: var(--f-ok); }
.desk-ticket-status.is-closed { background: rgba(160, 160, 160, 0.15); color: var(--f-fg-3); }

/* ---------------------------------------------------------------- the new-ticket form */
.desk-create {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
}

.desk-create label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--f-fg-3);
    font-size: 12px;
}

.desk-create select,
.desk-create input,
.desk-create textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--f-surface-6);
    border-radius: 6px;
    background: var(--f-surface-1);
    color: var(--f-fg);
    font: inherit;
    resize: vertical;
}
.desk-create textarea { min-height: 80px; max-height: 200px; }
.desk-create .kit-select-btn { display: flex; width: 100%; color: var(--f-fg); font-weight: 400; }

.desk-create-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* the chat's own button: filled, or outlined as .is-secondary */
.desk-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--f-control-h);
    padding: 0 14px;
    border: none;
    border-radius: 6px;
    background: var(--f-accent);
    color: var(--f-on-accent);
    font: inherit;
    cursor: pointer;
    transition: opacity 0.15s ease;
}
.desk-btn:hover { opacity: 0.85; }
.desk-btn.is-secondary { border: 1px solid var(--f-surface-6); background: transparent; color: var(--f-fg-2); }
.desk-btn:disabled { opacity: 0.5; cursor: default; }

/* ---------------------------------------------------------------- the thread */
.desk-thread {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

/* the "back to the list" bar: a full-width button with only a bottom border */
.desk-thread-back {
    display: flex;
    align-items: center;
    width: 100%;
    height: var(--f-control-h);
    padding: 0 12px;
    border-bottom: 1px solid var(--f-surface-6);
    border-top: none;
    border-left: none;
    border-right: none;
    background: transparent;
    color: var(--f-fg-3);
    font-size: 12px;
    text-align: left;
    cursor: pointer;
}
.desk-thread-back:hover { color: var(--f-fg); }

.desk-thread-list {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    overflow-y: auto;
}

/* a message bubble: the user's own on the right in the accent, support's on the left */
.desk-msg {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 80%;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--f-surface-4);
    color: var(--f-fg);
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.desk-img {
    display: block;
    max-width: 240px;
    max-height: 240px;
    border-radius: 6px;
    cursor: zoom-in;
}

.desk-msg-author { color: var(--f-fg-3); font-size: 11px; }

.desk-msg.is-mine { align-self: flex-end; background: var(--f-accent); color: var(--f-on-accent); }
.desk-msg.is-mine .desk-msg-author { color: inherit; font-weight: 700; opacity: 0.7; }
.desk-msg.is-support { align-self: flex-start; background: var(--f-surface-6); }

/* ---------------------------------------------------------------- the input footer */
.desk-input { display: flex; flex-direction: column; gap: 6px; }

.desk-input-row { display: flex; align-items: flex-end; gap: 8px; }

.desk-input textarea {
    flex: 1;
    min-height: 40px;
    max-height: 140px;
    padding: 8px;
    border: 1px solid var(--f-surface-6);
    border-radius: 6px;
    background: var(--f-surface-1);
    color: var(--f-fg);
    font: inherit;
    resize: none;
}

.desk-input-hint { color: var(--f-fg-3); font-size: 11px; }

/* pasted images waiting to be sent: small thumbnails in a wrapping row, each with its own remove cross */
.desk-image-preview {
    position: relative;
    display: inline-block;
    margin: 0 10px 8px 0;
    vertical-align: top;
}

.desk-image-preview img {
    max-width: 120px;
    max-height: 90px;
    border: 1px solid var(--f-surface-6);
    border-radius: 6px;
}

.desk-image-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: var(--f-danger);
    color: white;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

/* ---------------------------------------------------------------- the image zoom
   A click on a message image opens it full screen; the admin tickets tab uses it as well. */
.desk-zoom {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    cursor: zoom-out;
}

.desk-zoom img { max-width: 90vw; max-height: 90vh; border-radius: 8px; }

/* ---------------------------------------------------------------- our additions (support.chat.js without Vue) */
.desk-chat[hidden] { display: none; }
.desk-note { padding: 16px; color: var(--f-fg-3); }
.desk-note.is-empty { padding: 24px; text-align: center; }
.desk-previews { display: contents; }

/* ---------------------------------------------------------------- the live channel's bars (live.js)
   On top of everything, across the page: the server closed the connection, a new release, the plan's limit. */
.live-bars { position: fixed; inset: 0 0 auto 0; z-index: 10000; display: flex; flex-direction: column; }
.live-bars:empty { display: none; }
.live-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--f-fg);
    font: 14px var(--f-font);
}
.live-bar.is-danger { background: var(--f-danger); }
.live-bar.is-accent { background: var(--f-accent-2); color: var(--f-on-accent); }
.live-bar-btn {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 14px;
    border: 1px solid currentColor;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.live-bar-btn.is-primary { border-color: transparent; background: var(--f-surface-1); color: var(--f-fg); }
.live-bar-btn:hover { opacity: 0.9; }
.live-bar + .live-bar { border-top: 1px solid rgb(0 0 0 / 20%); }

/* «Сайт обновляется» / «Сайт обновился» (live.js): a card in the corner in the «Горн» look -- graphite, an ember dot
   (pulsing while the server restarts), the title in the display face; over a game or an editor without covering it.
   On a phone it stands above the tabs. */
.live-card {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 10001;
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr);
    gap: 6px 12px;
    width: min(360px, calc(100vw - 32px));
    padding: 16px 16px 14px;
    border: 1px solid var(--f-surface-4);
    border-radius: 16px;
    background-color: var(--f-surface-2);
    box-shadow: 0 18px 50px rgb(0 0 0 / 45%);
    color: var(--f-fg);
    font: 14px/1.45 var(--f-font);
    animation: live-card-in 0.25s ease-out;
}
.live-card[hidden] { display: none; }
.live-card-dot { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background-color: var(--f-accent); box-shadow: 0 0 0 4px rgb(255 106 26 / 18%); }
.live-card.is-busy .live-card-dot { animation: live-card-pulse 1.2s ease-in-out infinite; }
.live-card-title { margin: 0; font-family: var(--f-font-display); font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.live-card-text { grid-column: 2; margin: 0; color: var(--f-fg-2); font-size: 13px; }
.live-card-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.live-card-actions:empty { display: none; }
.live-card-btn {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    background-color: var(--f-surface-4);
    color: var(--f-fg);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.2s ease;
}
.live-card-btn:hover { filter: brightness(1.12); }
.live-card-btn.is-primary { background-color: var(--f-accent-2); color: var(--f-on-accent); }
@keyframes live-card-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes live-card-pulse { 50% { opacity: 0.35; transform: scale(0.8); } }
@media (max-width: 760px) {
    .live-card { right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
    .live-card, .live-card.is-busy .live-card-dot { animation: none; }
}
