/* ============================================================
   APPI - Estilos Globais (compartilhado entre todas as paginas)
   ============================================================ */

/* --- Reset e tipografia (Design System MS) --- */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background-color: #f8f9fa;
    color: #243447;
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
}

/* Headings - Avenir Next LT Pro (DS MS) com fallback */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: 'Avenir Next LT Pro', 'Montserrat', 'Segoe UI', sans-serif;
    font-weight: 600;
    line-height: 1.2;
    color: #1e293b;
    margin-top: 0;
    margin-bottom: 0.5rem;
}
.display { font-size: 3.5rem; font-weight: 700; line-height: 1.143; }   /* 56/64 */
h1, .h1 { font-size: 2.5rem; font-weight: 700; line-height: 1.2; }      /* 40/48 */
h2, .h2 { font-size: 2rem; font-weight: 600; line-height: 1.5; }        /* 32/48 */
h3, .h3 { font-size: 1.5rem; font-weight: 600; line-height: 1.667; }    /* 24/40 */
h4, .h4 { font-size: 1.25rem; font-weight: 600; line-height: 1.4; }     /* 20/28 */
h5, .h5 { font-size: 1rem; font-weight: 600; line-height: 1.5; }        /* 16/24 */
h6, .h6 { font-size: 0.875rem; font-weight: 600; line-height: 1.4; }

/* Body text scale - Open Sans */
.body-large  { font-family: 'Open Sans', sans-serif; font-size: 1.25rem; font-weight: 400; line-height: 1.4; }   /* 20/28 */
.body-medium { font-family: 'Open Sans', sans-serif; font-size: 1rem;   font-weight: 400; line-height: 1.5; }     /* 16/24 */
.body-small  { font-family: 'Open Sans', sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.429; } /* 14/20 */
.tiny        { font-family: 'Open Sans', sans-serif; font-size: 0.75rem; font-weight: 400; line-height: 1.333; }  /* 12/16 */

/* Font weights */
.font-regular  { font-weight: 400; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

/* --- Login (index.html) --- */
.login-page {
    background: #f1f5f9;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: white;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
}

/* --- Layout padrao das paginas internas --- */
.app-layout {
    height: 100vh;
    overflow: hidden;
}

.app-content {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ============================================
   Floating Hamburger Button (substitui a sidebar)
   ============================================ */
.hamburger-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}
.hamburger-btn:hover {
    background: #f1f5f9;
    color: #0d6efd;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

/* Hamburger dentro da topbar (nao flutuante) */
.app-topbar .hamburger-btn {
    box-shadow: none;
    border-color: #e2e8f0;
}
.app-topbar .hamburger-btn:hover {
    background: #f1f5f9;
    color: #0d6efd;
}

/* Overlay escuro quando o menu está aberto */
.hamburger-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1055;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.hamburger-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* Menu lateral deslizante */
.hamburger-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    z-index: 1060;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}
.hamburger-menu.open {
    transform: translateX(0);
}

.hamburger-menu .menu-brand {
    padding: 0.25rem 0.5rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 0.75rem;
}

.hamburger-menu nav {
    flex: 1;
    overflow-y: auto;
}

.hamburger-menu .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #495057;
    border-radius: 0.5rem;
    padding: 0.55rem 0.75rem;
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    transition: background-color 0.15s;
}

.hamburger-menu .nav-link i {
    flex-shrink: 0;
    font-size: 1.2rem;
    width: 1.5rem;
    text-align: center;
}

.hamburger-menu .nav-link:hover {
    background-color: #edf4ff;
    color: #1f4775;
}

.hamburger-menu .nav-link.active {
    background-color: #0d6efd;
    color: #fff;
}

.hamburger-menu .nav-link.active:hover {
    background-color: #0b5ed7;
}

/* --- Topbar --- */
.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.25rem;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    gap: 0.75rem;
    min-height: 52px;
    position: sticky;
    top: 0;
    z-index: 1040;
    flex-shrink: 0;
}

.app-topbar > div:first-child {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.app-topbar > div:first-child > div {
    min-width: 0;
}

.app-topbar h2 {
    font-family: 'Avenir Next LT Pro', 'Montserrat', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.app-topbar p {
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    color: #6c757d;
    margin: 0;
    line-height: 1.4;
}

/* --- Main content --- */
.app-main {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
}

/* --- Profile trigger --- */
.profile-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    border: 1px solid #d8e4f5;
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
}

.profile-trigger img {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
}

.profile-trigger .profile-name {
    font-weight: 600;
    font-size: 0.8rem;
}

.profile-avatar-initials {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #6366f1;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.profile-trigger .profile-role {
    font-size: 0.7rem;
    color: #6c757d;
}

/* --- Botoes padrao --- */
.btn-primary {
    background-color: #6366f1;
    border: none;
}

.btn-primary:hover {
    background-color: #4f46e5;
}

/* --- Tabelas padrao CRUD --- */
.crud-table-container {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    overflow: hidden;
}

.crud-table-container table {
    margin: 0;
}

.crud-table-container th {
    background-color: #f8fafc;
    font-family: 'Open Sans', sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    padding: 0.6rem 0.75rem;
}

.crud-table-container td {
    padding: 0.5rem 0.75rem;
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    vertical-align: middle;
    line-height: 1.4;
}

.crud-table-container tbody tr:hover {
    background-color: #f1f5f9;
}

/* --- Cards de filtro --- */
.crud-filters-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 1rem;
}

.crud-filters-card .form-label {
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.25rem;
}

.crud-filters-card select[multiple]:not(.tomselected) {
    height: 31px;
    min-height: 31px;
    overflow: hidden;
}

.crud-filters-card .form-select-sm,
.crud-filters-card .form-control-sm,
.crud-filters-card .ts-wrapper {
    min-height: 31px;
}

.crud-filters-card .ts-control {
    min-height: 31px !important;
    padding: 2px 8px !important;
}

.crud-filters-card .ts-control input {
    height: auto !important;
    min-height: unset !important;
}

.crud-filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.crud-filter-actions .btn {
    white-space: nowrap;
}

/* --- Paginacao --- */
.crud-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    font-size: 0.85rem;
    color: #6c757d;
}

/* --- Modal CRUD --- */
.crud-modal .modal-dialog {
    max-width: min(800px, calc(100vw - 2rem));
}

.crud-modal .modal-content {
    border-radius: 1rem;
    max-height: calc(100vh - 3rem);
}

.crud-modal .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

.crud-modal .modal-body .row {
    gap: 0;
}

/* A página de ações da agenda recebe os campos movidos para fora do
   .crud-modal (js/agenda_action_modal.js). Sem repetir o escopo aqui, as
   labels caem no peso normal do Bootstrap e deixam de se distinguir do
   valor preenchido. */
.crud-modal .form-label,
#agenda-action-page .form-label {
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.25rem;
}

.crud-modal .form-control,
.crud-modal .form-select {
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
}

/* --- Modal em tela cheia (padrao dos cadastros) ---
   Usar junto de .modal-fullscreen no .modal-dialog. Vem depois de
   .crud-modal de proposito: precisa vencer o max-width de 800px e o
   max-height de 60vh, que tem a mesma especificidade. */
.modal-full .modal-dialog {
    max-width: none;
    width: 100vw;
    height: 100%;
    margin: 0;
}

.modal-full .modal-content {
    height: 100%;
    max-height: none;
    border: none;
    border-radius: 0;
}

.modal-full .modal-header {
    padding: 0.7rem 1.25rem;
    align-items: flex-start;
}

.modal-full .modal-body {
    max-height: none;
    padding: 1.25rem;
    overflow-y: auto;
}

.modal-full .modal-footer {
    padding: 0.6rem 1.25rem;
}

/* Tela cheia nao significa campos de 1900px: o conteudo fica numa coluna
   de leitura centralizada. */
.modal-full .modal-body > * {
    max-width: 1080px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Tom Select --- */
.ts-wrapper {
    min-height: 2.2rem;
    padding: 0 !important;
}

/* Remove a aparência de lista suspensa aninhada do ts-control */
.ts-wrapper .ts-control {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0.40rem 0.5rem !important;
    min-height: unset !important;
}

/* Remove a setinha indicadora de lista suspensa */
.ts-wrapper.single .ts-control::after {
    display: none !important;
}

.ts-dropdown {
    border-color: #d8e4f5;
    border-radius: 0.5rem;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    /* Acima da página de ações da agenda (#agenda-action-page, z-index 1080)
       e dos modais Bootstrap, para o dropdown nunca abrir atrás do painel. */
    z-index: 1090;
}

.ts-dropdown .option {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

/* --- Quill Editor --- */
#editor-tematicas,
#editor-info {
    font-size: 0.85rem;
}
#editor-tematicas .ql-toolbar,
#editor-info .ql-toolbar {
    border-radius: 0.375rem 0.375rem 0 0;
    background: #f8f9fa;
    border: 1px solid #ced4da;
    border-bottom: none;
}
#editor-tematicas .ql-container,
#editor-info .ql-container {
    border-radius: 0 0 0.375rem 0.375rem;
    border: 1px solid #ced4da;
    background: #fff;
    min-height: 140px;
}

/* Destaque para o campo Info */
#editor-info .ql-toolbar {
    background: #e9ecef;
    border-color: #adb5bd;
}
#editor-info .ql-container {
    background: #f8f9fa;
    border-color: #adb5bd;
}

/* Barra de formatação sob demanda (js/quill_toolbar.js)
   Colapsada, a toolbar preserva apenas a borda superior: ela faz o
   papel da borda de topo do campo, que o Quill remove do
   .ql-container quando existe uma toolbar irmã. */
.ql-toolbar.ql-snow.appi-tb-hidden {
    height: 0 !important;
    min-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-bottom-width: 0 !important;
    overflow: hidden !important;
}
/* Campos cuja moldura vem do wrapper: aqui a borda da toolbar
   colapsada apareceria como uma segunda linha, colada à do wrapper. */
.descricao-richtext-wrapper .ql-toolbar.appi-tb-hidden {
    border-width: 0 !important;
}
/* Sem a toolbar em cima, o container passa a ser o topo do campo e
   recupera os cantos arredondados. */
.form-descricao-wrapper .ql-toolbar.appi-tb-hidden + .ql-container.ql-snow {
    border-top-left-radius: 0.25rem;
    border-top-right-radius: 0.25rem;
}

/* Altura dinâmica: o campo cresce com o texto em vez de rolar dentro
   de uma caixa fixa. A altura declarada em cada campo vale como
   mínimo (min-height), nunca como teto.
   O container vira flex para a área de digitação continuar preenchendo
   toda a altura mínima — sem isso, clicar na parte de baixo de um campo
   vazio não colocaria o cursor no texto. */
.ql-container.ql-snow {
    height: auto;
    display: flex;
    flex-direction: column;
}
.ql-container.ql-snow > .ql-editor {
    flex: 1 1 auto;
    max-height: none;
    overflow-y: visible;
}
/* Exceção: o diário de bordo é um editor de página inteira, com rolagem
   própria dentro do wrapper — ali a altura é mesmo a da janela. */
.diario-quill-wrapper .ql-container.ql-snow {
    display: block;
    height: 100%;
}
.diario-quill-wrapper .ql-container.ql-snow > .ql-editor {
    height: 100%;
    overflow-y: auto;
}

/* Tooltip de link do Quill — centralizado no modal */
.ql-tooltip {
    position: fixed !important;
    z-index: 9999 !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
}

/* --- View Roteiro --- */
.view-roteiro {
    font-size: 0.95rem;
    line-height: 1.6;
}
.view-roteiro h5 {
    font-weight: 700;
    color: #1e293b;
}
.view-tematicas, .view-info {
    line-height: 1.7;
}
.view-tematicas ul, .view-tematicas ol,
.view-info ul, .view-info ol {
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
}

/* --- Card Resumo UE --- */


/* --- Card Resumo UE --- */
.card-ue-resumo {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
}
.card-ue-resumo .card-body {
    padding: 1rem;
}
.card-ue-resumo .card-body .row > div {
    padding: 0.25rem 0.5rem;
}

/* --- Servidores Table --- */
#servidores-table {
    font-size: 0.85rem;
}
#servidores-table th {
    background: #f8f9fa;
    font-weight: 600;
}

/* --- Filtros cascade --- */
.crud-filters-card .ts-wrapper {
    min-height: 2rem;
}

/* --- Modal Feedback --- */
#modal-feedback .modal-fullscreen {
    max-width: min(800px, calc(100vw - 2rem));
    margin: 1rem auto;
}
#modal-feedback .modal-content {
    border-radius: 0.75rem;
    min-height: 70vh;
}
#modal-feedback .modal-body {
    padding-bottom: 0;
}
/* Feedback: seções empilhadas em largura total */
.feedback-section-card {
    margin-bottom: 1rem;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.feedback-section-card .card-header {
    cursor: pointer;
    user-select: none;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.7rem 1rem;
}
.feedback-section-card .card-header:hover {
    background: #f1f5f9;
}
.feedback-section-card .card-header h6 {
    margin: 0;
    font-size: 0.9rem;
}
.feedback-section-card .card-body {
    padding: 1rem;
}

/* Subseções dentro da Avaliação */
.feedback-subsection {
    margin-bottom: 0.75rem;
    border: 1px solid #eef2f7;
    border-radius: 0.5rem;
    background: #fafcff;
}
.feedback-subsection-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid transparent;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    transition: background 0.15s;
}
.feedback-subsection-header:hover {
    background: #f1f5f9;
}
.feedback-subsection:not(:last-child) {
    margin-bottom: 0.75rem;
}
.feedback-subsection .collapse.show + .feedback-subsection-header {
    border-bottom-color: #eef2f7;
}
.feedback-subsection .feedback-editor {
    border: none;
}
.feedback-subsection .feedback-editor .ql-toolbar {
    border-radius: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: none;
    border-right: none;
}
.feedback-subsection .feedback-editor .ql-container {
    border: none;
    background: #fff;
    min-height: 90px;
}
.feedback-subsection .feedback-editor .ql-editor {
    min-height: 90px;
}

/* Metadata rodapé da avaliação */
.feedback-metadata {
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

/* Collapse icons */
.feedback-section-card .collapse-icon,
.feedback-subsection .collapse-icon {
    transition: transform 0.25s ease;
    font-size: 0.85rem;
    color: #94a3b8;
}
.feedback-section-card .card-header[aria-expanded="false"] .collapse-icon,
.feedback-subsection-header[aria-expanded="false"] .collapse-icon {
    transform: rotate(-90deg);
}

/* --- Legendas do Calendário (checkboxes) --- */
.legend-toggle {
    cursor: pointer;
    user-select: none;
    transition: opacity 0.2s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    font-weight: 600;
    opacity: 1;
}
.legend-toggle:not(.active) {
    opacity: 0.4;
    text-decoration: line-through;
}
.legend-toggle:not(.active):hover {
    opacity: 0.6;
}
.legend-toggle.active:hover {
    opacity: 0.8;
}
.legend-toggle::before {
    content: '☑';
    font-size: 0.75rem;
    line-height: 1;
}
.legend-toggle:not(.active)::before {
    content: '☐';
}
.legend-toggle-agenda {
    background: #dbeafe !important;
    color: #1e3a8a !important;
    border: 1px solid #93c5fd !important;
}
.legend-toggle-agenda.active {
    background: #eff6ff !important;
    box-shadow: 0 0 0 2px #3b82f6;
}
.legend-toggle-roteiro {
    background: #fef3c7 !important;
    color: #92400e !important;
    border: 1px solid #fcd34d !important;
}
.legend-toggle-roteiro.active {
    background: #fffbeb !important;
    box-shadow: 0 0 0 2px #f59e0b;
}
.legend-toggle-escolar {
    background: #dadada !important;
    color: #000000 !important;
    border: 2px solid #3e3e3e !important;
}
.legend-toggle-escolar.active {
    background: #f2f0f9 !important;
    box-shadow: 0 0 0 2px #f6ebeb;
}

/* --- Feedback --- */
.alert-crud {
    margin-bottom: 0;
}

/* --- Mensagens de erro/sucesso --- */
.feedback-error { color: #ef4444; font-weight: 600; }
.feedback-success { color: #10b981; font-weight: 600; }

/* --- Stats Cards (Agenda) --- */
.stat-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.45rem 0.65rem;
    min-width: 88px;
    text-align: center;
    border-top: 3px solid #6c757d;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.16rem;
}
.stat-card .stat-value {
    order: 2;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
    color: #1e293b;
}
.stat-card .stat-label {
    order: 1;
    font-size: 0.7rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    white-space: nowrap;
}
/* Fundo/borda do cartão quando agrupado (ver #stats-cards-container abaixo):
   precisa vir ANTES das cores de status — mesma especificidade de ".stat-card
   .border-top-*", então a ordem no arquivo é quem decide, e a de baixo apagaria
   as cores se viesse depois (era exatamente o bug: sumia no claro). */
.stats-group .stat-card {
    background: #fff;
    border-color: #eef2f7;
}
.stat-card.border-top-success { border-top-color: #10b981; }
.stat-card.border-top-info { border-top-color: #0ea5e9; }
.stat-card.border-top-danger { border-top-color: #ef4444; }
.stat-card.border-top-primary { border-top-color: #6366f1; }
.stat-card.border-top-warning { border-top-color: #f59e0b; }
.stat-card.border-top-lido { border-top-color: #8b5cf6; }
.stat-card.stat-card-total { border-top-color: #475569; }
/* Cartões de status (grupo "Status"): mesma cor das badges da coluna
   Status na tabela (.agenda-status-*), para o cartão e a badge lerem
   como a mesma categoria em vez de dois esquemas de cor diferentes. */
.stat-card.border-top-status-programada { border-top-color: #7e22ce; }
.stat-card.border-top-status-realizada { border-top-color: #0369a1; }
.stat-card.border-top-status-concluida { border-top-color: #15803d; }
.stat-card.border-top-status-cancelada { border-top-color: #b91c1c; }
.stat-card .stat-value .stat-pct {
    font-size: 0.68rem;
    font-weight: 500;
    color: #94a3b8;
    margin-left: 0.15em;
    vertical-align: middle;
}

/* Stats grouped boxes */
#stats-cards-container {
    display: flex;
    align-items: stretch;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.stats-group {
    border: 1px solid #e2e8f0;
    border-top: 3px solid #cbd5e1;
    border-radius: 0.5rem;
    padding: 0.35rem 0.55rem 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    background: #f8fafc;
}
.stats-group-label {
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    line-height: 1;
    padding-left: 0.1rem;
}
.stats-group-cards {
    display: flex;
    gap: 0.4rem;
    align-items: stretch;
    /* Realizadas tem quatro cartoes: em tela estreita eles quebram
       dentro do grupo em vez de esticar a barra inteira. */
    flex-wrap: wrap;
}
/* Group color variants */
.stats-group-agendamentos {
    border-top-color: #475569;
    background: #f8fafc;
}
.stats-group-agendamentos .stats-group-label { color: #475569; }
.stats-group-status {
    border-top-color: #6366f1;
    background: #fafafa;
}
.stats-group-status .stats-group-label { color: #6366f1; }
.stats-group-realizadas {
    border-top-color: #10b981;
    background: #f6fefb;
}
.stats-group-realizadas .stats-group-label { color: #10b981; }

/* --- Descricao RichText (builder) --- */
.descricao-richtext-wrapper {
    position: relative;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    transition: border-color 0.15s;
}
.descricao-richtext-wrapper:hover {
    border-color: #86b7fe;
}
.descricao-richtext-wrapper:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13,110,253,0.15);
}
.descricao-richtext-wrapper .ql-toolbar {
    border-radius: 0.2rem 0.2rem 0 0;
    background: #f8f9fa;
    padding: 2px 4px;
    border-bottom: 1px solid #dee2e6;
}
.descricao-richtext-wrapper .ql-toolbar .ql-formats {
    margin-right: 6px;
}
.descricao-richtext-wrapper .ql-container {
    border: none;
    font-size: 0.85rem;
    font-family: 'Open Sans', sans-serif;
}
.descricao-richtext-wrapper .ql-editor {
    min-height: 38px;
    padding: 4px 8px;
}
.descricao-richtext-wrapper .ql-editor.ql-blank::before {
    font-style: normal;
    color: #adb5bd;
    font-size: 0.82rem;
}
/* Form descricao editor (Quill no modal de forms) */
.form-descricao-wrapper {
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
}
.form-descricao-wrapper:hover {
    border-color: #86b7fe;
}
.form-descricao-wrapper:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13,110,253,0.15);
}
.form-descricao-editor.ql-container.ql-snow {
    height: auto !important;
    min-height: 140px;
    font-size: 0.9rem;
    font-family: 'Open Sans', sans-serif;
    overflow: visible;
    border: none;
    border-radius: 0 0 0.2rem 0.2rem;
    background: #fff;
}
.form-descricao-editor .ql-editor {
    min-height: 100px;
    padding: 0.75rem 0.9rem;
}
.form-descricao-wrapper .ql-toolbar {
    border-radius: 0.25rem 0.25rem 0 0;
    background: #f8f9fa;
    border: none;
    border-bottom: 1px solid #dee2e6;
}
.form-descricao-wrapper .ql-container {
    border: none;
    border-radius: 0 0 0.25rem 0.25rem;
}
.form-descricao-wrapper .ql-editor.ql-blank::before {
    font-style: normal;
    color: #adb5bd;
}

/* Descricao view (simulador/responder) */
.descricao-view {
    line-height: 1.5;
}
.descricao-view p {
    margin-bottom: 0.25rem;
}
.descricao-view ul, .descricao-view ol {
    padding-left: 1.2rem;
    margin-bottom: 0.25rem;
}

@media (max-width: 991.98px) {
    #modal-feedback .modal-fullscreen {
        max-width: calc(100vw - 1rem);
        margin: 0.5rem auto;
    }

    #modal-feedback .modal-content {
        min-height: calc(100vh - 1rem);
    }
}

/* --- Botão bloqueado (finalizado) --- */
.btn-blocked {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
    pointer-events: auto !important;
}
.btn-blocked:hover {
    opacity: 0.45 !important;
}

/* --- Status Agenda (Badges e Dashboard) --- */
.agenda-status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid;
}

/* Programada - Roxo Claro */
.agenda-status-programada {
    color: #7c3aed;
    background-color: #ede9fe;
    border-color: #ddd6fe;
}

/* Realizada - Azul */
.agenda-status-realizada {
    color: #0284c7;
    background-color: #cffafe;
    border-color: #a5f3fc;
}

/* Concluída - Verde */
.agenda-status-concluida {
    color: #16a34a;
    background-color: #dcfce7;
    border-color: #bbf7d0;
}

/* Cancelada - Vermelho */
.agenda-status-cancelada {
    color: #dc2626;
    background-color: #fee2e2;
    border-color: #fecaca;
}

/* --- Responsivo --- */
@media (max-width: 768px) {
    .hamburger-btn {
        width: 34px;
        height: 34px;
        font-size: 1.1rem;
    }
    .hamburger-menu {
        width: 220px;
    }
    .app-topbar {
        padding: 0.5rem 0.75rem;
    }
    .app-topbar h2 {
        font-size: 1rem;
    }
}

/* ============================================================
   RichText exibido EM LINHA (titulo de pergunta em cards,
   tabelas e cabecalhos). O JS (renderRichInline) ja desembrulha
   os <p> do Quill; estas regras sao a rede de seguranca para
   conteudo antigo ou colado de fora.
   ============================================================ */
.rich-inline p,
.rich-inline div {
    display: inline;
    margin: 0;
}
.rich-inline ul,
.rich-inline ol {
    display: inline;
    margin: 0;
    padding-left: 0;
    list-style: none;
}
.rich-inline img {
    max-height: 1.4em;
    vertical-align: text-bottom;
}

/* ============================================================
   Validacao ao responder formularios (js/agenda_forms.js)
   O erro aparece no proprio campo enquanto a pessoa digita,
   nao so depois de clicar em salvar.
   ============================================================ */
.resp-erro {
    font-size: 0.78rem;
    color: #dc3545;
    margin-top: 0.35rem;
}
.resp-dica {
    font-size: 0.72rem;
    color: #6c757d;
    margin-top: 0.25rem;
}
.sim-card-invalido {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.15rem rgba(220, 53, 69, 0.12);
}
.sim-card-invalido .card-title {
    color: #b02a37;
}
#resp-resumo-erros .resp-erro-link {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

/* ============================================================
   Campos de resposta que crescem com o texto (js/agenda_forms.js)
   Altura fixa com rolagem interna esconde o que ja foi escrito e
   atrapalha reler a propria resposta: os dois campos de texto
   crescem e quem rola e a pagina.
   ============================================================ */
.resp-textarea-auto {
    /* A altura real e calculada no JS (autoResizeCampoTexto); estes valores
       valem enquanto o campo esta oculto e o scrollHeight nao e confiavel. */
    min-height: calc(1.5em + 0.5rem + 2px);
    overflow-y: hidden;
    resize: none;
}
/* field-sizing resolve tudo nativamente onde existe; o JS continua como
   caminho principal para os navegadores que ainda nao suportam. */
@supports (field-sizing: content) {
    .resp-textarea-auto { field-sizing: content; }
}
.resp-quill-auto.ql-container {
    height: auto;
}
.resp-quill-auto .ql-editor {
    min-height: 150px;
    max-height: none;
    overflow-y: visible;
}

/* ============================================================
   Diálogos APPI (substituem alert/confirm/prompt do navegador)
   ============================================================ */
.appi-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.16s ease;
}
.appi-dialog-backdrop.is-visible { opacity: 1; }
.appi-dialog-backdrop.is-closing { opacity: 0; }

.appi-dialog {
    width: min(100%, 460px);
    overflow: hidden;
    background: #fff;
    color: #243447;
    border: 1px solid #dbe3ec;
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
    transform: translateY(10px) scale(0.985);
    transition: transform 0.18s ease;
}
.appi-dialog-backdrop.is-visible .appi-dialog { transform: translateY(0) scale(1); }
.appi-dialog-backdrop.is-closing .appi-dialog { transform: translateY(8px) scale(0.99); }

.appi-dialog__header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.85rem;
    padding: 1.1rem 1.15rem 0.9rem;
    border-bottom: 1px solid #e2e8f0;
}
.appi-dialog__icon {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: #eaf3ff;
    color: #1d65b9;
    font-size: 1.25rem;
}
.appi-dialog--danger .appi-dialog__icon { background: #fff0f1; color: #c92a3a; }
.appi-dialog--warning .appi-dialog__icon { background: #fff7df; color: #a16207; }
.appi-dialog--success .appi-dialog__icon { background: #eafaf0; color: #167447; }
.appi-dialog--info .appi-dialog__icon { background: #e8f8fd; color: #087990; }

.appi-dialog__heading { min-width: 0; }
.appi-dialog__title {
    margin: 0;
    color: #172033;
    font-size: 1.05rem;
    line-height: 1.35;
}
.appi-dialog__close {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #64748b;
    transition: background-color 0.15s, color 0.15s;
}
.appi-dialog__close:hover { background: #f1f5f9; color: #1e293b; }
.appi-dialog__close:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.24);
    outline-offset: 1px;
}

.appi-dialog__body { padding: 1.1rem 1.15rem 1.2rem; }
.appi-dialog__message {
    margin: 0;
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-line;
}
.appi-dialog__field { margin-top: 1rem; }
.appi-dialog__label {
    display: block;
    margin-bottom: 0.4rem;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 700;
}
.appi-dialog__input { min-height: 44px; border-radius: 10px; }
.appi-dialog__feedback {
    min-height: 1.15rem;
    margin-top: 0.3rem;
    color: #b42332;
    font-size: 0.78rem;
}
.appi-dialog__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    padding: 0.9rem 1.15rem 1.1rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}
.appi-dialog__footer .btn { min-width: 104px; border-radius: 10px; font-weight: 600; }

@media (max-width: 480px) {
    .appi-dialog-backdrop { align-items: end; padding: 0.65rem; }
    .appi-dialog { width: 100%; border-radius: 18px 18px 14px 14px; }
    .appi-dialog__footer { display: grid; grid-template-columns: 1fr 1fr; }
    .appi-dialog__footer .btn:only-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
    .appi-dialog-backdrop,
    .appi-dialog { transition: none; }
}
