/* Câmera do painel (js/painel/camera.js): tela cheia no celular, janela no computador. Sempre escura, como a do WhatsApp:
   a câmera não troca de tema. Tudo preso a `.cw-cam`; o resto do painel não enxerga estas regras. */

html.cw-cam-aberta,
html.cw-cam-aberta body {
    overflow: hidden;
}

.cw-cam {
    --cam-verde: #21c063;
    --cam-vermelho: #ff3b4e;
    --cam-vidro: rgba(24, 28, 31, 0.56);
    position: fixed;
    inset: 0;
    z-index: 30000;
    display: grid;
    place-items: center;
    background: #000;
    color: #fff;
    font-family: var(--fonte-chat, Roboto, 'Segoe UI', sans-serif);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.cw-cam-palco {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background: #000;
}

.cw-cam-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.cw-cam-video.cw-cam-espelho {
    transform: scaleX(-1);
}

.cw-cam-flash {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
}

.cw-cam-flash.cw-cam-pisca {
    animation: cw-cam-pisca 220ms ease-out;
}

@keyframes cw-cam-pisca {
    from { opacity: 0.85; }
    to { opacity: 0; }
}

/* ── barras de cima e de baixo ──────────────────────────────────────────── */

.cw-cam-topo,
.cw-cam-baixo {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 2;
    box-sizing: border-box;
}

.cw-cam-topo {
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(12px + env(safe-area-inset-top)) 16px 28px;
    background: linear-gradient(rgba(0, 0, 0, 0.5), transparent);
}

.cw-cam-topo-dir {
    display: flex;
    gap: 12px;
}

.cw-cam-baixo {
    bottom: 0;
    padding: 28px 0 calc(14px + env(safe-area-inset-bottom));
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.62));
}

.cw-cam-btn {
    display: inline-grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--cam-vidro);
    color: #fff;
    cursor: pointer;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: transform 150ms ease, background-color 150ms ease;
}

.cw-cam-btn svg,
.cw-cam-enviar svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cw-cam-btn:hover {
    background: rgba(24, 28, 31, 0.78);
}

.cw-cam-btn:active {
    transform: scale(0.92);
}

.cw-cam-btn[hidden],
.cw-cam-enviar[hidden],
.cw-cam-faixa[hidden],
.cw-cam-tempo[hidden],
.cw-cam-modos[hidden] {
    display: none;
}

.cw-cam-btn.cw-cam-ligado {
    background: #fff;
    color: #111;
}

.cw-cam-btn.cw-cam-ligado svg {
    fill: currentColor;
}

/* ── tempo da gravação ──────────────────────────────────────────────────── */

.cw-cam-tempo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.55);
    font-size: 15px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.cw-cam-tempo i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--cam-vermelho);
    animation: cw-cam-bate 1s ease-in-out infinite;
}

@keyframes cw-cam-bate {
    50% { opacity: 0.25; }
}

/* ── faixa do que já foi tirado ─────────────────────────────────────────── */

.cw-cam-faixa {
    display: flex;
    gap: 8px;
    padding: 0 16px 16px;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
}

.cw-cam-faixa::-webkit-scrollbar {
    display: none;
}

.cw-cam-mini {
    position: relative;
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: #1b2125;
    overflow: hidden;
    scroll-snap-align: end;
}

.cw-cam-mini img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cw-cam-mini-video {
    position: absolute;
    left: 4px;
    bottom: 4px;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
}

.cw-cam-mini-video svg {
    width: 12px;
    height: 12px;
    fill: #fff;
}

/* canto da miniatura: 28 px de toque, o desenho do × é menor */
.cw-cam-mini-tirar {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 0 0 0 10px;
    background: rgba(0, 0, 0, 0.66);
    cursor: pointer;
}

.cw-cam-mini-tirar svg {
    width: 12px;
    height: 12px;
    fill: none;
    stroke: #fff;
    stroke-width: 2.6;
    stroke-linecap: round;
}

/* ── disparador, galeria e enviar ───────────────────────────────────────── */

.cw-cam-controles {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 24px;
}

.cw-cam-galeria {
    justify-self: start;
}

.cw-cam-disparo {
    position: relative;
    display: grid;
    place-items: center;
    width: 78px;
    height: 78px;
    padding: 0;
    border: 4px solid #fff;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: transform 120ms ease;
}

.cw-cam-disparo span {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #fff;
    transition: background-color 160ms ease, border-radius 160ms ease, transform 160ms ease;
}

.cw-cam-disparo:active span {
    transform: scale(0.88);
}

.cw-cam-modo-video .cw-cam-disparo span {
    background: var(--cam-vermelho);
}

.cw-cam-gravando .cw-cam-disparo span {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--cam-vermelho);
}

.cw-cam-gravando .cw-cam-disparo::after {
    content: '';
    position: absolute;
    inset: -10px;
    border: 3px solid var(--cam-vermelho);
    border-radius: 50%;
    opacity: 0;
    animation: cw-cam-onda 1.4s ease-out infinite;
}

@keyframes cw-cam-onda {
    from { opacity: 0.8; transform: scale(0.9); }
    to { opacity: 0; transform: scale(1.18); }
}

/* enquanto grava só o disparador e o tempo ficam: o resto atrapalharia o dedo */
.cw-cam-gravando .cw-cam-galeria,
.cw-cam-gravando .cw-cam-modos,
.cw-cam-gravando .cw-cam-topo-dir,
.cw-cam-gravando [data-cam="fechar"] {
    visibility: hidden;
}

.cw-cam-enviar {
    position: relative;
    justify-self: end;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--cam-verde);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    transition: transform 150ms ease;
}

.cw-cam-enviar:active {
    transform: scale(0.92);
}

.cw-cam-enviar svg {
    fill: currentColor;
    stroke: none;
    width: 26px;
    height: 26px;
}

.cw-cam-enviar b {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    box-sizing: border-box;
    border-radius: 11px;
    background: #111b21;
    border: 2px solid #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}

/* ── Vídeo | Foto ───────────────────────────────────────────────────────── */

.cw-cam-modos {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 14px;
}

.cw-cam-modos button {
    min-width: 76px;
    height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 22px;
    background: transparent;
    color: rgba(255, 255, 255, 0.82);
    font: inherit;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.cw-cam-modos button[aria-selected="true"] {
    background: var(--cam-vidro);
    color: #fff;
}

.cw-cam :focus-visible {
    outline: 3px solid #53bdeb;
    outline-offset: 2px;
}

/* ── computador: janela no meio, não a tela inteira ─────────────────────── */

@media (min-width: 900px) {
    .cw-cam {
        background: rgba(0, 0, 0, 0.72);
    }

    .cw-cam-palco {
        width: min(92vw, 920px);
        height: min(88vh, 660px);
        border-radius: 16px;
        box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
    }

    .cw-cam-btn:hover {
        transform: scale(1.06);
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .cw-cam-baixo {
        padding-top: 12px;
    }

    .cw-cam-modos {
        margin-top: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cw-cam *,
    .cw-cam *::before,
    .cw-cam *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
