/*
 * FisioGestor - Folha de Estilos CSS Premium Customizada
 * Inspirado diretamente no layout limpo, moderno e responsivo do print de referência
 */

:root {
    --primary: #2f7d1f; /* Verde principal da marca */
    --primary-medium: #43a72f;
    --primary-light: #6fca52;
    --primary-soft: #f0faed;
    --primary-soft-text: #2a6f1b;
    
    --bg-main: #f8fafc; /* Fundo cinza/azul claro */
    --bg-card: #ffffff; /* Fundo do card */
    --border: #e2e8f0; /* Cinza de borda */
    --border-hover: #cbd5e1;
    
    --text-main: #1e293b; /* Slate 800 */
    --text-sub: #64748b; /* Slate 500 */
    --text-light: #94a3b8; /* Slate 400 */
    
    --danger: #ef4444; /* Vermelho */
    --danger-soft: #fef2f2;
    --danger-text: #991b1b;
    
    --warning: #f59e0b; /* Amarelo */
    --warning-soft: #fffbeb;
    --warning-text: #92400e;
    
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.03), 0 2px 4px -2px rgb(0 0 0 / 0.03);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.04), 0 4px 6px -4px rgb(0 0 0 / 0.04);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.05), 0 8px 10px -6px rgb(0 0 0 / 0.05);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Resets & Configurações de Base
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}

a {
    color: var(--primary-medium);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--primary);
}

img {
    max-width: 100%;
    height: auto;
}

input, button, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ==========================================================================
   Layout Principal (Desktop Sidebar vs Mobile Bottom Nav)
   ========================================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.main-content {
    flex: 1;
    padding: 24px;
    padding-bottom: 90px; /* Margem para menu mobile na base */
    transition: var(--transition);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Sidebar (Desktop) */
.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 36px;
}

.sidebar-logo .logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-soft);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: 700;
    font-size: 20px;
}

.sidebar-logo .logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.sidebar-logo .logo-text span {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-sub);
    display: block;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-sub);
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-link:hover, .sidebar-link.active {
    background: var(--primary-soft);
    color: var(--primary-soft-text);
}

.sidebar-link svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: auto;
}

.user-profile-summary {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
}

.user-profile-info h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.user-profile-info p {
    font-size: 12px;
    color: var(--text-sub);
}

/* Bottom Navigation (Mobile) */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 68px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom); /* Suporte para Notch do iPhone */
}

.bottom-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-sub);
    font-size: 11px;
    font-weight: 500;
    flex: 1;
    padding: 8px 0;
}

.bottom-link.active {
    color: var(--primary);
}

.bottom-link svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* Botão Flutuante Centralizado Mobile */
.bottom-link-float {
    position: relative;
    top: -16px;
    background: var(--primary);
    color: white;
    width: 52px;
    height: 52px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 16px rgba(15, 118, 110, 0.3);
    transition: var(--transition);
}

.bottom-link-float:hover {
    background: var(--primary-medium);
    transform: scale(1.05);
}

.bottom-link-float svg {
    width: 26px;
    height: 26px;
    stroke: white;
    stroke-width: 2.5;
}

/* ==========================================================================
   Header Unificado
   ========================================================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
}

.page-title p {
    font-size: 14px;
    color: var(--text-sub);
}

/* Header Prontuário do Paciente (Idêntico ao print) */
.patient-profile-header {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px 24px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 20px;
    box-shadow: var(--shadow);
}

.patient-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-btn {
    background: var(--bg-main);
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    transition: var(--transition);
    cursor: pointer;
}

.back-btn:hover {
    background: var(--border);
}

.patient-avatar-circle {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--primary-soft);
}

.patient-avatar-placeholder {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 20px;
}

.patient-header-details h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
}

.patient-header-details p {
    font-size: 13px;
    color: var(--text-sub);
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 2px;
}

.patient-header-details p span.dot {
    width: 4px;
    height: 4px;
    background: var(--text-light);
    border-radius: var(--radius-full);
    display: inline-block;
}

/* ==========================================================================
   Grid de Conteúdo (Duas Colunas / Responsivo)
   ========================================================================== */
.two-columns-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 24px;
    align-items: start;
}

/* ==========================================================================
   Cards e Elementos do Prontuário (Esquerda)
   ========================================================================== */
.card-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-section-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-section-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-section-header h3 svg {
    color: var(--primary-medium);
    width: 22px;
    height: 22px;
}

.card-section-body {
    padding: 24px;
}

/* Subseções da Avaliação */
.evaluation-subsection {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.evaluation-subsection:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.subsection-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 16px;
}

/* inputs e Textareas */
.form-input-group {
    margin-bottom: 16px;
}

.form-input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-sub);
    margin-bottom: 6px;
}

.form-control-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

.form-control-input:focus {
    border-color: var(--primary-medium);
    background: white;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

textarea.form-control-input {
    resize: vertical;
    min-height: 80px;
}

/* Layout em Grid para Subseção 2 (História Resumida) */
.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* ==========================================================================
   Componentes de Controle Exclusivos do Print
   ========================================================================== */

/* 1. Slider de Dor EVA */
.slider-eva-container {
    padding: 12px 0;
}

.slider-eva-track {
    position: relative;
    display: flex;
    align-items: center;
}

.slider-eva-control {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: var(--radius-full);
    background: #e2e8f0;
    outline: none;
    margin: 16px 0;
}

/* Estilo do Knob do Slider */
.slider-eva-control::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-medium);
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(13, 148, 136, 0.3);
    transition: transform 0.1s;
    border: 2px solid white;
}

.slider-eva-control::-webkit-slider-thumb:active {
    transform: scale(1.15);
}

.slider-eva-control::-moz-range-thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-medium);
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(13, 148, 136, 0.3);
    border: 2px solid white;
}

.slider-eva-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-sub);
    font-weight: 500;
}

.slider-eva-value-box {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    color: var(--primary-soft-text);
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 20px;
    margin-left: 20px;
    border: 1px solid rgba(15, 118, 110, 0.15);
}

/* 2. Botão Tri-State (Melhorou, Igual, Piorou) */
.tri-state-container {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.tri-state-btn {
    flex: 1;
    background: white;
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 14px;
    color: var(--text-main);
    cursor: pointer;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.tri-state-btn:hover {
    border-color: var(--primary-medium);
    background: var(--bg-main);
}

.tri-state-btn.active-improved {
    background: var(--primary-soft);
    border-color: #10b981;
    color: #047857;
    font-weight: 600;
}

.tri-state-btn.active-same {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #475569;
    font-weight: 600;
}

.tri-state-btn.active-worse {
    background: #fef2f2;
    border-color: #f87171;
    color: #b91c1c;
    font-weight: 600;
}

/* 3. Checkboxes e Radios Customizados (No Estilo do Print) */
.custom-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.custom-checkbox-label, .custom-radio-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-main);
    cursor: pointer;
    font-weight: 500;
}

.custom-checkbox-label input, .custom-radio-label input {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-medium);
    border-radius: 4px;
    cursor: pointer;
}

/* 4. Caixa de Funcionalidade Visual (Sentar, Andar, Dormir) */
.func-visual-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 12px;
}

.func-visual-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    color: var(--text-sub);
}

.func-visual-box svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
}

.func-visual-box span {
    font-size: 11px;
    font-weight: 500;
}

.func-visual-box:hover {
    border-color: var(--primary-medium);
    background: var(--bg-main);
}

.func-visual-box.active {
    border-color: var(--primary-medium);
    background: var(--primary-soft);
    color: var(--primary-soft-text);
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.1);
}

.func-visual-box.active svg {
    stroke: var(--primary-soft-text);
}

/* 5. Pills de Conduta/Plano Terapêutico (Multiselect) */
.pills-select-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.pill-select-item {
    background: white;
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-sub);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pill-select-item:hover {
    border-color: var(--primary-medium);
    color: var(--primary-medium);
}

.pill-select-item.active {
    background: var(--primary-soft);
    border-color: var(--primary-medium);
    color: var(--primary-soft-text);
}

.pill-select-item.active svg {
    stroke: var(--primary-soft-text);
}

/* Botões do Prontuário */
.btn-primary-custom {
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary-custom:hover {
    background: var(--primary-medium);
}

.btn-secondary-custom {
    background: white;
    color: var(--primary-medium);
    border: 1px solid var(--primary-medium);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary-custom:hover {
    background: var(--primary-soft);
}

/* ==========================================================================
   Coluna Direita (Evolução & Resumo)
   ========================================================================== */
.evolution-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.evolution-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.evolution-header h3 svg {
    color: var(--primary-medium);
}

/* Accordion de Evoluções (Idêntico ao print) */
.evolution-accordion-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.evolution-accordion-item {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.evolution-accordion-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    background: white;
}

.evolution-accordion-header:hover {
    background: var(--bg-main);
}

.evolution-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.evolution-header-title svg.calendar-icon {
    color: var(--primary-medium);
}

.evolution-accordion-header .chevron-icon {
    transition: transform 0.2s ease;
    color: var(--text-sub);
}

.evolution-accordion-item.open .evolution-accordion-header .chevron-icon {
    transform: rotate(180deg);
}

.evolution-accordion-body {
    padding: 20px;
    border-top: 1px solid var(--border);
    background: white;
    display: none;
}

.evolution-accordion-item.open .evolution-accordion-body {
    display: block;
}

.evolution-detail-row {
    margin-bottom: 16px;
}

.evolution-detail-row:last-child {
    margin-bottom: 0;
}

.evolution-detail-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-sub);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.evolution-detail-content {
    font-size: 14px;
    color: var(--text-main);
}

/* Card Resumo do Tratamento */
.treatment-summary-card {
    background: var(--primary-soft);
    border: 1px solid rgba(15, 118, 110, 0.12);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow);
}

.treatment-summary-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.treatment-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed rgba(15, 118, 110, 0.15);
    font-size: 14px;
}

.treatment-summary-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.treatment-summary-item span.label {
    color: var(--text-sub);
    font-weight: 500;
}

.treatment-summary-item span.value {
    color: var(--text-main);
    font-weight: 600;
}

.treatment-summary-item span.badge {
    background: var(--bg-card);
    color: var(--primary-soft-text);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 12px;
    border: 1px solid rgba(15, 118, 110, 0.15);
}

/* ==========================================================================
   Galeria de Fotos e Anexos (Estilo Prontuário)
   ========================================================================== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.gallery-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    aspect-ratio: 1;
    background: var(--bg-main);
    cursor: pointer;
    transition: var(--transition);
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item .file-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    text-align: center;
}

.gallery-item .file-placeholder svg {
    width: 24px;
    height: 24px;
    color: var(--text-sub);
}

.gallery-item .file-placeholder span {
    font-size: 10px;
    color: var(--text-sub);
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-item .file-meta {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 9px;
    padding: 3px 6px;
    text-align: center;
}

/* ==========================================================================
   Páginas e Interfaces Gerais (Login, Listagem, Tabelas)
   ========================================================================== */

/* Tela de Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-main);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    border: 1px solid var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h2 {
    color: var(--primary);
    font-weight: 700;
    font-size: 26px;
    margin-top: 10px;
}

/* Cards do Dashboard */
.dashboard-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.dashboard-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card-details h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card-details p {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 4px;
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Atalhos Rápidos Dashboard */
.dashboard-shortcuts {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 28px;
}

.dashboard-shortcuts h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.shortcuts-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Tabelas Listagem Genericas */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

.table-header-filters {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.search-filter-input {
    display: flex;
    align-items: center;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    max-width: 320px;
    width: 100%;
}

.search-filter-input input {
    background: transparent;
    border: none;
    outline: none;
    font-size: 14px;
    width: 100%;
    margin-left: 8px;
    color: var(--text-main);
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.table-custom {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.table-custom th {
    background: var(--bg-main);
    padding: 14px 20px;
    font-weight: 600;
    color: var(--text-sub);
    border-bottom: 1px solid var(--border);
}

.table-custom td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    vertical-align: middle;
}

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

.table-custom tr:hover td {
    background: #f8fafc;
}

/* Badges e Status */
.badge-status {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

.badge-status-active {
    background: var(--primary-soft);
    color: var(--primary-soft-text);
}

.badge-status-inactive {
    background: #f1f5f9;
    color: #475569;
}

.badge-status-scheduled {
    background: #eff6ff;
    color: #1d4ed8;
}

.badge-status-confirmed {
    background: #f5f3ff;
    color: #6d28d9;
}

.badge-status-completed {
    background: #ecfdf5;
    color: #047857;
}

.badge-status-missed {
    background: #fffbeb;
    color: #b45309;
}

.badge-status-cancelled {
    background: #fef2f2;
    color: #b91c1c;
}

/* Modais Pop-up Elegantes */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    max-width: 540px;
    width: 100%;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.2s ease;
}

.modal-overlay.open .modal-card {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-sub);
    line-height: 1;
}

.modal-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-main);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Alertas de Flash */
.flash-message {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
}

.flash-success {
    background-color: #ecfdf5;
    color: #047857;
    border: 1px solid #d1fae5;
}

.flash-error {
    background-color: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fee2e2;
}

/* Câmera Captura Layout */
.camera-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.video-preview {
    width: 100%;
    max-width: 320px;
    height: 240px;
    border-radius: var(--radius-md);
    object-fit: cover;
    background: #000;
    border: 1px solid var(--border);
    transform: scaleX(-1); /* Espelhar câmera frontal */
}

.canvas-capture {
    display: none;
}

.image-captured-preview {
    width: 100%;
    max-width: 320px;
    height: 240px;
    border-radius: var(--radius-md);
    object-fit: cover;
    border: 1px solid var(--primary-medium);
}

/* ==========================================================================
   Media Queries & Responsividade (Super Importante para PWA)
   ========================================================================== */

/* Desktop Médio e Grande */
@media (min-width: 1024px) {
    .main-content {
        padding-bottom: 24px; /* Não precisa de espaço extra pro menu inferior */
    }
}

/* Tablet e Telas Menores */
@media (max-width: 1023px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        display: none; /* Esconder a sidebar no mobile/tablet */
    }
    
    .bottom-nav {
        display: flex; /* Mostrar o menu inferior no mobile/tablet */
    }
    
    .two-columns-grid {
        grid-template-columns: 1fr; /* Forçar uma coluna */
    }

    .main-content {
        padding: 16px;
        padding-bottom: 90px;
    }
    
    .patient-profile-header {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }

    .patient-header-left {
        justify-content: flex-start;
    }

    .patient-profile-header .btn-primary-custom {
        justify-content: center;
        width: 100%;
    }
}

/* Celular Mobile Pequeno */
@media (max-width: 576px) {
    .form-grid-2, .form-grid-3 {
        grid-template-columns: 1fr; /* Inputs um abaixo do outro */
    }
    
    .func-visual-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 itens por linha */
    }
    
    .table-header-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-filter-input {
        max-width: 100%;
    }
    
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .page-header .btn-primary-custom {
        width: 100%;
        justify-content: center;
    }
}

/* Animações */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Premium mobile polish - Global Fisio
   ========================================================================== */
:root {
    --primary: #2f7d1f;
    --primary-medium: #43a72f;
    --primary-light: #6fca52;
    --primary-soft: #f0faed;
    --primary-soft-text: #2a6f1b;
    --premium: #b58a2a;
    --bg-main: #f6f8fb;
    --bg-card: #ffffff;
    --border: #dfe7ef;
    --text-main: #172033;
    --text-sub: #667085;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 12px 28px rgba(16, 24, 40, 0.07);
    --shadow-lg: 0 24px 52px rgba(16, 24, 40, 0.12);
    --radius-md: 8px;
    --radius-lg: 10px;
}

html {
    background: var(--bg-main);
    scroll-behavior: smooth;
}

body {
    background: var(--bg-main);
    color: var(--text-main);
    text-rendering: optimizeLegibility;
}

button,
a,
input,
select,
textarea {
    touch-action: manipulation;
}

input,
select,
textarea {
    font-size: 16px;
}

.main-content {
    max-width: none;
    padding: 28px clamp(20px, 3vw, 40px);
}

.sidebar {
    width: 272px;
    padding: 20px;
    background: #0f172a;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 12px 0 34px rgba(15, 23, 42, 0.16);
}

.sidebar-logo {
    margin-bottom: 28px;
}

.sidebar-logo .logo-text {
    color: #ffffff;
}

.sidebar-logo .logo-text span,
.user-profile-info p {
    color: rgba(255, 255, 255, 0.54);
}

.sidebar-link {
    min-height: 44px;
    color: rgba(226, 232, 240, 0.72);
    border-radius: var(--radius-md);
}

.sidebar-link:hover,
.sidebar-link.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 14px 30px rgba(15, 118, 110, 0.24);
}

.sidebar-footer {
    border-top-color: rgba(255, 255, 255, 0.08);
}

.user-profile-info h4 {
    color: #ffffff;
}

.dashboard-stat-card,
.dashboard-shortcuts,
.card-section,
.table-container,
.patient-profile-header,
.modal-card,
.login-card,
.login-card-custom {
    border-color: var(--border);
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow);
}

.dashboard-stat-card:hover,
.card-section:hover,
.table-container:hover {
    box-shadow: var(--shadow-md);
}

.page-header {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.page-title h2 {
    color: #101828;
}

.btn-primary-custom,
.btn-secondary-custom,
.back-btn,
.form-control-input,
.search-filter-input,
.tri-state-btn,
.pill-select-item {
    border-radius: var(--radius-md);
}

.btn-primary-custom {
    min-height: 44px;
    background: var(--primary);
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.18);
}

.btn-primary-custom:hover {
    background: var(--primary-medium);
}

.form-control-input {
    min-height: 44px;
    background: #fbfdff;
}

.form-control-input:focus {
    box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.14);
}

.table-responsive {
    -webkit-overflow-scrolling: touch;
}

.bottom-nav {
    height: calc(72px + env(safe-area-inset-bottom));
    align-items: flex-start;
    padding-top: 8px;
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(226, 232, 240, 0.94);
    box-shadow: 0 -16px 42px rgba(15, 23, 42, 0.1);
    backdrop-filter: blur(18px);
}

.bottom-link {
    min-height: 56px;
    justify-content: center;
    color: #667085;
    font-weight: 700;
}

.bottom-link.active {
    color: var(--primary);
}

.bottom-link-float {
    top: -18px;
    background: var(--primary);
    box-shadow: 0 14px 28px rgba(15, 118, 110, 0.28);
}

@media (min-width: 768px) {
    input,
    select,
    textarea {
        font-size: 15px;
    }
}

@media (max-width: 1023px) {
    .main-content {
        padding: 16px;
        padding-bottom: calc(96px + env(safe-area-inset-bottom));
    }

    .dashboard-stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }

    .dashboard-stat-card {
        padding: 16px;
        align-items: flex-start;
        gap: 10px;
    }

    .stat-card-details p {
        font-size: 24px;
    }

    .stat-card-icon {
        width: 42px;
        height: 42px;
    }

    .shortcuts-btn-group .btn-primary-custom,
    .shortcuts-btn-group .btn-secondary-custom {
        flex: 1 1 160px;
        justify-content: center;
    }

    .modal-card {
        width: min(100%, 720px);
        max-height: calc(100vh - 24px - env(safe-area-inset-bottom));
    }
}

@media (min-width: 721px) and (max-width: 1180px) {
    .main-content {
        padding: 20px;
        padding-bottom: calc(92px + env(safe-area-inset-bottom));
    }

    .two-columns-grid {
        grid-template-columns: 1fr !important;
    }

    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }

    .btn-primary-custom,
    .btn-secondary-custom,
    .form-control-input {
        min-height: 48px;
        font-size: 15px;
    }

    .table-container,
    .card-section {
        border-radius: var(--radius-md);
    }

    .table-responsive {
        overflow-x: auto;
        overscroll-behavior-x: contain;
    }

    .camera-preview-box,
    .patient-photo-capture,
    video,
    canvas {
        max-width: 100%;
    }
}

@media (max-width: 720px) {
    .page-header {
        margin-bottom: 18px;
    }

    .page-title h2 {
        font-size: 22px;
        line-height: 1.2;
    }

    .dashboard-stats-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-shortcuts,
    .card-section,
    .table-container {
        margin-bottom: 18px;
    }

    .card-section-header,
    .card-section-body,
    .table-header-filters {
        padding: 16px;
    }

    .table-custom {
        min-width: 640px;
    }

    .patient-header-left {
        min-width: 0;
    }

    .patient-avatar-circle,
    .patient-avatar-placeholder {
        width: 48px;
        height: 48px;
    }

    .bottom-link span {
        max-width: 62px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 420px) {
    .main-content {
        padding-left: 12px;
        padding-right: 12px;
    }

    .dashboard-stat-card {
        padding: 14px;
    }

    .func-visual-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
