/*
 * Video chat page (performer/{id}/chat) - desktop "stage" layout.
 *
 * Colours: video (black, framed), chat (light panel) and the viewer panels
 * (slate, with a header bar) each have their own surface (all dark; chat is the lightest tone) - see the palette.
 *
 * Loaded only by chat.twig, on top of the generated site stylesheet. The
 * video is the main element; chat, viewer info and the online list share one
 * narrow column next to it.
 *
 * Everything is limited to >= 992px: the mobile layout, and the component's
 * own full-screen mode (.full-screen), keep their original styles.
 */

@media (min-width: 992px) {

    body.page__chat {
        /* Height left for the video after header, toolbar and button row. */
        --stage-video-h: clamp(420px, calc(100vh - 250px), 900px);
        /*
         * Three surfaces that read as three separate areas:
         *   video  -> black, framed          (--stage-video-*)
         *   chat   -> lighter slate panel    (--stage-chat-*)
         *   people -> slate panels + header  (--stage-panel*)
         * all sitting on a blue-grey stage instead of black on black.
         */
        --stage-bg: #161b27;
        --stage-bg-2: #1d2433;
        --stage-panel: #252d3f;
        --stage-panel-2: #303a50;
        --stage-panel-head: #2f3950;
        --stage-line: rgba(255, 255, 255, .14);
        --stage-text: #eef1f6;
        --stage-muted: #a9b3c5;
        --stage-accent: #fd4800;
        --stage-accent-2: #5b8cff;
        --stage-online: #35d07f;
        --stage-video-line: #46516a;
        --stage-chat-bg: #323c53;
        --stage-chat-bar: #3d4963;
        --stage-chat-line: rgba(255, 255, 255, .16);
        --stage-chat-text: #f1f4f9;
        --stage-chat-muted: #b4bed0;
        --stage-radius: 12px;
    }

    /* ------------------------------------------------------------ Toolbar */

    body.page__chat .toolbar {
        gap: 12px;
        min-height: 56px;
        padding: 8px 14px;
        background: var(--stage-panel);
        border-bottom: 1px solid var(--stage-line);
        box-shadow: 0 1px 0 rgba(0, 0, 0, .25);
    }

    body.page__chat .toolbar nav { display: flex; gap: 6px; margin: 0; }

    body.page__chat .toolbar nav .prev,
    body.page__chat .toolbar nav .next {
        float: none;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--stage-panel-2);
        color: var(--stage-text);
        font-size: 22px;
        line-height: 34px;
        text-decoration: none;
        transition: background-color .12s ease;
    }

    body.page__chat .toolbar nav .prev:hover,
    body.page__chat .toolbar nav .next:hover { background: #3b4763; }

    body.page__chat .toolbar .username {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
        margin-left: 4px;
        font-size: 18px;
        font-weight: 700;
        letter-spacing: -.01em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.page__chat .toolbar .actions { align-items: center; gap: 6px; }

    body.page__chat .toolbar .actions .action-button {
        height: 36px;
        padding: 0 12px;
        border-radius: 999px;
        color: var(--stage-text);
        font-size: 13px;
        font-weight: 600;
        line-height: 1;
        white-space: nowrap;
        transition: background-color .12s ease;
    }

    body.page__chat .toolbar .actions .action-button + .action-button { border-left: 0; }

    body.page__chat .toolbar .actions .action-button > a {
        height: 36px;
        margin: 0 -12px;
        padding: 0 12px;
        border-radius: 999px;
    }

    body.page__chat .toolbar .actions .action-button:hover { background: var(--stage-panel-2); }

    body.page__chat .toolbar .actions .action-button.emergency-exit {
        background: rgba(255, 106, 0, .12);
        color: #ffb27a;
    }

    body.page__chat .toolbar .actions .action-button.emergency-exit:hover { background: rgba(255, 106, 0, .2); }
    body.page__chat .toolbar .actions .action-button.emergency-exit strong { font-weight: 600; }
    body.page__chat .toolbar .actions .action-button.emergency-exit br { display: none; }

    body.page__chat .toolbar .actions .action-button.leave-room {
        height: 36px;
        margin: 0 0 0 4px;
        padding: 0 14px;
        background: var(--stage-panel-2);
        border: 1px solid var(--stage-line);
    }

    body.page__chat .toolbar .actions .action-button.leave-room:hover { background: #c0392b; border-color: #c0392b; }

    @media (max-width: 1279px) {
        body.page__chat .toolbar .actions .action-button { padding: 0 9px; font-size: 12.5px; }
        body.page__chat .toolbar .actions .action-button > a { margin: 0 -9px; padding: 0 9px; }
    }

    /* -------------------------------------------------------------- Stage */

    body.page__chat .user-chat-window:not(.full-screen) {
        flex-direction: row;
        justify-content: center;
        align-items: stretch;
        padding: 14px;
        gap: 14px;
        background: linear-gradient(180deg, var(--stage-bg-2), var(--stage-bg));
    }

    /* Video column: as wide as the available height allows at 4:3. */
    body.page__chat .user-chat-window:not(.full-screen) > .performer-camera {
        flex: 0 1 calc(var(--stage-video-h) * 4 / 3);
        width: auto;
        max-width: none;
        min-width: 0;
        --stage-bars-h: 122px;
    }

    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .slick-container,
    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .slick-item,
    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .camera-container {
        border-radius: var(--stage-radius);
    }

    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .slick-container {
        overflow: hidden;
        background: #000;
        box-shadow: 0 0 0 2px var(--stage-video-line), 0 16px 40px rgba(0, 0, 0, .5);
    }

    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .camera-container { overflow: hidden; }

    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .camera-container video,
    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .camera-container canvas { object-fit: contain; }

    body.page__chat .user-chat-window .pipVideo-button,
    body.page__chat .user-chat-window .fullscreen-button {
        top: 12px;
        width: 36px;
        height: 36px;
        border-radius: 10px;
        background: rgba(0, 0, 0, .55);
        line-height: 36px;
        backdrop-filter: blur(6px);
        transition: background-color .12s ease;
    }

    body.page__chat .user-chat-window .fullscreen-button { right: 12px; }
    body.page__chat .user-chat-window .pipVideo-button { right: 56px; }

    body.page__chat .user-chat-window .pipVideo-button:hover,
    body.page__chat .user-chat-window .fullscreen-button:hover { background: rgba(0, 0, 0, .8); }

    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .mini-camera {
        right: 12px;
        bottom: calc(var(--stage-bars-h) + 12px);
        width: 22%;
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
    }

    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .sound-control {
        left: 12px;
        bottom: calc(var(--stage-bars-h) + 12px);
    }

    /* Button rows under the video */
    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .actions-container {
        gap: 8px;
        padding: 10px 0 0;
        background: transparent;
    }

    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .actions-container .button {
        min-height: 44px;
        margin: 0;
        padding: 6px 14px;
        border: 1px solid var(--stage-line);
        border-radius: 10px;
        background: var(--stage-panel-2);
        color: var(--stage-text);
        font-size: 13.5px;
        font-weight: 600;
        white-space: nowrap;
        transition: background-color .12s ease, border-color .12s ease;
    }

    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .actions-container .button svg * { fill: currentColor; }

    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .actions-container .button:hover {
        background: #3b4763;
        border-color: rgba(255, 255, 255, .26);
        color: #fff;
    }

    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .actions-container .button.button-secondary {
        border-color: var(--stage-accent);
        background: var(--stage-accent);
        color: #fff;
    }

    body.page__chat .user-chat-window:not(.full-screen) .performer-camera .actions-container .button.button-secondary:hover {
        border-color: #e04000;
        background: #e04000;
    }

    /* Wide screens: both button rows share one line. */
    @media (min-width: 1280px) {
        body.page__chat .user-chat-window:not(.full-screen) > .performer-camera {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            grid-template-rows: auto auto;
            column-gap: 8px;
            align-content: start;
            --stage-bars-h: 56px;
        }

        body.page__chat .user-chat-window:not(.full-screen) > .performer-camera > .slick-container,
        body.page__chat .user-chat-window:not(.full-screen) > .performer-camera > .performer-camera { grid-column: 1 / -1; }

        body.page__chat .user-chat-window:not(.full-screen) > .performer-camera > .actions-container.x .button { flex: 0 0 auto; }
    }

    /* --------------------------------------------------------- Side column */

    body.page__chat .user-chat-window:not(.full-screen) > .side-area,
    body.page__chat .user-chat-window:not(.full-screen) > .side-area.private {
        flex: 1 1 340px;
        flex-direction: column-reverse;
        gap: 10px;
        min-width: 320px;
        max-width: 440px;
        margin-left: 0;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area > .user-info {
        display: flex;
        flex: 0 0 auto;
        flex-direction: column;
        gap: 10px;
        width: 100%;
        margin-left: 0;
    }

    /* Viewer card: avatar + name on the left, remaining time + buy on the right */
    body.page__chat .user-chat-window:not(.full-screen) .side-area .user-info-container {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        height: auto;
        margin: 0;
        padding: 12px 14px;
        border: 1px solid rgba(91, 140, 255, .35);
        border-radius: var(--stage-radius);
        background: linear-gradient(135deg, #2d3a5c, #252d3f 70%);
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .user-info-container > div { flex: 1 1 auto; min-width: 0; }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .user-info-container > div:last-child {
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .user-info-container .onlines-header { display: none; }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .user-info-container .profile-container .user-info {
        min-width: 0;
        font-size: 14px;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .user-info-container .profile-container .user-info .username,
    body.page__chat .user-chat-window:not(.full-screen) .side-area .user-info-container .profile-container .user-info .user-type {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .user-info-container .profile-container .user-info .user-type { color: var(--stage-muted); }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .user-info-container .credits {
        width: auto;
        margin: 0;
        color: #fff;
        font-size: 17px;
        line-height: 1.2;
        text-align: right;
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .user-info-container > div .btn {
        height: 34px;
        padding: 0 14px;
        border-radius: 999px;
        font-size: 13px;
        font-weight: 600;
        line-height: 34px;
        white-space: nowrap;
    }

    /* Online viewers: slate panel with a header bar and one row per viewer */
    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container {
        display: flex !important;
        flex: 0 0 auto;
        flex-direction: column;
        padding: 0 !important;
        border: 1px solid var(--stage-line);
        border-radius: var(--stage-radius);
        background: var(--stage-panel) !important;
        overflow: hidden;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .onlines-header {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 9px 14px;
        border-bottom: 1px solid var(--stage-line);
        background: var(--stage-panel-head);
        color: var(--stage-text);
        font-size: 13px;
        font-weight: 600;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .onlines-header i.fa { color: var(--stage-online); opacity: 1; }
    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .onlines-header strong { color: var(--stage-online); font-variant-numeric: tabular-nums; }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .online-list {
        flex: 0 0 auto;
        height: 128px;
        padding: 6px 4px 6px 8px;
        border-bottom: 0;
        font-size: 13.5px;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .online-list .nano { width: 100%; }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .online-list ul li {
        display: flex;
        align-items: center;
        gap: 9px;
        margin-right: 6px;
        padding: 5px 8px;
        border-radius: 7px;
        color: var(--stage-text);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .online-list ul li:empty { display: none; }
    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .online-list ul li:nth-child(even) { background: rgba(255, 255, 255, .045); }
    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .online-list ul li:hover { background: rgba(255, 255, 255, .09); }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .online-list ul li::before {
        content: "";
        flex: 0 0 auto;
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: var(--stage-online);
        box-shadow: 0 0 0 3px rgba(53, 208, 127, .18);
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .online-list span > span { color: var(--stage-text); font-weight: 500; }
    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .online-list span > span.has-credits { color: #ffb072; font-weight: 600; }
    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .online-list span > span.gold { color: #ff7d90; font-weight: 600; }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .onlines-container .online-list ul li > span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .device-list-container {
        flex: 0 0 auto;
        border: 1px solid var(--stage-line);
        border-radius: var(--stage-radius);
        background: var(--stage-panel);
        overflow: hidden;
    }

    /* Chat: the lightest slate tone on the page + a coloured top edge, so it never blends into the video */
    body.page__chat .user-chat-window:not(.full-screen) .side-area > .messages {
        flex: 1 1 0;
        flex-direction: column;
        min-height: 220px;
        border: 1px solid var(--stage-chat-line);
        border-radius: var(--stage-radius);
        border-top: 2px solid var(--stage-accent-2);
        background: var(--stage-chat-bg);
        box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
        overflow: hidden;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .chat-container,
    body.page__chat .user-chat-window:not(.full-screen) .side-area .chat-container.white {
        min-height: 0;
        padding: 10px 6px 10px 12px !important;
        background: transparent !important;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .chat-container.white > .chats {
        color: var(--stage-chat-text);
        font-size: 13.5px;
        line-height: 1.45;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .chat-container.white > .chats ol li { padding: 3px 10px 3px 0; }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .chat-container.white > .chats .content { overflow-wrap: anywhere; }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .chat-container.white > .chats .username { color: var(--stage-chat-muted); font-weight: 700; }
    body.page__chat .user-chat-window:not(.full-screen) .side-area .chat-container.white > .chats .username.credits { color: #ffb072; }
    body.page__chat .user-chat-window:not(.full-screen) .side-area .chat-container.white > .chats .username.gold { color: #ff7d90; }
    body.page__chat .user-chat-window:not(.full-screen) .side-area .chat-container.white > .chats .username.performer { color: #8fe06a; }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .chat-container.white > .chats ol li .message .profile-picture { border-color: var(--stage-chat-line); }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .chat-container.white > .chats ol li.buy-credits {
        margin: 0 10px 10px 0;
        padding: 14px 12px;
        border: 1px solid var(--stage-chat-line);
        border-radius: 10px;
        background: var(--stage-chat-bar);
        color: var(--stage-chat-muted);
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .chat-container.white > .chats ol li.buy-credits strong { color: var(--stage-chat-text); }
    body.page__chat .user-chat-window:not(.full-screen) .side-area .chat-container.white > .chats ol li.buy-credits a { color: #ff9a5c; font-weight: 600; }

    /* Scrollbar */
    body.page__chat .user-chat-window:not(.full-screen) .side-area > .messages .nano > .nano-pane { background: rgba(255, 255, 255, .06); }
    body.page__chat .user-chat-window:not(.full-screen) .side-area > .messages .nano > .nano-pane > .nano-slider { background: rgba(255, 255, 255, .38); }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .composer-container {
        margin: 0 !important;
        border: 0;
        border-top: 1px solid var(--stage-chat-line);
        background: var(--stage-chat-bar);
        box-shadow: none;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .composer-container form .form-control {
        height: 46px;
        background: transparent;
        color: var(--stage-chat-text);
        font-size: 14px;
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .composer-container form .form-control::placeholder { color: var(--stage-chat-muted); opacity: 1; }
    body.page__chat .user-chat-window:not(.full-screen) .side-area .composer-container form .form-control[disabled] { opacity: .6; }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .composer-container form .button-container { padding: 5px; margin: 0; }
    body.page__chat .user-chat-window:not(.full-screen) .side-area .composer-container form .button-container .volume-button * { fill: var(--stage-chat-muted); }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .composer-container form .button-container button {
        height: 36px;
        margin: 0 0 0 6px;
        padding: 0 14px;
        border: 0;
        border-radius: 9px;
        background: var(--stage-accent);
    }

    body.page__chat .user-chat-window:not(.full-screen) .side-area .composer-container form .button-container button:hover { background: #e04000; }
    body.page__chat .user-chat-window:not(.full-screen) .side-area .composer-container form .button-container button * { fill: #fff; }

}

@media (min-width: 992px) and (prefers-reduced-motion: reduce) {
    body.page__chat .toolbar *,
    body.page__chat .user-chat-window * { transition: none !important; }
}
