/* css/style.css - VERSÃO: AJUSTE FINO (PACIENTES SEM SCROLL) */

:root {
    --blue-dark: #003366;
    --blue-light: #0056b3;
    --gradiente-azul: linear-gradient(135deg, #0056b3 0%, #002a52 100%);
    --red-light: #cc0000;
    --orange-icon: #ff9f43;
    --bg-body: #F4F7FA;
    --surface: #FFFFFF;
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --border: #e1e4e8;
    --radius: 8px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --sidebar-bg: #1e4c82;
    --sidebar-text: #f1f2f6;
    --sidebar-width: 280px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Global */
html,
body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: var(--bg-body);
    color: var(--text-main);
}

.hidden-screen,
.hidden-section {
    display: none !important;
}

.active-screen {
    display: flex !important;
}

.active-section {
    display: block !important;
    animation: fadeIn 0.3s ease-in-out;
}

#main-app {
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* --- TELA DE LOGIN --- */
#login-screen {
    position: fixed;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #003366 0%, #0056b3 50%, #001a33 100%);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 5000;
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 5px 30px 20px 30px;
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 100%;
}

.login-logo {
    max-height: 200px;
    width: auto;
    margin-bottom: 0px;
    object-fit: contain;
}

.login-header h2 {
    color: var(--blue-dark);
    margin: 0;
    font-size: 1.5rem;
}

.login-header p {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.input-group {
    position: relative;
    margin-bottom: 10px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
}

.input-group input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid #ddd;
    border-radius: 30px;
    background: #f9f9f9;
    transition: 0.3s;
}

.input-group input:focus {
    border-color: var(--blue-light);
    background: white;
    outline: none;
}

.btn-login-action {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 30px;
    background: linear-gradient(90deg, #0056b3, #003366);
    color: white;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
    transition: 0.3s;
    box-shadow: 0 4px 10px rgba(0, 86, 179, 0.3);
}

.btn-login-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 86, 179, 0.4);
}

.login-footer-links {
    margin-top: 20px;
    font-size: 0.85em;
}

.login-footer-links a {
    color: var(--blue-light);
    text-decoration: none;
    transition: 0.2s;
}

.login-footer-links a:hover {
    text-decoration: underline;
}

.divider {
    margin: 0 10px;
    color: #ccc;
}

.btn-voltar-login {
    background: none;
    border: none;
    color: #777;
    cursor: pointer;
    margin-top: 15px;
    text-decoration: underline;
    font-size: 0.9em;
}

.copyright {
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    margin-top: 20px;
    font-size: 0.8em;
}

/* Sidebar */
#sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.header-sidebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 80px;
}

.company-logo-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.company-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
}

.toggle-btn {
    display: block;
    cursor: pointer;
    color: white;
    font-size: 1.2rem;
}

.menu-items {
    list-style: none;
    flex-grow: 1;
    overflow-y: auto;
    padding-top: 10px;
    scrollbar-width: none;
}

.menu-items li {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
    border-left: 4px solid transparent;
}

.menu-items li:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.menu-items li.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border-left-color: var(--orange-icon);
}

.menu-items li i {
    color: var(--orange-icon);
    font-size: 1.1rem;
    width: 25px;
    text-align: center;
}

.footer-sidebar {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
    margin-bottom: 10px;
    color: white;
}

.logout-btn {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: none;
    color: #ff6b6b;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    padding: 8px;
    border-radius: 5px;
    justify-content: center;
}

#sidebar.collapsed {
    width: 70px;
    min-width: 70px;
}

/* FIX: Forçar altura do calendário para evitar bug de "um horário" */
#calendar {
    height: 800px !important;
    min-height: 800px !important;
    width: 100%;
    display: block;
    position: relative;
    /* Ensure context */
}

.tui-full-calendar-layout {
    height: 100% !important;
    min-height: 100% !important;
}

/* FIX: Forçar painel de eventos a ocupar espaço mesmo se JS falhar no cálculo inicial */
.tui-full-calendar-time-layout-area,
.tui-full-calendar-time-layout,
.tui-full-calendar-time-grid {
    height: 100% !important;
    min-height: 100% !important;
    flex-grow: 1;
}


#agenda-view-lista {
    min-height: 600px;
    background: white;
}

#sidebar.collapsed .company-name,
#sidebar.collapsed .user-info span,
#sidebar.collapsed .user-info div,
#sidebar.collapsed .menu-items span,
#sidebar.collapsed .logout-btn span {
    display: none !important;
}

#sidebar.collapsed .header-sidebar {
    justify-content: center;
    flex-direction: column;
    gap: 10px;
}

#sidebar.collapsed .menu-items li {
    justify-content: center;
}

#sidebar.collapsed .toggle-btn {
    margin: 0;
}

/* Content */
header {
    display: none;
    width: 100%;
    padding: 15px;
    background: white;
    border-bottom: 1px solid var(--border);
    justify-content: space-between;
    align-items: center;
    height: 60px;
    flex-shrink: 0;
}

.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.mobile-header i {
    font-size: 1.5rem;
    color: var(--blue-dark);
    cursor: pointer;
}

#content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
    background-color: var(--bg-body);
    width: 100%;
    max-width: 100%;
}

.views-container {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.view {
    display: none;
    flex-direction: column;
    min-height: 100%;
    height: auto;
    width: 100%;
    animation: fadeIn 0.3s;
    max-width: 100%;
}

.active-view {
    display: flex !important;
}

/* Agenda Flex */
#view-agenda {
    overflow: hidden;
    padding: 0 !important;
    height: 100% !important;
    display: none;
    flex-direction: column;
}

#view-agenda.active-view {
    display: flex !important;
}

.agenda-toolbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    background: white;
    padding: 15px;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f4f7fa;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.agenda-group-left,
.agenda-group-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.agenda-group-right {
    justify-content: flex-end;
    flex-grow: 1;
}

.filter-box {
    display: flex;
    flex-direction: column;
}

.label-text {
    font-size: 0.8em;
    font-weight: bold;
    color: #666;
    margin-bottom: 3px;
    display: block;
}

.input-standard {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    min-width: 140px;
}

.checkbox-box {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #f8f9fa;
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid #eee;
    cursor: pointer;
}

.search-box-agenda {
    position: relative;
    flex-grow: 1;
    max-width: 250px;
    min-width: 150px;
}

.search-box-agenda i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.search-box-agenda input {
    width: 100%;
    padding: 10px 10px 10px 35px;
    border-radius: 20px;
    border: 1px solid #ccc;
    font-size: 0.9em;
}

.actions-box {
    display: flex;
    gap: 10px;
}

.btn-whatsapp {
    background-color: white;
    border: 1px solid #25D366;
    color: #25D366;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-whatsapp:hover {
    background-color: #eafff0;
}

.left-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-arrows {
    display: flex;
    gap: 5px;
}

.btn-icon-nav {
    background: white;
    border: 1px solid #ccc;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.date-range-display {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--blue-dark);
}

/* 
#calendar {
    flex-grow: 1;
    width: 100% !important;
    height: calc(100% - 150px) !important;
    background: white;
    position: relative;
    border-radius: 0 0 8px 8px;
    display: block;
    overflow: hidden;
} 
*/

/* UI Elements */
.header-view {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    min-height: 50px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    flex-shrink: 0;
}

#view-faturamento .header-view {
    height: auto !important;
}

.view-title {
    color: var(--blue-dark);
    font-size: 1.5rem;
    margin-right: 15px;
}

.btn-primary {
    background: var(--gradiente-azul);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-main);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    font-size: 1.1rem;
    color: #777;
    transition: 0.2s;
}

/* --- TABELAS UNIVERSAIS --- */
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid #e1e4e8;
    overflow-x: auto;
    margin-top: 15px;
    width: 100%;
    max-width: 100%;
}

.table-responsive {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid #e1e4e8;
    margin-top: 15px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    display: block;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table thead th {
    background: linear-gradient(135deg, #003366, #0056b3) !important;
    color: white !important;
    padding: 12px 15px !important;
    font-weight: 600 !important;
    border: 1px solid #002a52 !important;
    text-align: left;
    text-transform: uppercase;
    font-size: 0.85rem;
    white-space: nowrap;
}

.data-table tbody tr {
    color: #444;
}

.data-table tbody td {
    padding: 8px 12px !important;
    color: inherit;
    border: 1px solid #e0e0e0 !important;
    vertical-align: middle;
}

.data-table tbody tr:nth-child(even) {
    background-color: #f9fafc !important;
}

.data-table tbody tr:hover {
    background-color: #e3f2fd !important;
}

/* --- DISTRIBUIÇÃO PADRÃO (Genérica) --- */
.data-table th:first-child,
.data-table td:first-child {
    min-width: 180px;
    width: auto;
}

.data-table th:not(:first-child):not(:last-child),
.data-table td:not(:first-child):not(:last-child) {
    min-width: 100px;
    width: 1%;
    white-space: nowrap;
}

.data-table th:last-child,
.data-table td:last-child {
    width: 1%;
    min-width: 110px;
    white-space: nowrap;
    text-align: center;
    background-color: inherit;
    display: table-cell !important;
}

.actions-cell {
    white-space: nowrap;
    text-align: center;
}

.actions-cell button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 2px;
}


/* ========================================================================= */
/* --- AJUSTE EXCLUSIVO: PACIENTES --- */
/* ========================================================================= */

/* 1. Nome do Paciente (Coluna 1): Mais moderado (220px) para não gerar scroll */
#view-pacientes .data-table th:first-child,
#view-pacientes .data-table td:first-child {
    min-width: 220px !important;
    max-width: 300px;
    /* Impede de esticar infinitamente */
    width: auto !important;
}

/* 2. Coluna Ações (Última): SUPER COMPACTA */
#view-pacientes .data-table th:last-child,
#view-pacientes .data-table td:last-child {
    min-width: 80px !important;
    /* Espaço mínimo absoluto para 3 ícones */
    width: 1% !important;
    text-align: center !important;
    padding-left: 2px !important;
    padding-right: 2px !important;
}


/* ========================================================================= */
/* --- AJUSTE EXCLUSIVO: AUDITORIA/LOGS --- */
/* ========================================================================= */
#config-section-logs .data-table th:last-child,
#config-section-logs .data-table td:last-child {
    width: auto !important;
    min-width: 250px !important;
    white-space: normal !important;
    word-break: break-word !important;
    text-align: left !important;
}

#config-section-logs .data-table th:first-child,
#config-section-logs .data-table td:first-child {
    min-width: 140px !important;
    width: 1% !important;
    white-space: nowrap !important;
}


/* ABAS */
.tabs-header {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid #ddd;
    position: relative;
    z-index: 5;
    padding-bottom: 0;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.tab-btn {
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: #777;
    border-bottom: 3px solid transparent;
    position: relative;
    z-index: 10;
    margin-bottom: -1px;
}

.tab-btn.active {
    color: var(--blue-light);
    border-bottom-color: var(--blue-light);
    background: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Filtros Bar */
.filters-bar {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 15px;
    width: 100%;
    max-width: 100%;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ddd;
    flex-shrink: 0;
}

.filters-bar select,
.filters-bar input {
    flex-grow: 1;
    min-width: 150px;
}

/* Config Cards */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    padding: 10px;
}

.config-card {
    background: white;
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    padding: 25px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.config-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-color: var(--blue-light);
}

.config-card i {
    font-size: 2.5rem !important;
    margin-bottom: 15px;
    color: var(--orange-icon);
}

.config-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--blue-dark);
    margin: 0 0 5px 0;
}

.config-card small {
    font-size: 0.85rem;
    color: #888;
}

.config-form-container {
    padding: 20px;
    background: white;
    border-radius: 8px;
    border: 1px solid #eee;
}

/* Forms e Gráficos */
.form-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
}

input,
select,
textarea {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    outline: none;
    font-size: 1rem;
}

.finance-cards-grid,
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.finance-card,
.chart-card {
    background: white;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.autocomplete-results {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    z-index: 2000;
    list-style: none;
    top: 100%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.autocomplete-results li {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.chart-container-box {
    position: relative;
    height: 300px !important;
    width: 100%;
    margin-bottom: 20px;
}

canvas {
    max-height: 100% !important;
    width: 100% !important;
}

/* Botões */
#view-dashboard .btn-secondary {
    background: white !important;
    border: 1px solid #e1e4e8 !important;
    color: var(--blue-dark) !important;
    padding: 15px 25px !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05) !important;
}

#btn-novo-agendamento {
    background: var(--gradiente-azul) !important;
    color: white !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

#btn-fechar-caixa {
    background-color: #c0392b !important;
    color: white !important;
    font-weight: 800 !important;
    padding: 12px 25px !important;
}

#btn-acao-faturamento {
    font-size: 1.1rem !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    padding: 15px 30px !important;
}

/* Modais */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal-overlay.active {
    display: flex !important;
    animation: fadeIn 0.2s;
    z-index: 9999 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.modal-box {
    background: white;
    width: 95%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9f9f9;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f9f9f9;
}

/* Modal Split */
.modal-box-large {
    max-width: 900px !important;
    width: 95%;
}

.split-modal-body {
    display: flex;
    gap: 0;
    padding: 0 !important;
    height: 600px;
    overflow: hidden;
}

.modal-left {
    flex: 1;
    padding: 25px;
    background-color: #ffffff;
    overflow-y: auto;
}

.vertical-line {
    width: 1px;
    background-color: #e0e0e0;
    margin: 20px 0;
}

.modal-right {
    flex: 1;
    padding: 25px;
    background-color: #f8faff;
    overflow-y: auto;
    border-left: 1px solid #eee;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--blue-dark);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 2px solid #eee;
}

.alert-box {
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 0.9em;
    display: none;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.magic-price-box {
    background: #fff;
    border: 2px solid #3498db;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 4px 6px rgba(52, 152, 219, 0.1);
}

.price-display {
    font-size: 1.8rem;
    font-weight: 800;
    color: #27ae60;
    text-align: center;
    margin: 10px 0;
}

/* CARDs RESUMO RELATÓRIO */
.summary-card {
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    flex: 1;
    min-width: 150px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    color: #2c3e50;
}

.card-total {
    background-color: #e3f2fd;
    border: 1px solid #bbdefb;
}

.card-pago {
    background-color: #ffebee;
    border: 2px solid #c0392b;
    color: #c0392b;
}

.card-pagar {
    background-color: #e8f5e9;
    border: 2px solid #2ecc71;
    color: #2ecc71;
    font-weight: bold;
}

/* PRINT */
@media print {
    body>* {
        display: none !important;
    }

    #main-app {
        display: block !important;
    }

    #content,
    .views-container,
    #view-relatorios {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        overflow: visible !important;
    }

    #sidebar,
    header,
    .header-view,
    .tabs-header,
    .card,
    .no-print,
    #btn-imprimir-recibo,
    #btn-gerar-extrato {
        display: none !important;
    }

    #relatorio-resultado {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 20px;
        background: white;
        z-index: 9999;
    }

    #relatorio-resultado * {
        visibility: visible !important;
        display: block;
    }

    #relatorio-resultado div[style*="display: grid"] {
        display: grid !important;
    }

    #relatorio-resultado div[style*="display: flex"] {
        display: flex !important;
    }

    #relatorio-resultado table {
        display: table !important;
        width: 100% !important;
    }

    #relatorio-resultado tbody {
        display: table-row-group !important;
    }

    #relatorio-resultado tr {
        display: table-row !important;
    }

    #relatorio-resultado td,
    #relatorio-resultado th {
        display: table-cell !important;
    }
}

@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100%;
        width: 280px;
        z-index: 4000;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.2);
        transition: 0.3s;
    }

    #sidebar.active {
        left: 0;
    }

    header {
        display: flex;
    }

    .views-container {
        padding: 10px;
        display: block;
        overflow-y: auto;
        overflow-x: hidden;
        height: calc(100vh - 60px);
    }

    #view-agenda {
        display: none;
        flex-direction: column;
        height: auto !important;
        overflow-y: visible !important;
        padding-bottom: 50px !important;
    }

    #view-agenda.active-view {
        display: flex !important;
    }

    .agenda-toolbar-container {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        height: auto;
    }

    .agenda-group-left,
    .agenda-group-right {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .search-box-agenda {
        max-width: 100%;
    }

    .actions-box {
        justify-content: space-between;
    }

    .filter-box {
        width: 100%;
    }

    .desktop-text {
        display: none;
    }

    .filters-bar {
        flex-direction: column;
        height: auto;
    }

    #calendar {
        height: 800px !important;
        flex-grow: 0;
        overflow-x: auto !important;
        min-height: 800px;
        min-width: 100%;
        display: block;
    }

    .calendar-controls {
        flex-wrap: wrap !important;
        gap: 5px !important;
        height: auto !important;
    }

    .left-controls {
        display: flex !important;
        align-items: center !important;
        width: 100% !important;
        justify-content: space-between !important;
        margin-bottom: 10px !important;
    }

    .date-range-display {
        white-space: nowrap !important;
        font-size: 1rem !important;
        font-weight: 800 !important;
        margin-left: 0 !important;
    }

    .right-controls,
    .right-controls select {
        width: 100% !important;
    }

    #view-financeiro .header-view {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 290px !important;
        width: 100% !important;
        margin-bottom: 20px !important;
        padding-bottom: 10px !important;
        position: relative !important;
        z-index: 100 !important;
        background-color: transparent !important;
    }

    #view-financeiro .view-title {
        width: 100%;
        text-align: center;
        margin-bottom: 15px !important;
        display: block;
    }

    #view-financeiro input[type="date"] {
        width: 100% !important;
        height: 50px !important;
        background: #fff;
        border: 1px solid #999;
        border-radius: 8px;
        display: block;
    }

    #view-faturamento .header-view {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        margin-bottom: 30px !important;
        position: relative !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    #view-faturamento .tabs-header {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        height: auto;
        margin-bottom: 20px;
    }

    #view-faturamento .tab-btn {
        flex: 1;
        text-align: center;
        padding: 12px 5px;
        background: #f9f9f9;
    }

    #view-faturamento .tab-btn.active {
        background: white;
    }

    #view-faturamento .filters-bar {
        width: 100%;
        max-width: 100%;
        margin-bottom: 30px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        flex-shrink: 0 !important;
    }

    #view-faturamento .filters-bar select,
    #view-faturamento .filters-bar input,
    #btn-buscar-guias {
        width: 100%;
        height: 50px;
        margin: 0;
    }

    #titulo-tabela-fat {
        margin-top: 20px !important;
        display: block;
        clear: both;
        padding-top: 10px;
    }

    #view-relatorios .header-view {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        margin-bottom: 10px !important;
        overflow: visible !important;
    }

    #view-relatorios .view-title {
        margin-bottom: 15px !important;
        text-align: left;
    }

    .tabs-header {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        width: 100% !important;
        gap: 10px !important;
        padding-bottom: 15px !important;
        padding-right: 60px !important;
        margin-bottom: 20px;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        padding: 10px 20px !important;
        height: 45px !important;
        border-radius: 25px !important;
    }

    /* MODIFICAÇÃO PARA MOBILE: TABELAS SEMPRE COM SCROLL (Roll Lateral) */
    .table-responsive {
        display: block !important;
        width: 90vw !important;
        max-width: 90vw !important;
        overflow-x: scroll !important;
        -webkit-overflow-scrolling: touch;
        margin: 0 auto 80px auto !important;
        border: 1px solid #ccc;
        background: white;
    }

    /* Largura Mínima para Mobile */
    .data-table {
        width: 100% !important;
        min-width: 800px !important;
    }

    .data-table th,
    .data-table td {
        white-space: normal !important;
        padding: 8px 5px !important;
        font-size: 0.85rem !important;
    }

    .modal-box-large {
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0;
        width: 100% !important;
    }

    .split-modal-body {
        flex-direction: column;
        height: auto;
        overflow-y: auto;
    }

    .modal-left,
    .modal-right {
        padding: 15px;
        border: none;
    }

    .vertical-line {
        display: none;
    }

    .modal-right {
        border-top: 5px solid #eee;
    }
}

/* ========================================================================= */
/* --- PRINT STYLES (IMPRESSÃO) --- */
/* ========================================================================= */
/* ========================================================================= */
/* --- PRINT STYLES (IMPRESSÃO) --- */
/* ========================================================================= */
@media print {
    @page {
        size: A4;
        margin: 1cm;
    }

    /* 1. HIDE UI CHROME */
    #sidebar,
    header,
    .mobile-header,
    .tabs-header,
    .filters-bar,
    .agenda-toolbar-container,
    .calendar-controls,
    .actions-box,
    .fab,
    #btn-voltar-topo,
    #login-screen,
    .modal-background,
    .login-wrapper,
    #view-faturamento .tabs-header,
    #view-faturamento .filters-bar,
    .view-title,
    button,
    .btn-primary,
    .btn-secondary,
    .btn-whatsapp,
    .no-print,
    .btn-icon,
    .check-guia,
    .actions-cell,
    th:first-child input {
        display: none !important;
    }

    /* 2. RESET LAYOUT & VISIBILITY */
    html,
    body,
    #main-app,
    #content,
    .views-container {
        height: auto !important;
        width: 100% !important;
        overflow: visible !important;
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
    }

    /* Hide Inactive Views / Show Active View */
    .view,
    .screen {
        display: none !important;
    }

    .view.active-view,
    .view.active-screen,
    .screen.active-screen {
        display: block !important;
        visibility: visible !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* 3. TABLE RESET (Critical for Alignment) */
    .table-container,
    .table-responsive {
        box-shadow: none !important;
        border: none !important;
        overflow: visible !important;
        display: block !important;
        height: auto !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .data-table {
        display: table !important;
        width: 100% !important;
        border-collapse: collapse !important;
        border: 1px solid #000 !important;
        min-width: 0 !important;
    }

    .data-table thead {
        display: table-header-group !important;
    }

    .data-table tbody {
        display: table-row-group !important;
    }

    .data-table tr {
        display: table-row !important;
        page-break-inside: avoid;
    }

    .data-table th,
    .data-table td {
        display: table-cell !important;
        /* allow browser to auto-size or use fixed layout if needed */
        width: auto;
        padding: 5px !important;
        font-size: 9pt !important;
        color: black !important;
        border: 1px solid #777 !important;
        text-align: left !important;
        white-space: normal !important;
        vertical-align: top;
    }

    .data-table th {
        background-color: #eee !important;
        text-align: center !important;
        font-weight: bold !important;
        /* Ensure headers are visible */
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Right Align Money/Last Column */
    .data-table th:last-child,
    .data-table td:last-child {
        text-align: right !important;
    }

    /* 4. SPECIFIC REPORT CARDS */
    .summary-card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        page-break-inside: avoid;
        color: black !important;
        margin-bottom: 10px;
    }

    .summary-card div {
        color: black !important;
    }

    #card-a-pagar {
        background: #eee !important;
        -webkit-print-color-adjust: exact;
    }

    /* 5. SIGNATURE AREA */
    .only-print {
        display: none !important;
        /* Hide globally by default */
        width: 100%;
        margin-top: 40px;
    }

    /* Show only in Relatorios */
    #view-relatorios.active-view .only-print,
    #view-relatorios .tab-content.active .only-print {
        display: block !important;
    }

    .assinatura-box {
        display: flex;
        justify-content: space-between;
        margin-top: 30px;
    }

    .assinatura-linha {
        border-top: 1px solid black;
        width: 40%;
        text-align: center;
        padding-top: 5px;
        font-size: 10pt;
    }

    /* 6. SCOPED TITLES */
    #rel-nome-prof,
    #titulo-tabela-fat {
        font-size: 16pt !important;
        color: black !important;
        margin-bottom: 10px;
        text-align: center;
        width: 100%;
        display: none !important;
    }

    #view-relatorios.active-view #rel-nome-prof {
        display: block !important;
    }

    #view-faturamento.active-view #titulo-tabela-fat {
        display: block !important;
    }

    /* 7. HACKS */
    #paciente-saldo-badge div {
        border: 1px solid #000 !important;
        color: black !important;
    }

    /* ========================================================================= */
    /* FIX: Force Block for Faturamento Card (Critical for Printing) */
    /* ========================================================================= */
    /* ========================================================================= */
    /* FIX: Force Block for Faturamento Card (Critical for Printing) */
    /* ========================================================================= */

    /* Security: Hide all views that are not active during print */
    .view:not(.active-view) {
        display: none !important;
    }

    /* Scoped Visibility - Only show what belongs to the ACTIVE view */
    #view-faturamento.active-view .card {
        display: block !important;
        visibility: visible !important;
        overflow: visible !important;
        height: auto !important;
    }

    #view-relatorios.active-view .tab-content.active,
    #view-relatorios.active-view #relatorio-resultado {
        display: block !important;
        visibility: visible !important;
        overflow: visible !important;
        height: auto !important;
    }

    /* Paranoid Safety: Hide Signature in Faturamento explicitly */
    #view-faturamento .only-print {
        display: none !important;
    }

    /* Show only in Relatorios (FLEX to fix stacking) */
    #view-relatorios.active-view .only-print,
    #view-relatorios .tab-content.active .only-print {
        display: flex !important;
        justify-content: space-around !important;
    }

    /* Hide Footer Actions in Faturamento Print */
    #view-faturamento .card>div:last-child {
        display: none !important;
    }

    /* Hide Top Header (Tabs/Filters) in Faturamento Print - Keeps only the Table Card */
    #view-faturamento .header-view {
        display: none !important;
    }

    /* Hide Checkbox Column (First Column) in Faturamento Print */
    #view-faturamento .data-table th:first-child,
    #view-faturamento .data-table td:first-child {
        display: none !important;
    }

    /* ========================================================================= */
    /* NUCLEAR OPTION: Destroy Signature Box in Faturamento */
    /* ========================================================================= */
    #view-faturamento .assinatura-box,
    #view-faturamento .assinatura-linha,
    #view-faturamento #relatorio-resultado {
        display: none !important;
    }

    /* REDUNDANT SAFETY: If Faturamento is active, kill Relatorios (Siblings) */
    #view-faturamento.active-view~#view-relatorios {
        display: none !important;
    }
}

/* --- AUTOCOMPLETE AGENDA --- */
.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    list-style: none;
    padding: 0;
    margin: 0;
    display: none;
    /* Hidden by default */
}

.autocomplete-results li {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 0.9em;
    color: #333;
    transition: background 0.2s;
}

.autocomplete-results li:last-child {
    border-bottom: none;
}

.autocomplete-results li:hover {
    background-color: #f0f7ff;
    color: var(--blue-dark);
}

.autocomplete-results li strong {
    color: var(--blue-dark);
}