/* =========================================================================
   chat-menus.css — «Два меню действий над чатом» (ТЗ §5).
   Стили для js/chat-menus.js: §5.1 удержание, §5.2 «Ещё», §5.3 «Без звука».

   Самодостаточно. Не правит другие файлы. Палитра через var(--aya-*,#hex).
   Тёмная тема — body.dark-theme. Безопасные зоны — env(safe-area-inset-*).
   ========================================================================= */

/* ───────────────────────── Каркас оверлея ────────────────────────────── */

.cm-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    opacity: 0;
    transition: opacity .24s ease;
    -webkit-tap-highlight-color: transparent;
}
.cm-overlay.cm-show { opacity: 1; }

/* Размытый + затемнённый фон списка (приватность, §5.1/§5.2). */
.cm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(18, 28, 32, .42);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}
body.dark-theme .cm-backdrop {
    background: rgba(4, 12, 16, .58);
}

.cm-content {
    position: relative;
    z-index: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    pointer-events: none;          /* клики проходят к backdrop, кроме своих детей */
}
.cm-content > * { pointer-events: auto; }

/* ───────────────── Общая карта меню (узкая/широкая) ──────────────────── */

.cm-card {
    background: var(--aya-menu-bg, #f7f7f5);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(6, 37, 52, .28);
}
body.dark-theme .cm-card {
    background: var(--aya-menu-bg-dark, #20292d);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}

/* Пункт меню */
.cm-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    background: transparent;
    border: 0;
    cursor: pointer;
    font: inherit;
    font-size: 16px;
    color: var(--aya-text, #1a1d21);
    text-align: left;
    position: relative;
}
body.dark-theme .cm-row { color: var(--aya-text-dark, #e8edee); }

/* Короткие разделители (от текста, не на всю ширину) — §5.1 */
.cm-row + .cm-row::before {
    content: "";
    position: absolute;
    left: 50px;
    right: 0;
    top: 0;
    height: 1px;
    background: var(--aya-divider, rgba(0, 0, 0, .08));
}
body.dark-theme .cm-row + .cm-row::before {
    background: rgba(255, 255, 255, .08);
}

.cm-row:active { background: rgba(0, 0, 0, .05); }
body.dark-theme .cm-row:active { background: rgba(255, 255, 255, .06); }

.cm-row-ic {
    flex: 0 0 auto;
    display: inline-flex;
    color: var(--aya-text-secondary, #52606a);
}
body.dark-theme .cm-row-ic { color: #9fb0b6; }
.cm-row-ic .ic { width: 22px; height: 22px; }

.cm-row-label { flex: 1 1 auto; }

/* Опасные пункты — огненный текст/иконка */
.cm-row--danger,
.cm-row--danger .cm-row-ic {
    color: var(--aya-danger, #e8502e);
}

/* Опасная карта (§5.2) — тонированный фон */
.cm-card--danger {
    margin-top: 12px;
    background: var(--aya-danger-bg, #d6e8ec);
}
.cm-card--danger .cm-row,
.cm-card--danger .cm-row-ic {
    color: var(--aya-danger, #e8502e);
}
.cm-card--danger .cm-row + .cm-row::before {
    background: rgba(232, 80, 46, .22);
}
.cm-card--danger .cm-row:active { background: rgba(232, 80, 46, .08); }
body.dark-theme .cm-card--danger {
    background: var(--aya-danger-bg-dark, #2a3a3f);
}

/* ===================================================================== */
/* §5.1 — Долгое удержание (превью сверху + узкая карта вправо)          */
/* ===================================================================== */

.cm-hold .cm-content {
    justify-content: flex-start;
    padding: calc(env(safe-area-inset-top, 0px) + 16px) 12px
             calc(env(safe-area-inset-bottom, 0px) + 16px) 12px;
    gap: 14px;
    height: 100%;
    box-sizing: border-box;
}

/* Превью чата — header + ЖИВОЙ скроллируемый контейнер сообщений (не скрин). */
.cm-preview {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg, linear-gradient(180deg, #f4f6f7, #dfe6e9));
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 16px 50px rgba(6, 37, 52, .34);
    /* лёгкий «вылет» сверху, появление снизу */
    transform: translateY(8px) scale(.985);
    opacity: 0;
    transition: transform .26s cubic-bezier(.2, .7, .3, 1), opacity .26s ease;
}
.cm-show .cm-preview { transform: none; opacity: 1; }

.cm-pv-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, .82);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(0, 0, 0, .06);
}
body.dark-theme .cm-pv-head {
    background: rgba(18, 38, 44, .82);
    border-bottom-color: rgba(255, 255, 255, .08);
}
.cm-pv-avatar {
    flex: 0 0 auto;
    width: 42px; height: 42px;
    border-radius: 50%;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--aya-teal, #1a6b82);
    color: #fff;
    font-weight: 600;
    font-size: 17px;
}
.cm-pv-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cm-pv-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--aya-text, #1a1d21);
}
body.dark-theme .cm-pv-name { color: #e8edee; }
.cm-pv-status {
    font-size: 13px;
    color: var(--aya-text-secondary, #8a9499);
}

/* Живой скроллируемый контейнер сообщений на обоях чата */
.cm-pv-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cm-pv-loading,
.cm-pv-empty {
    margin: auto;
    color: var(--aya-text-secondary, #8a9499);
    font-size: 14px;
    text-align: center;
    padding: 24px 16px;
}

/* Пузыри превью (упрощённые, в духе §11.2) */
.cm-pv-row { display: flex; min-width: 0; }
.cm-pv-own { justify-content: flex-end; }
.cm-pv-other { justify-content: flex-start; }

.cm-pv-bubble {
    max-width: 82%;
    /* min-width pod vremya: na korotkom soobshchenii (1-2 bukvy) vremya ne uezzhaet vlevo */
    min-width: 68px;
    padding: 8px 12px 18px;
    border-radius: 16px;
    position: relative;
    font-size: 16px;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
    overflow-wrap: break-word;
    word-break: normal;
    white-space: normal;
    hyphens: none;
}
.cm-pv-text { white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; }
.cm-pv-own .cm-pv-bubble {
    background: var(--bubble-own, linear-gradient(180deg, #1f7d92, #105c6c));
    color: var(--bubble-own-text, #fff);
    border-bottom-right-radius: 4px;
}
.cm-pv-other .cm-pv-bubble {
    background: var(--bubble-other, linear-gradient(180deg, #fff, #f3f6f7));
    color: var(--bubble-other-text, #000);
    border-bottom-left-radius: 4px;
}
.cm-pv-text { white-space: pre-wrap; }
.cm-pv-img { margin: -2px 0 4px; }
.cm-pv-img img {
    max-width: 100%;
    border-radius: 10px;
    display: block;
}
.cm-pv-file {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    opacity: .9;
}
.cm-pv-time {
    position: absolute;
    right: 10px;
    bottom: 5px;
    font-size: 11px;
    opacity: .7;
}

/* Узкая карта меню — прижата ВПРАВО (у пальца), не на всю ширину */
.cm-hold-menu {
    flex: 0 0 auto;
    align-self: flex-end;
    width: min(248px, 78%);
    background: var(--aya-menu-bg, #f7f7f5);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 14px 44px rgba(6, 37, 52, .3);
    transform: translateY(12px) scale(.96);
    opacity: 0;
    transform-origin: bottom right;
    transition: transform .24s cubic-bezier(.2, .7, .3, 1) .04s, opacity .24s ease .04s;
}
.cm-show .cm-hold-menu { transform: none; opacity: 1; }
body.dark-theme .cm-hold-menu { background: var(--aya-menu-bg-dark, #20292d); }

.cm-hold-menu .cm-row { padding: 13px 15px; font-size: 15.5px; }
.cm-hold-menu .cm-row + .cm-row::before { left: 49px; }

/* ===================================================================== */
/* §5.2 / §5.3 — Bottom-sheet («Ещё») и компактная панель («Без звука»)  */
/* ===================================================================== */

.cm-sheet .cm-content {
    margin-top: auto;            /* прижато к низу */
    padding: 0 10px calc(env(safe-area-inset-bottom, 0px) + 12px);
    gap: 0;
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.2, .8, .25, 1);
}
.cm-sheet.cm-show .cm-content { transform: none; }

/* Header панели */
.cm-sheet-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 10px 12px;
}
.cm-h-avatar {
    flex: 0 0 auto;
    width: 40px; height: 40px;
    border-radius: 50%;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--aya-teal, #1a6b82);
    color: #fff;
    font-weight: 600;
    font-size: 16px;
}
.cm-h-avatar img { width: 100%; height: 100%; object-fit: cover; }

.cm-h-id { flex: 1 1 auto; min-width: 0; }
.cm-h-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--aya-text, #1a1d21);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
body.dark-theme .cm-h-name { color: #f1f4f5; }
.cm-h-sub {
    font-size: 13px;
    color: var(--aya-text-secondary, #8a9499);
}
.cm-h-title {
    flex: 1 1 auto;
    font-size: 18px;
    font-weight: 700;
    color: var(--aya-text, #1a1d21);
}
body.dark-theme .cm-h-title { color: #f1f4f5; }

/* Кнопки header: X в круге, ◁ назад в круге */
.cm-hbtn {
    flex: 0 0 auto;
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .06);
    color: var(--aya-text-secondary, #52606a);
    cursor: pointer;
}
body.dark-theme .cm-hbtn {
    background: rgba(255, 255, 255, .1);
    color: #c6d2d6;
}
.cm-hbtn:active { background: rgba(0, 0, 0, .12); }
.cm-hbtn .ic { width: 18px; height: 18px; }

/* ── §5.3 «Без звука»: панель светло-серая, кнопки белые ── */
.cm-mute .cm-content {
    background: var(--aya-mute-panel, #eef0f2);
    border-radius: 18px 18px 0 0;
    padding-left: 16px;
    padding-right: 16px;
}
body.dark-theme .cm-mute .cm-content {
    background: #1a2226;
}
.cm-mute .cm-sheet-head--mute { padding-left: 0; padding-right: 0; }

.cm-mute-note {
    background: #fff;
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 14px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--aya-text-secondary, #52606a);
}
body.dark-theme .cm-mute-note {
    background: #232c30;
    color: #9fb0b6;
}

.cm-mute-opts {
    background: transparent;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: visible;
}
.cm-mute-opt {
    width: 100%;
    padding: 16px 18px;
    background: #fff;
    border: 0;
    border-radius: 14px;
    text-align: left;
    font: inherit;
    font-size: 16px;
    color: var(--aya-text, #1a1d21);
    cursor: pointer;
}
.cm-mute-opt:active { background: #f2f4f6; }
body.dark-theme .cm-mute-opt {
    background: #232c30;
    color: #e8edee;
}
body.dark-theme .cm-mute-opt:active { background: #2b363b; }

/* ===== Krupnee, no ne zhirno — tekst menyu/modalok (po prosbe Gleba) ===== */
.cm-row, .cm-row-label { font-size: 18px !important; font-weight: 500 !important; }
.sheet-btn { font-size: 18px !important; font-weight: 500 !important; }
.aya-ci-row-label { font-size: 18px !important; font-weight: 500 !important; }
.aya-ci-name { font-size: 25px !important; font-weight: 600 !important; }
.aya-ci-quick-label { font-size: 14px !important; font-weight: 500 !important; }
.cc-tab { font-size: 17px !important; font-weight: 500 !important; }
.cc-bubble, .cc-bubble-file-name { font-size: 17px !important; font-weight: 400 !important; }
.search-row-name { font-size: 18px !important; font-weight: 500 !important; }
.search-cat { font-size: 18px !important; font-weight: 500 !important; }
.search-cats-title, .search-section-title { font-size: 13px !important; }
