/* ── Painéis ── */
.panel {
    background-color: var(--cor-fundo-card);
    border-radius: var(--raio-card);
    box-shadow: var(--sombra-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--cor-borda);
}

.panel-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.panel-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: var(--cor-primaria);
    color: #ffffff;
    font-size: 17px;
}

.panel-header h2 {
    margin: 0 0 3px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--cor-primaria);
}

.panel-header p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--cor-texto-suave);
    font-weight: 500;
}

.panel-body {
    flex: 1;
    padding: 16px 20px 20px;
}

.panel-body-scroll {
    overflow-y: auto;
    max-height: calc(100vh - 220px);
}

.badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 20px;
    background-color: var(--cor-secundaria);
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 700;
}

.hidden{
    display: none !important;
}

/* ── Tabelas ── */

.fila-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.fila-table thead th {
    padding: 10px 8px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cor-secao);
    border-bottom: 2px solid var(--cor-borda);
}

.fila-table tbody td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--cor-borda);
    color: var(--cor-texto);
    vertical-align: middle;
}

.fila-table tbody tr:last-child td {
    border-bottom: none;
}

.fila-table tbody tr:hover:not(.fila-empty) {
    background-color: var(--cor-fundo-input);
}

.fila-empty td {
    padding: 40px 16px;
    text-align: center;
    color: var(--cor-texto-suave);
    font-weight: 500;
    border-bottom: none;
}

.fila-empty i {
    display: block;
    font-size: 1.6rem;
    margin-bottom: 10px;
    color: #b0b8c4;
}

/* ── Status Tags ── */

.status-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.status-tag.aguardando {
    color: var(--cor-aguardando);
    background-color: var(--cor-aguardando-fundo);
}

.status-tag.em-atendimento {
    color: var(--cor-disponivel);
    background-color: var(--cor-disponivel-fundo);
}

/* ── Vídeo ── */

.video-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.video-container {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: 240px;
    max-height: calc(100vh - 280px);
    border-radius: var(--raio-campo);
    background-color: #000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #94a3b8;
    text-align: center;
    padding: 24px;
}

.video-placeholder i {
    font-size: 2.8rem;
    opacity: 0.6;
}

.video-placeholder p {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
}

.video-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.video-container video:not(.video-local) {
    width: auto;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

.espelhar {
    transform: scaleX(-1);
}

/* ── Indicador de gravação ("REC") ── canto superior direito da tela de
   vídeo (o preview local fica no canto superior esquerdo, sem conflito). */
.rec-indicator {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1001;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px;
    border-radius: 999px;
    background-color: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
    user-select: none;
}

.rec-indicator .rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #e74c3c;
    flex: none;
}

.rec-indicator.rec-ativa .rec-dot {
    animation: rec-pulse 1.4s ease-out infinite;
}

.rec-indicator.rec-erro {
    background-color: rgba(122, 60, 20, 0.72);
}

.rec-indicator.rec-erro .rec-dot {
    background-color: #f1c40f;
    animation: none;
}

@keyframes rec-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70%  { box-shadow: 0 0 0 9px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .rec-indicator.rec-ativa .rec-dot { animation: none; }
}

.video-local {
    top: 10px;
    left: 10px;
    z-index: 1000;
    position: absolute;
    border-radius: 10px;
    width: 20% !important;
    height: 20% !important;
    max-width: none;
    object-fit: cover;
}


/* ── Botões ── */

.btn-secundario {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    border: 1px solid var(--cor-borda);
    border-radius: var(--raio-campo);
    background-color: var(--cor-fundo-input);
    color: var(--cor-secundaria);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-secundario:hover:not(:disabled) {
    background-color: #e4e8ed;
}

.btn-secundario:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-secundario:active {
    transform: scale(0.95);
}

/* Estado "mídia desligada" dos botões Mutar/Câmera (áudio mutado ou câmera
   desligada durante a chamada) — feedback visual de que a track local está
   inativa. */
.btn-secundario.midia-desligada {
    color: #ffffff;
    background-color: var(--cor-ocupado);
    border-color: var(--cor-ocupado);
}

.btn-secundario.midia-desligada:hover:not(:disabled) {
    background-color: #a93226;
    border-color: #a93226;
}

.btn-chat {
    color: #023100;
    background-color: #08bd5f;
    border-color: #00a34f;
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

.btn-chat:hover {
    color: #a0ff9d !important;
    background-color: #00813e !important;
    border-color: #005c2c !important;
}

.btn-encerrar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    padding: 11px 22px;
    border: none;
    border-radius: var(--raio-campo);
    background-color: var(--cor-ocupado);
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.25s, opacity 0.2s;
}

.btn-encerrar:hover:not(:disabled) {
    background-color: #a93226;
}

.btn-encerrar:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Mapa ── */

.mapa-container {
    width: 100%;
    height: 220px;
    border-radius: var(--raio-campo);
    background-color: var(--cor-fundo-input);
    border: 1px solid var(--cor-borda);
    overflow: hidden;
}

.mapa-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--cor-texto-suave);
    text-align: center;
    padding: 20px;
}

.mapa-placeholder i {
    font-size: 2rem;
    color: #b0b8c4;
}

.mapa-placeholder p {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 500;
    max-width: 280px;
}


/* ── Chat ── */

.chat-iframe{
    left: 24px;
    bottom: 24px;
    width: 330px;
    border: none;
    height: 500px;
    overflow: hidden;
    margin-top: 16px;
    position: absolute;
    border-radius: var(--raio-card);
}

/* ── Responsividade (operador / componentes compartilhados) ── */

@media (max-width: 1024px) {
    .panel-body-scroll {
        max-height: none;
    }

    .panel-header {
        flex-wrap: wrap;
        padding: 14px 16px;
        gap: 10px;
    }

    .panel-header-left {
        flex: 1 1 auto;
        min-width: 0;
    }

    .panel-header .btn-secundario {
        flex-shrink: 0;
    }

    .video-container {
        min-height: 220px;
        max-height: min(58vh, 520px);
    }
}

@media (max-width: 768px) {
    .panel-icon {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }

    .panel-header h2 {
        font-size: 0.95rem;
    }

    .panel-header p {
        font-size: 0.75rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .panel-body {
        padding: 12px 14px 16px;
    }

    .fila-table {
        font-size: 0.8rem;
    }

    .fila-table thead th,
    .fila-table tbody td {
        padding: 10px 6px;
    }

    .fila-table thead th:nth-child(3),
    .fila-table tbody td:nth-child(3) {
        display: none;
    }

    .fila-empty td {
        padding: 28px 12px;
    }

    .video-container {
        min-height: 200px;
        max-height: min(52vh, 460px);
    }

    .video-placeholder {
        padding: 16px;
    }

    .video-placeholder i {
        font-size: 2.2rem;
    }

    .video-placeholder p {
        font-size: 0.88rem;
    }

    .video-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .video-controls .btn-encerrar {
        grid-column: 1 / -1;
        margin-left: 0;
        justify-content: center;
    }

    .video-local {
        width: 28% !important;
        height: 28% !important;
    }

    .btn-secundario,
    .btn-encerrar {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
}

@media (max-width: 600px) {
    .panel-header {
        padding: 12px;
    }

    .panel-header .btn-secundario {
        flex: 1 1 100%;
        justify-content: center;
    }

    .panel-body-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .fila-table {
        min-width: 280px;
    }

    .video-container {
        min-height: 180px;
        max-height: none;
        aspect-ratio: 4 / 3;
    }

    .video-controls {
        grid-template-columns: 1fr;
    }

    .video-controls .btn-secundario,
    .video-controls .btn-encerrar {
        width: 100%;
        justify-content: center;
    }

    .mapa-container {
        height: 180px;
    }
}
