/* Blazor: oculta o modal "Reconectando ao servidor" - a reconexão continua em background */
#components-reconnect-modal {
    display: none !important;
}

.autocomplete-container {
    position: relative;
}

.suggestions-list {
    position: absolute;
    z-index: 1000;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
}

    .suggestions-list .list-group-item-action {
        cursor: pointer;
    }


.validation-message {
    color: #dc3545;
    font-size: 1.0em;
    margin-top: 0.25rem;
    font-weight: bold;
}


/* FullCalendar Custom Styles */
.fc-event-main {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.fc-timegrid-slot {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 60px !important;
}

.fc-non-business {
    background: none !important;
}

.agenda-tooltip {
    position: absolute;
    z-index: 10001; /* Garante que fique sobre tudo */
    background-color: #343a40; /* Fundo escuro */
    color: #fff; /* Texto branco */
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 0.85rem;
    line-height: 1.6;
    max-width: 300px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    pointer-events: none; /* Impede que o mouse interaja com o tooltip */
}

    .agenda-tooltip strong {
        color: #17a2b8; /* Ciano para destaque */
    }

.agenda-legenda {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 10px 0;
    margin-bottom: 15px;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.legenda-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
}

.legenda-cor {
    width: 15px;
    height: 15px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
}

.fc-event {
    width: 100% !important;
    height: 100% !important;
    margin: 0px !important;
}

.fc-event-title {
    color: #757171 !important;
}

.fc-bg-event {
    opacity: 0.5 !important;
}

.fc-event.event-cancelado {
    width: 48% !important;
    float: right;
    font-size: 0.8rem;
}

/* Horário bloqueado (agendamento em outra unidade): texto visível na célula */
.fc-event.event-bloqueado .fc-event-title,
.fc-event.event-bloqueado .fc-event-main {
    color: #fff !important;
}

.fc-blocked {
    background-color: #fff !important;
    opacity: 0.6;
    cursor: not-allowed !important;
    pointer-events: none;
}

.invalid-feedback{
    color: #dc3545 !important;
}

.swal-mini {
    font-size: 0.75rem !important;
    padding: 0.4rem 0.8rem !important;
    min-width: 220px !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
}

.swal-mini-title {
    font-size: 0.8rem !important;
    margin-bottom: 0.2rem !important;
    font-weight: 600 !important;
}

.swal-mini-text {
    font-size: 0.7rem !important;
    line-height: 1.1rem !important;
}

.page-title {
    margin-top: 10px !important;
}

.patient-info > div {
    line-height: 1.1rem !important;
    margin: 0 !important;
    padding: 0 !important;
}

.sticky-header {
    position: sticky;
    top: 0px !important;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.content-area {
    max-height: calc(100vh - 266px);
    overflow-y: auto;
    padding-right: 8px;
    margin-top:10px;
}

.compact-info {
    line-height: 1.1rem !important;
}

.compact-info > div {
        margin: 0 !important;
        padding: 0 !important;
    }

.compact-info strong {
        font-weight: 600;
    }

.compact-info span,
.compact-info p {
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1.1rem !important;
    }

.sticky-header h4 {
    margin-bottom: 0.3rem !important;
}

.footer {
    height: 24px !important;
    min-height: 24px !important;
    padding: 0.25rem 1rem !important;
    font-size: 0.75rem !important;
    align-items: center !important;
}

.modal-xl {
    max-width: 95vw !important;
}

.overlay-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.75);
    z-index: 2000;
    backdrop-filter: blur(2px);
}

/* Barra de botões: mesmo espaço horizontal do footer do layout */
.form-actions-floating {
    position: fixed;
    bottom: 0;
    left: var(--osen-sidenav-width);
    right: 0;
    padding: 6px 1rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    background: var(--osen-topbar-bg);
    border-top: 1px solid var(--osen-border-color);
    /* Mantém a barra acima do conteúdo, mas abaixo de overlays posicionados em headers */
    z-index: 1010;
}

html[data-layout=topnav] .form-actions-floating {
    left: 0;
}

html[data-sidenav-size=condensed]:not([data-layout=topnav]) .form-actions-floating {
    left: var(--osen-sidenav-width-sm);
}

html[data-sidenav-size=compact]:not([data-layout=topnav]) .form-actions-floating {
    left: var(--osen-sidenav-width-md);
}

html[data-sidenav-size=sm-hover]:not([data-layout=topnav]) .form-actions-floating {
    left: var(--osen-sidenav-width-sm);
}

html[data-sidenav-size=full]:not([data-layout=topnav]) .form-actions-floating,
html[data-sidenav-size=fullscreen]:not([data-layout=topnav]) .form-actions-floating {
    left: 0;
}

.form-actions-floating .btn {
    padding: 0.25rem 0.6rem;
    font-size: 0.8125rem;
}

.form-actions-floating .btn + .btn {
    margin-left: 6px;
}

/* Reserva espaço no final para a barra de botões */
.form-with-floating-actions {
    padding-bottom: 48px;
}

/* Área de filtros compacta (mesmo estilo da barra de botões) */
.filtros-compactos .card-header {
    padding: 0.35rem 0.75rem;
    font-size: 0.875rem;
}

.filtros-compactos .card-body {
    padding: 0.5rem 0.75rem 0.6rem;
}

.filtros-compactos .form-control,
.filtros-compactos .form-select {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    min-height: calc(1.5em + 0.5rem);
}

.filtros-compactos .btn {
    padding: 0.25rem 0.6rem;
    font-size: 0.8125rem;
}

.filtros-compactos .row.g-3 {
    --bs-gutter-x: 0.5rem;
    --bs-gutter-y: 0.5rem;
}

.filtros-compactos .row.g-1 {
    --bs-gutter-x: 0.5rem;
    --bs-gutter-y: 0.25rem;
}

.filtros-compactos small.text-muted {
    font-size: 0.7rem !important;
    margin-left: 2px !important;
}

.filtros-compactos .card {
    margin-bottom: 0.5rem !important;
}

.dashboard-watermark {
    position: fixed;
    top: 50%;
    left: calc(50% + 80px);
    width: 50%;
    height: 50%;
    transform: translate(-50%, -50%);
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    opacity: 0.08; /* Deixa suave */
    filter: blur(1px); /* Desfoque */
    pointer-events: none; /* Não interfere em cliques */
    z-index: 0;
}

/* Estilo para Cartões de dashboard */
.metric-card {
    border: none;
    color: #fff; /* Cor do texto dentro do cartão */
    transition: transform 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-5px);
}

.metric-card.color-blue {
    background-color: #007bff; /* Azul vibrante */
}

.metric-card.color-red {
    background-color: #dc3545; /* Vermelho vibrante */
}

.metric-card.color-green {
    background-color: #28a745; /* Verde vibrante */
}

 /* ============================
JORNADA – CORES DOS CARDS
============================ */

.metric-card.color-purple {
    background-color: #550a5b; /* Triagem */
}

.metric-card.color-indigo {
    background-color: #2f3c8f; /* Plano / Desfecho */
}

.metric-card.color-cyan {
    background-color: #0e7490; /* Escaneamento */
}

.metric-card.color-orange {
    background-color: #b45309; /* Modelagem */
}

.metric-card.color-yellow {
    background-color: #a16207; /* Impressão */
}

.metric-card.color-teal {
    background-color: #0f766e; /* Instalação / Ajuste */
}

/* ============================
   JORNADA – CORES DOS CARDS
   ============================ */

.metric-card.color-purple {
    background-color: #550a5b; /* Triagem */
}

.metric-card.color-indigo {
    background-color: #2f3c8f; /* Plano / Desfecho */
}

.metric-card.color-cyan {
    background-color: #0e7490; /* Escaneamento */
}

.metric-card.color-orange {
    background-color: #b45309; /* Modelagem */
}

.metric-card.color-yellow {
    background-color: #a16207; /* Impressão */
}

.metric-card.color-teal {
    background-color: #0f766e; /* Instalação / Ajuste */
}

.metric-card.color-gray {
    background-color: #4b5563; /* Pausar */
}

.metric-card.color-emerald {
    background-color: #065f46; /* Finalizar */
}

.metric-card .badge {
    font-size: 0.65rem;
    padding: 4px 6px;
}

.card-metricas {
    padding-top: 30px;
    padding-bottom: 0px !important;
    padding-left: 12px;
    padding-right: 12px;
}

.dashboard-card {
    padding: 12px !important;
    border-radius: 10px;
    border: 2px solid rgb(0, 0, 0, 0,05);
}

.dashboard-card h5 {
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.dashboard-chart {
    height: auto;
}

.filtro-popover {
    position: absolute;
    top: 40px;
    right: 10px;
    width: 340px;
    z-index: 20;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.10);
    padding: 10px 12px;
    animation: filtroFadeIn .15s ease-out;
}

.total{
    color: #fff;
}

.apexcharts-datalabel {
    fill: #fff !important;
    color: #fff !important;
}

#grafico-faltas .apexcharts-data-labels rect {
    fill: #f44336 !important; /* fundo vermelho */
    stroke: #f44336 !important; /* borda igual ao fundo */
}

#grafico-faltas .apexcharts-data-labels text {
    fill: #ffffff !important; /* número branco */
}

#grafico-atendimentos .apexcharts-data-labels rect {
    fill: #007bff !important; /* fundo azul */
    stroke: #007bff !important; /* borda igual ao fundo */
}

#grafico-atendimentos .apexcharts-data-labels text {
    fill: #ffffff !important; /* número branco */
}

.modal .modal-dialog {
    max-height: calc(100vh - 2rem);
    margin: 1rem auto;
}

.modal .modal-dialog .modal-content {
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
}

.modal .modal-dialog .modal-body {
    max-height: calc(100vh - 11rem);
    overflow-y: auto;
}

/* Agenda: sugestões de busca de paciente acima do rodapé e sem recorte pelo overflow da modal */
.modal.agenda-agendamento-modal .modal-dialog {
    overflow: visible;
    max-height: none;
}

.modal.agenda-agendamento-modal .modal-dialog .modal-content {
    overflow: visible;
    max-height: none;
}

.modal.agenda-agendamento-modal .modal-dialog .modal-body {
    overflow: visible;
    max-height: none;
    position: relative;
    z-index: 2;
}

.modal.agenda-agendamento-modal .modal-footer {
    position: relative;
    z-index: 1;
}

.agenda-agendamento-paciente-suggestions {
    z-index: 2000;
}

.dropdown-item{
    cursor: pointer !important;
}

.row > [class^="col-"] {
    display: flex;
    flex-direction: column;
}

input[type="radio"],
input[type="radio"] + label,
input[type="checkbox"],
input[type="checkbox"] + label {
    cursor: pointer;
}

/* Desktop: badge no fluxo da topbar (evita sobrepor engrenagem / usuário — antes era fixed + right:300px) */
.homologacao-badge {
    flex-shrink: 0;
    align-self: center;
    background: #b91c1c;
    color: #fff;
    padding: 6px 10px;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.06em;
    border-radius: 6px;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

/* Em telas estreitas, a badge não pode ficar com right:300px + z-index altíssimo:
   cobre o botão do menu (hambúrguer) e impede navegação. Faixa logo abaixo da topbar. */
@media (max-width: 991.98px) {
    .homologacao-badge {
        position: fixed;
        top: var(--osen-topbar-height, 70px);
        left: 0;
        right: 0;
        width: 100%;
        max-width: none;
        transform: none;
        border-radius: 0;
        text-align: center;
        font-size: 9px;
        padding: 5px 10px;
        letter-spacing: 0.06em;
        z-index: 999;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
        white-space: normal;
    }
}

/* Landscape em celular: mesma faixa; evita subir sobre a topbar */
@media (max-width: 991.98px) and (orientation: landscape) {
    .homologacao-badge {
        padding: 3px 8px;
        font-size: 8px;
    }
}

/* Conteúdo não fica escondido atrás da faixa de homologação (fixed abaixo da topbar) */
@media (max-width: 991.98px) {
    body:has(.homologacao-badge) .page-content {
        padding-top: 1.65rem;
    }
}

.cursor-pointer {
    cursor: pointer;
}

.complexidade-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .15s ease, box-shadow .15s ease;
}

    .complexidade-pill:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 10px rgba(0,0,0,.18);
    }

.complexidade-data {
    font-weight: 400;
    color:#fff;
}

.bg-danger {
    background-color: #f44336 !important;
}

@keyframes filtroFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Jornada Odonto: garantir mesmo tamanho de fonte nos itens Modelagem e Impressão */
#menu_999000 .sub-menu .side-nav-link .menu-text {
    font-size: calc(var(--osen-menu-item-font-size) * 0.95) !important;
}

/* ============================
   LAYOUT COMPACTO - CONFIG PLUGINS
   Espaçamento vertical equilibrado
   ============================ */
.form-with-floating-actions:has(.plugin-config-compact) .card-body {
    padding: 0.65rem 1rem !important;
}

.plugin-config-compact {
    margin-top: 0.5rem;
}

.plugin-config-compact .card {
    margin-bottom: 0.75rem !important;
}

.plugin-config-compact .card-body {
    padding: 0.65rem 1rem !important;
}

.plugin-config-compact .tab-content {
    padding-top: 0.65rem !important;
}

.plugin-config-compact .nav-tabs .nav-link {
    padding: 0.4rem 0.65rem;
    font-size: 0.875rem;
}

.plugin-config-compact .form-label {
    margin-bottom: 0.25rem !important;
}

.plugin-config-compact .form-label.fw-semibold {
    margin-bottom: 0.25rem !important;
}

.plugin-config-compact .mb-1 { margin-bottom: 0.3rem !important; }
.plugin-config-compact .mb-2 { margin-bottom: 0.5rem !important; }
.plugin-config-compact .mb-3 { margin-bottom: 0.65rem !important; }
.plugin-config-compact .mb-4 { margin-bottom: 0.75rem !important; }
.plugin-config-compact .mt-1 { margin-top: 0.3rem !important; }
.plugin-config-compact .mt-2 { margin-top: 0.5rem !important; }
.plugin-config-compact .mt-3 { margin-top: 0.65rem !important; }
.plugin-config-compact .pt-3 { padding-top: 0.65rem !important; }

.plugin-config-compact .row.g-3 {
    --bs-gutter-x: 0.65rem;
    --bs-gutter-y: 0.65rem;
}

.plugin-config-compact .row.g-2 {
    --bs-gutter-x: 0.5rem;
    --bs-gutter-y: 0.5rem;
}

.plugin-config-compact .input-group {
    margin-bottom: 0.6rem !important;
}

.plugin-config-compact .input-group.mb-3 {
    margin-bottom: 0.6rem !important;
}

/* Bloco Especialidades/Profissionais */
.plugin-config-compact .d-flex.justify-content-between.align-items-center.mb-2 {
    margin-bottom: 0.35rem !important;
}

.plugin-config-compact .d-flex.justify-content-between ~ .input-group {
    margin-bottom: 0.5rem !important;
}

.plugin-config-compact div.mt-3:has(small.text-muted) {
    margin-top: 0.5rem !important;
}

.plugin-config-compact div.mt-0:has(small.text-muted) {
    margin-top: 0.35rem !important;
}

.plugin-config-compact hr {
    margin: 0.6rem 0 !important;
}

.plugin-config-compact .form-check {
    margin-bottom: 0.35rem !important;
}

.plugin-config-compact .form-check.mb-2 {
    margin-bottom: 0.35rem !important;
}

.plugin-config-compact .form-text {
    margin-top: 0.3rem !important;
}

.plugin-config-compact .table-responsive {
    margin-top: 0.5rem !important;
}

.plugin-config-compact .table-responsive.mt-3 {
    margin-top: 0.5rem !important;
}

.plugin-config-compact .table.table-sm th,
.plugin-config-compact .table.table-sm td {
    padding: 0.3rem 0.5rem;
}

.plugin-config-compact .card-title {
    margin-bottom: 0.5rem !important;
}

.plugin-config-compact .card-title.mb-3 {
    margin-bottom: 0.5rem !important;
}

.plugin-config-compact .d-flex.gap-1 {
    gap: 0.35rem !important;
}

.plugin-config-compact .d-flex.gap-2 {
    gap: 0.5rem !important;
}

.plugin-config-compact .badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.plugin-config-compact .form-control,
.plugin-config-compact .form-select {
    padding: 0.3rem 0.5rem;
    min-height: calc(1.5em + 0.6rem);
}

.plugin-config-compact .form-control-sm {
    padding: 0.25rem 0.45rem;
}

.plugin-config-compact .btn-sm {
    padding: 0.25rem 0.55rem;
    font-size: 0.8125rem;
}

.plugin-config-compact .input-group-text {
    padding: 0.3rem 0.5rem;
}

/* Painel: dropdown "Adicionar" dentro de .table-responsive — evita ficar atrás de barras/cards */
.painel-dropdown-menu-z {
    z-index: 1080 !important;
}

/* ============================================================
   PRONT — base responsiva global (UX / layout, reutilizável)
   ============================================================ */
:root {
    --pront-touch-min: 44px;
    --pront-page-pad-x: clamp(0.65rem, 2.2vw, 1.1rem);
    --pront-content-max: 1680px;
    --pront-modal-edge: max(0.5rem, env(safe-area-inset-left, 0px));
}

/* Área principal: evita estouro horizontal em flex do tema + padding lateral equilibrado */
.page-content {
    min-width: 0;
    overflow-x: clip;
    padding-left: var(--pront-page-pad-x);
    padding-right: var(--pront-page-pad-x);
}

/* Topbar mobile: menu hambúrguer + ações à direita não podem ser empurrados para fora da tela */
.app-topbar {
    min-width: 0;
    overflow-x: visible;
}

.app-topbar .topbar-menu {
    min-width: 0;
}

.app-topbar .topbar-unidade-trigger {
    min-width: 0;
    max-width: 100%;
}

.app-topbar .topbar-unidade-text {
    min-width: 0;
}

/* Lista longa de unidades na topbar: rolagem vertical */
.app-topbar .dropdown-menu.dropdown-menu-unidades {
    max-height: min(70vh, 22rem);
    overflow-y: auto;
    overflow-x: hidden;
}

@media (max-width: 991.98px) {
    .app-topbar .topbar-menu {
        flex-wrap: wrap;
        row-gap: 0.35rem;
        column-gap: 0.25rem;
    }

    .app-topbar .topbar-cluster-start {
        flex: 1 1 auto;
        min-width: 0;
        flex-wrap: wrap;
    }

    .app-topbar .topbar-cluster-end {
        flex: 0 0 auto;
        margin-left: auto;
    }

    .app-topbar .sidenav-toggle-button,
    .app-topbar .topnav-toggle-button {
        flex-shrink: 0;
        position: relative;
        z-index: 2;
    }

    /* Garante ícone do menu visível no tema escuro/claro */
    .app-topbar .sidenav-toggle-button i,
    .app-topbar .topnav-toggle-button i {
        color: var(--osen-topbar-item-color, currentColor);
    }

    .app-topbar .nav-user .topbar-link i.ti-user-circle {
        color: var(--osen-topbar-item-color, currentColor);
    }

    .app-topbar .topbar-unidade-text {
        display: inline-block;
        max-width: min(52vw, 14rem);
        vertical-align: middle;
    }
}

/* Em telas muito estreitas, segunda linha da topbar ocupa a largura para não cortar o menu do usuário */
@media (max-width: 420px) {
    .app-topbar .topbar-cluster-end {
        flex-basis: 100%;
        justify-content: flex-end;
        margin-left: 0;
        padding-top: 0.15rem;
        border-top: 1px solid var(--osen-border-color, rgba(0, 0, 0, 0.08));
    }
}

/* Leitura confortável em telas muito largas (opt-in nas páginas) */
.pront-content-readable {
    max-width: var(--pront-content-max);
    margin-left: auto;
    margin-right: auto;
}

/* Barra de título + ações: empilha no mobile, alinha no desktop */
.pront-page-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .pront-page-toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        justify-content: space-between;
    }

    .pront-page-toolbar .pront-page-toolbar-actions {
        margin-left: auto;
        justify-content: flex-end;
    }
}

.pront-page-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* Botões em faixa inferior flutuante: mobile full-width do sidenav */
@media (max-width: 991.98px) {
    .form-actions-floating {
        left: 0 !important;
        padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
        padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
        flex-wrap: wrap;
        justify-content: stretch;
        gap: 0.5rem;
    }

    .form-actions-floating .btn {
        flex: 1 1 auto;
        min-height: var(--pront-touch-min);
        padding: 0.45rem 0.85rem;
        font-size: 0.9rem;
    }
}

/* Modal histórico de fichas (PDF): encaixa na viewport sem scroll na página */
.historico-fichas-atendimento-modal {
    position: fixed !important;
    inset: 0;
    z-index: 1055;
    overflow: hidden !important;
    overscroll-behavior: none;
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
}

.historico-fichas-atendimento-modal .modal-dialog.historico-fichas-dialog {
    margin: 0 auto !important;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: stretch;
}

@media (min-width: 576px) {
    .historico-fichas-atendimento-modal .modal-dialog.historico-fichas-dialog {
        max-width: min(1140px, 100%);
    }
}

.historico-fichas-atendimento-modal .historico-fichas-content {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Modal histórico de fichas (PDF): só no mobile (<768px) cabeçalho em 2 linhas; desktop = uma linha como antes */
.modal.historico-fichas-atendimento-modal .modal-dialog .modal-content {
    max-height: none !important;
}

/* Corpo ocupa o espaço entre header e footer (evita “vão” gigante antes do rodapé pela max-height global .modal .modal-dialog .modal-body) */
.modal.historico-fichas-atendimento-modal .modal-dialog .modal-body {
    max-height: none !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.historico-fichas-atendimento-modal .modal-footer {
    flex-grow: 0;
    flex-shrink: 0;
    padding: 0.35rem 0.75rem;
}

.historico-fichas-atendimento-modal .modal-footer > * {
    margin: 0;
}

/* Evita pseudo-elemento do modal-dialog-centered forçar altura extra */
.historico-fichas-atendimento-modal .modal-dialog.historico-fichas-dialog::before {
    display: none !important;
    content: none !important;
}

.historico-fichas-atendimento-modal .historico-fichas-modal-body {
    min-height: 0;
}

.historico-fichas-atendimento-modal .historico-fichas-modal-header-grid {
    display: grid;
    gap: 0.5rem 0.75rem;
    align-items: start;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "title close"
        "select select";
}

.historico-fichas-atendimento-modal .historico-fichas-mh-title {
    grid-area: title;
    align-self: center;
}

.historico-fichas-atendimento-modal .historico-fichas-mh-close {
    grid-area: close;
    align-self: start;
}

.historico-fichas-atendimento-modal .historico-fichas-mh-selectwrap {
    grid-area: select;
}

@media (min-width: 768px) {
    .historico-fichas-atendimento-modal .historico-fichas-modal-header-grid {
        grid-template-columns: minmax(0, 1fr) minmax(200px, 300px) auto;
        grid-template-areas: "title select close";
        align-items: center;
        gap: 0.5rem 1rem;
    }

    .historico-fichas-atendimento-modal .historico-fichas-mh-close {
        align-self: center;
    }
}

.historico-fichas-atendimento-modal .historico-fichas-pdf-host {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.historico-fichas-atendimento-modal .historico-fichas-iframe {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    border: 0;
}

/*
 * Histórico de arquivos (plugin UploadArquivos): o .razor.css do RCL não entra no bundle do host
 * sem ProjectReference — layout do header precisa existir aqui.
 */
.historico-arquivos-modal .historico-modal-header-body {
    padding-inline-end: 2.75rem;
}

.historico-arquivos-modal .historico-modal-header-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
}

/* Coluna esquerda: nome + nascimento em linhas coladas */
.historico-arquivos-modal .historico-modal-header-coluna-paciente {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.historico-arquivos-modal .historico-modal-header-coluna-paciente .historico-modal-header-nome {
    line-height: 1.2;
}

.historico-arquivos-modal .historico-modal-header-coluna-paciente .historico-modal-header-nascimento {
    line-height: 1.2;
}

.historico-arquivos-modal .historico-modal-header-coluna-paciente .historico-modal-header-nascimento .small {
    line-height: inherit;
}

.historico-arquivos-modal .historico-modal-header-filtro .form-select {
    width: 100%;
    max-width: 100%;
}

.historico-arquivos-modal .historico-modal-header-close {
    z-index: 5;
}

@media (min-width: 768px) {
    /* Duas colunas: textos à esquerda; combo à direita, alinhado à direita e centralizado na altura das duas linhas. */
    .historico-arquivos-modal .historico-modal-header-meta {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.5rem 0.75rem;
        align-items: center;
    }

    .historico-arquivos-modal .historico-modal-header-coluna-paciente {
        grid-column: 1;
        grid-row: 1;
    }

    .historico-arquivos-modal .historico-modal-header-filtro {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
        align-self: center;
        width: auto;
        min-width: 11rem;
        max-width: 17rem;
    }
}

/* Modais: melhor uso da viewport em telas pequenas */
@media (max-width: 575.98px) {
    .modal .modal-dialog:not(.modal-fullscreen):not(.telemedicina-upload-dialog) {
        margin: var(--pront-modal-edge);
        max-width: calc(100% - 2 * var(--pront-modal-edge));
    }

    .modal .modal-header,
    .modal .modal-footer {
        padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
        padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
    }

    .modal:not(.agenda-agendamento-modal) .modal-footer {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 0.5rem;
    }

    .modal:not(.agenda-agendamento-modal) .modal-footer .btn {
        width: 100%;
        min-height: var(--pront-touch-min);
    }
}

/* Tabelas → cartões empilhados em viewports estreitas (requer data-label nas células) */
@media (max-width: 767.98px) {
    .table-pront-stack thead {
        display: none;
    }

    .table-pront-stack tbody tr {
        display: block;
        border: 1px solid var(--osen-border-color, var(--bs-border-color, #dee2e6));
        border-radius: 0.5rem;
        margin-bottom: 0.75rem;
        padding: 0.5rem 0.65rem;
        /* Osen usa --osen-*; --bs-body-bg costuma não existir → caía em #fff no escuro */
        background-color: var(--osen-secondary-bg, var(--bs-secondary-bg, var(--bs-body-bg, #fff)));
    }

    .table-pront-stack tbody tr:last-child {
        margin-bottom: 0;
    }

    .table-pront-stack tbody td {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
        border: none !important;
        padding: 0.4rem 0 !important;
        /* Evita camada “table” do Osen (inset) por cima do fundo do <tr> cartão */
        background-color: transparent !important;
        box-shadow: none !important;
        color: var(--osen-body-color, var(--bs-body-color, inherit));
    }

    .table-pront-stack tbody td::before {
        content: attr(data-label);
        font-size: 0.7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        color: var(--osen-secondary-color, var(--bs-secondary-color, #6c757d));
    }

    .table-pront-stack tbody td[data-label=""]::before,
    .table-pront-stack tbody td:not([data-label])::before {
        content: none !important;
    }

    .table-pront-stack tbody td.table-pront-stack-check {
        flex-direction: row;
        align-items: center;
        gap: 0.65rem;
    }

    .table-pront-stack tbody td.table-pront-stack-check::before {
        display: none;
    }

    .table-pront-stack .form-control,
    .table-pront-stack .form-select {
        width: 100% !important;
        max-width: none !important;
    }
}

/* Áreas de conteúdo interno com altura máxima — menos restritivo no mobile */
@media (max-width: 767.98px) {
    .content-area {
        max-height: calc(100vh - 200px);
        max-height: calc(100dvh - 200px);
    }
}

/* Toque: botões pequenos um pouco maiores em telas estreitas */
@media (max-width: 767.98px) {
    .btn-sm,
    .btn-group-sm > .btn {
        min-height: 2.5rem;
        padding: 0.35rem 0.75rem;
    }

    .btn-group-sm > .btn {
        min-width: 2.5rem;
    }

    /* Telemedicina: controles circulares mic/câmera (senão min-height 2.5rem deixa o botão oval) */
    .telemedicina-videos-area .telemedicina-local-controls .btn.telemedicina-control-btn.btn-sm {
        min-height: unset !important;
        min-width: unset !important;
        padding: 0 !important;
    }

    /*
     * Upload: histórico = só ícone em círculo no mobile.
     * Espelha AdicionarArquivo.razor.css — aqui em global porque o CSS isolado do plugin
     * pode não aplicar em alguns hosts (ex.: modal na sala de telemedicina).
     */
    .upload-btn-historico.btn-sm,
    button.upload-btn-historico.btn-sm {
        min-height: 40px !important;
        min-width: 40px !important;
        max-width: 40px !important;
        max-height: 40px !important;
        width: 40px !important;
        height: 40px !important;
        padding: 0 !important;
        flex-shrink: 0;
        border-radius: 50% !important;
        gap: 0 !important;
        box-sizing: border-box;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        overflow: hidden;
        color: var(--bs-primary, #465dff) !important;
        border-color: var(--bs-primary, #465dff) !important;
        background-color: transparent !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    }

    .upload-btn-historico.btn-sm .upload-btn-historico-label,
    button.upload-btn-historico.btn-sm .upload-btn-historico-label {
        display: none !important;
    }

    .upload-btn-historico.btn-sm .upload-btn-historico-icon.ti,
    button.upload-btn-historico.btn-sm .upload-btn-historico-icon.ti {
        font-size: 1.1rem;
        line-height: 1;
        margin: 0;
    }

    .upload-btn-historico.btn-sm:hover,
    .upload-btn-historico.btn-sm:focus-visible,
    button.upload-btn-historico.btn-sm:hover,
    button.upload-btn-historico.btn-sm:focus-visible {
        color: #fff !important;
        background-color: var(--bs-primary, #465dff) !important;
        border-color: var(--bs-primary, #465dff) !important;
    }
}

/* Upload plugin: zona de anexo (complementa AdicionarArquivo.razor.css) */
.upload-arquivo-dropzone {
    position: relative;
    border: 2px dashed var(--bs-border-color);
    border-radius: 0.75rem;
    padding: 1rem 0.75rem;
    background: var(--bs-tertiary-bg, rgba(0, 0, 0, 0.02));
    transition: border-color 0.2s ease, background 0.2s ease;
}

.upload-arquivo-dropzone:focus-within {
    border-color: var(--bs-primary);
    background: rgba(var(--osen-primary-rgb, 70, 93, 255), 0.04);
}

/* Altura/padding do file input: AdicionarArquivo.razor.css (scoped) — evita conflito com ::file-selector-button do tema */

.upload-arquivo-hint {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    margin-bottom: 0;
    color: var(--bs-secondary-color);
}

/* Modal interconsulta (plugin): ordem de botões coerente com barra global em mobile */
@media (max-width: 575.98px) {
    .modal.telemedicina-modal-interconsulta .modal-footer {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .modal.telemedicina-modal-interconsulta .modal-footer .btn {
        width: 100%;
    }
}

@media (min-width: 576px) {
    .modal.telemedicina-modal-interconsulta .modal-footer {
        flex-direction: row !important;
        justify-content: flex-end !important;
    }

    .modal.telemedicina-modal-interconsulta .modal-footer .btn {
        width: auto !important;
    }
}

/* TablerIcon (SVG): substitui .ti por fonte — alinhamento com menu/topbar */
svg.tabler-svg-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    color: inherit;
}

.app-topbar svg.tabler-svg-icon {
    color: inherit;
    opacity: 1;
}

.side-nav .menu-icon svg.tabler-svg-icon {
    width: 1.15em;
    height: 1.15em;
}

/* Seta de expandir submenu: SVG (evita glifo quebrado da webfont .menu-arrow::before) */
.menu-arrow.menu-arrow-tabler::before {
    content: none !important;
    display: none !important;
}

.menu-arrow.menu-arrow-tabler .menu-arrow-svg {
    width: 1em;
    height: 1em;
    display: block;
}

/*
 * Marcador (ponto) à esquerda dos subitens do menu.
 * O tema original usava ::before + webfont Tabler (icons.min.css); o app passou a não carregar a webfont
 * (ícones via SVG TablerIcon). Sem glifo, o marcador sumia — substituímos por um círculo em CSS.
 */
.sub-menu .side-nav-link::before {
    content: "" !important;
    display: block !important;
    font-family: inherit !important;
    font-size: 0 !important;
    line-height: 0 !important;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: currentColor;
    opacity: 0.55;
    position: absolute;
    top: 50%;
    left: var(--osen-menu-item-padding-x);
    transform: translateY(-50%) !important;
    transition: opacity 0.25s ease-in-out, background-color 0.25s ease-in-out;
}

/*
 * Offcanvas "Configurações de Tema": visto dentro do círculo (como glifo Tabler \f704).
 * Sem webfont: círculo + check em SVG inline (data URI).
 */
.card-radio .form-check-input:checked + .form-check-label::before,
.card-radio .form-check-input:checked + .form-check-label:before {
    content: "" !important;
    font-family: inherit !important;
    font-size: 0 !important;
    line-height: 0 !important;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: var(--osen-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5l10 -10'/%3E%3C/svg%3E");
    background-size: 12px 12px;
    background-repeat: no-repeat;
    background-position: center;
    position: absolute;
    bottom: 2px;
    right: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.card-radio.dark .form-check-input:checked + .form-check-label::before,
.card-radio.dark .form-check-input:checked + .form-check-label:before {
    background-color: #fff !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23465dff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5l10 -10'/%3E%3C/svg%3E") !important;
}

