/* AI Studio — чаты индивидуальных заказов и админ-навигация */
.nav-count {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    margin-left: 5px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--pink);
    color: #fff;
    font-size: .66rem;
    font-weight: 700;
}

.admin-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin: 18px 0 24px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tabs a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: none;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--muted);
    font-size: .82rem;
}
.admin-tabs a:hover { color: var(--text); background: var(--panel); }
.admin-tabs a.is-active {
    border-color: rgba(124,92,255,.45);
    background: rgba(124,92,255,.15);
    color: var(--text);
}
.admin-tabs__badge {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--pink);
    color: #fff;
    font-size: .64rem;
}

.status-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin: 0 0 18px;
    padding-bottom: 4px;
    scrollbar-width: none;
}
.status-tabs::-webkit-scrollbar { display: none; }
.status-tabs a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: none;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel);
    color: var(--muted);
    font-size: .78rem;
}
.status-tabs a:hover { border-color: rgba(124,92,255,.5); color: var(--text); }
.status-tabs a.is-active {
    border-color: rgba(124,92,255,.6);
    background: rgba(124,92,255,.16);
    color: var(--text);
}
.status-tabs__count {
    display: inline-grid;
    place-items: center;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(255,255,255,.09);
    color: var(--muted);
    font-size: .67rem;
}
.status-tabs a.is-active .status-tabs__count { color: var(--text); }

.chat-pagehead {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 34px 0 22px;
}
.chat-pagehead h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.8rem); letter-spacing: -.03em; }
.chat-pagehead p { margin: 5px 0 0; color: var(--muted); }

.chat-list { display: grid; gap: 10px; }
.chat-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel);
    color: var(--text);
}
.chat-list__item:hover { border-color: rgba(124,92,255,.5); color: var(--text); }
.chat-list__main { min-width: 0; }
.chat-list__main strong { display: block; font-size: 1rem; }
.chat-list__main span { display: block; overflow: hidden; color: var(--muted); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.chat-list__side { display: flex; align-items: center; gap: 10px; flex: none; }
.chat-list__unread {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--pink);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
}
.chat-empty {
    padding: 56px 20px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
}
.chat-empty h2 { margin: 0 0 6px; color: var(--text); }
.chat-empty .btn { margin-top: 18px; }

.chat-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    align-items: start;
    padding-bottom: 50px;
}
.chat-card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
}
.chat-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}
.chat-card__head h1 { margin: 0; font-size: 1.15rem; }
.chat-card__head p { margin: 3px 0 0; color: var(--muted); font-size: .78rem; }
.chat-thread {
    display: grid;
    gap: 14px;
    max-height: 62vh;
    overflow-y: auto;
    padding: 18px;
    background: rgba(0,0,0,.08);
}
.chat-msg { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; max-width: 82%; }
.chat-msg--admin { align-self: flex-end; align-items: flex-end; }
.chat-msg__author { color: var(--dim); font-size: .7rem; }
.chat-msg__bubble {
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 14px 14px 14px 4px;
    background: var(--bg-soft);
    color: var(--text);
    font-size: .9rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.chat-msg--admin .chat-msg__bubble {
    border-color: rgba(124,92,255,.35);
    border-radius: 14px 14px 4px 14px;
    background: rgba(124,92,255,.16);
}
.chat-msg__time { color: var(--dim); font-size: .66rem; }

.chat-attachment { margin-top: 6px; }
.chat-preview {
    width: min(420px, 100%);
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-soft);
}
.chat-preview__frame { position: relative; overflow: hidden; background: #05050e; }
.chat-preview__frame img,
.chat-preview__frame video { width: 100%; max-height: 360px; object-fit: contain; }
.chat-preview__frame img { user-select: none; -webkit-user-drag: none; }
.chat-preview__watermark {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: rgba(255,255,255,.62);
    font-size: clamp(.9rem, 3vw, 1.4rem);
    font-weight: 800;
    letter-spacing: .12em;
    text-align: center;
    text-shadow: 0 2px 12px rgba(0,0,0,.7);
    transform: rotate(-18deg);
    pointer-events: none;
    background: repeating-linear-gradient(-35deg, transparent 0 46px, rgba(255,255,255,.035) 46px 47px);
}
.chat-preview figcaption { padding: 8px 10px; color: var(--muted); font-size: .78rem; }
.chat-preview__note { display: block; padding: 0 10px 10px; color: var(--dim); font-size: .68rem; }

.chat-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255,255,255,.04);
    color: var(--text);
    font-size: .8rem;
}
.chat-file:hover { border-color: var(--accent); color: var(--text); }
.chat-file__icon { font-size: 1.15rem; }
.chat-file__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-file--locked { color: var(--muted); border-style: dashed; }
.chat-file__lock { color: var(--amber); font-size: .7rem; }

.chat-composer { padding: 14px 18px; border-top: 1px solid var(--border); }
.chat-composer form { display: grid; gap: 8px; }
.chat-composer textarea { width: 100%; min-height: 70px; resize: vertical; }
.chat-composer__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chat-composer__file { color: var(--muted); font-size: .76rem; }
.chat-composer__file input { max-width: 240px; color: var(--dim); font-size: .72rem; }
.chat-closed { padding: 14px 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: .82rem; }

.chat-side { display: grid; gap: 14px; }
.chat-side .panel { padding: 18px; }
.chat-side h2 { margin: 0 0 10px; font-size: .95rem; }
.chat-side p { color: var(--muted); font-size: .8rem; line-height: 1.6; }
.chat-order-card { display: grid; gap: 10px; }
.chat-order-card__row { display: flex; justify-content: space-between; gap: 10px; font-size: .82rem; }
.chat-order-card__row span { color: var(--muted); }
.chat-original-list { display: grid; gap: 7px; }

.admin-chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.admin-chat-tools { display: grid; gap: 14px; }
.admin-chat-tools .panel { padding: 16px; }
.admin-chat-tools h2 { margin: 0 0 8px; font-size: .9rem; }
.admin-chat-tools p { color: var(--muted); font-size: .76rem; }
.admin-chat-tools form { display: grid; gap: 8px; }
.admin-chat-tools label { display: grid; gap: 4px; color: var(--muted); font-size: .76rem; }
.admin-chat-tools input,
.admin-chat-tools textarea { width: 100%; }
.admin-thread { max-height: 68vh; }

@media (max-width: 1080px) {
    .chat-shell, .admin-chat-layout { grid-template-columns: minmax(0, 1fr); }
    .chat-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .chat-side { grid-template-columns: minmax(0, 1fr); }
    .chat-msg { max-width: 94%; }
    .chat-thread { max-height: none; }
    .chat-list__item { align-items: flex-start; }
    .chat-list__side { flex-direction: column; align-items: flex-end; }
}

.chat-ai-note { margin: 0 0 12px; padding: 10px 14px; border: 1px solid rgba(124,92,255,.35); border-radius: 10px; background: rgba(124,92,255,.08); color: var(--muted, #b9b7cc); font-size: .84rem; }
.chat-msg--ai .chat-msg__author { color: #9f86ff; }
.chat-msg--ai .chat-msg__bubble { border-color: rgba(124,92,255,.35); background: rgba(124,92,255,.08); }

.chat-ai-consent { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; color: var(--muted, #b9b7cc); font-size: .78rem; line-height: 1.4; }
.chat-ai-consent input { margin-top: 3px; accent-color: #7c5cff; }
