/* Cores principais Blue Med */
:root {
    --bluemed-primary: #00a0e4;
    --bluemed-secondary: #263481;
    --bluemed-light: #E6F7FF;
    --bluemed-dark: #1A2847;
}

/* Prevenir scroll horizontal em todo o site */
* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden !important;
    max-width: 100vw !important;
}

/* Aplicar cores Blue Med em todos os temas */
[data-bs-theme="light"] {
    --bs-primary: var(--bluemed-primary);
    --bs-primary-rgb: 0, 160, 228;
    --bs-secondary: var(--bluemed-secondary);
    --bs-secondary-rgb: 38, 52, 129;
}

[data-bs-theme="dark"] {
    --bs-primary: var(--bluemed-primary);
    --bs-primary-rgb: 0, 160, 228;
    --bs-secondary: var(--bluemed-secondary);
    --bs-secondary-rgb: 38, 52, 129;
}

[data-bs-theme="blue-theme"] {
    --bs-primary: var(--bluemed-primary);
    --bs-primary-rgb: 0, 160, 228;
    --bs-secondary: var(--bluemed-secondary);
    --bs-secondary-rgb: 38, 52, 129;
}

[data-bs-theme="semi-dark"] {
    --bs-primary: var(--bluemed-primary);
    --bs-primary-rgb: 0, 160, 228;
    --bs-secondary: var(--bluemed-secondary);
    --bs-secondary-rgb: 38, 52, 129;
}

/* Botões primários */
.btn-primary,
.btn-grd-primary {
    background: var(--bluemed-primary) !important;
    background-color: var(--bluemed-primary) !important;
    background-image: none !important;
    border-color: var(--bluemed-primary) !important;
    color: #fff !important;
}

.btn-primary:hover,
.btn-grd-primary:hover,
.btn-primary:focus,
.btn-grd-primary:focus,
.btn-primary:active,
.btn-grd-primary:active {
    background: #0080b8 !important;
    background-color: #0080b8 !important;
    background-image: none !important;
    border-color: #0080b8 !important;
    color: #fff !important;
}

/* Bordas gradientes */
.border-gradient-1 {
    border-color: var(--bluemed-primary) !important;
}

/* Links */
a {
    color: var(--bluemed-primary);
}

a:hover {
    color: var(--bluemed-secondary);
}

/* Navegação e sidebar */
.sidebar-wrapper .metismenu a {
    color: inherit;
}

.sidebar-wrapper .metismenu a:hover,
.sidebar-wrapper .metismenu a.mm-active {
    color: var(--bluemed-primary);
}

/* Header */
.top-header {
    background: linear-gradient(135deg, var(--bluemed-secondary) 0%, var(--bluemed-primary) 100%);
}

/* Cards e alertas */
.alert-primary {
    background-color: var(--bluemed-light);
    border-color: var(--bluemed-primary);
    color: var(--bluemed-secondary);
}

/* Form inputs focus */
.form-control:focus {
    border-color: var(--bluemed-primary);
    box-shadow: 0 0 0 0.25rem rgba(0, 160, 228, 0.25);
}

/* Badge */
.badge.bg-primary {
    background-color: var(--bluemed-primary) !important;
}

/* Progress bar */
.progress-bar {
    background-color: var(--bluemed-primary);
}

/* Spinner */
.spinner-border.text-primary {
    color: var(--bluemed-primary) !important;
}

/* Login page branding */
.auth-cover-right {
    border-top-color: var(--bluemed-primary) !important;
}

/* Sobrescrever cores rosa/magenta do template original */
.text-primary {
    color: var(--bluemed-primary) !important;
}

.bg-primary {
    background-color: var(--bluemed-primary) !important;
}

.border-primary {
    border-color: var(--bluemed-primary) !important;
}

/* Checkbox e radio buttons */
.form-check-input:checked {
    background-color: var(--bluemed-primary);
    border-color: var(--bluemed-primary);
}

/* Switch */
.form-switch .form-check-input:checked {
    background-color: var(--bluemed-primary);
    border-color: var(--bluemed-primary);
}

/* ===== FOOTER FIXO NO FINAL ===== */
/* Garante que o HTML ocupe toda a altura */
html {
    height: 100%;
}

/* Body com flexbox para empurrar footer para baixo */
body {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    margin: 0;
    overflow-x: hidden !important;
    max-width: 100vw !important;
}

/* Wrapper principal ocupa todo espaço disponível */
.wrapper {
    display: flex;
    flex-direction: column;
    min-height: auto;
    flex: 1;
    overflow-x: hidden !important;
    max-width: 100% !important;
}

/* Main wrapper cresce para preencher espaço */
.main-wrapper {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    overflow-x: hidden !important;
    max-width: 100% !important;
}

/* Conteúdo principal cresce */
.main-content {
    flex: 1 0 auto;
    padding-bottom: 20px;
    overflow-x: hidden !important;
    max-width: 100% !important;
}

/* Footer sempre no final */
.page-footer {
    flex-shrink: 0;
    width: 100%;
    margin-top: auto;
}

/* Garantir que sidebar não interfira */
.sidebar-wrapper + .main-wrapper {
    min-height: auto;
}

/* ===== COMPATIBILIDADE COM TEMAS ESCUROS ===== */
/* Garantir que textos fiquem legíveis em todos os temas */
[data-bs-theme="dark"] .card,
[data-bs-theme="blue-theme"] .card,
[data-bs-theme="semi-dark"] .card {
    color: inherit;
}

[data-bs-theme="dark"] .text-muted,
[data-bs-theme="blue-theme"] .text-muted,
[data-bs-theme="semi-dark"] .text-muted {
    color: rgba(255, 255, 255, 0.6) !important;
}

[data-bs-theme="dark"] h1, 
[data-bs-theme="dark"] h2, 
[data-bs-theme="dark"] h3, 
[data-bs-theme="dark"] h4, 
[data-bs-theme="dark"] h5, 
[data-bs-theme="dark"] h6,
[data-bs-theme="blue-theme"] h1,
[data-bs-theme="blue-theme"] h2,
[data-bs-theme="blue-theme"] h3,
[data-bs-theme="blue-theme"] h4,
[data-bs-theme="blue-theme"] h5,
[data-bs-theme="blue-theme"] h6,
[data-bs-theme="semi-dark"] h1,
[data-bs-theme="semi-dark"] h2,
[data-bs-theme="semi-dark"] h3,
[data-bs-theme="semi-dark"] h4,
[data-bs-theme="semi-dark"] h5,
[data-bs-theme="semi-dark"] h6 {
    color: inherit;
}

/* Labels de formulário em temas escuros */
[data-bs-theme="dark"] .form-label,
[data-bs-theme="blue-theme"] .form-label,
[data-bs-theme="semi-dark"] .form-label {
    color: rgba(255, 255, 255, 0.9);
}

/* Select e inputs em temas escuros */
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .form-control,
[data-bs-theme="blue-theme"] .form-select,
[data-bs-theme="blue-theme"] .form-control,
[data-bs-theme="semi-dark"] .form-select,
[data-bs-theme="semi-dark"] .form-control {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
    color: #fff;
}

[data-bs-theme="dark"] .form-select option,
[data-bs-theme="blue-theme"] .form-select option,
[data-bs-theme="semi-dark"] .form-select option {
    background-color: #1e293b;
    color: #fff;
}

[data-bs-theme="dark"] .form-select:focus,
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="blue-theme"] .form-select:focus,
[data-bs-theme="blue-theme"] .form-control:focus,
[data-bs-theme="semi-dark"] .form-select:focus,
[data-bs-theme="semi-dark"] .form-control:focus {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: var(--bluemed-primary);
    color: #fff;
}

/* Tabelas em temas escuros */
[data-bs-theme="dark"] .info-table td,
[data-bs-theme="blue-theme"] .info-table td,
[data-bs-theme="semi-dark"] .info-table td {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .info-table td:nth-child(odd),
[data-bs-theme="blue-theme"] .info-table td:nth-child(odd),
[data-bs-theme="semi-dark"] .info-table td:nth-child(odd) {
    background-color: rgba(255, 255, 255, 0.03);
    color: rgba(255, 255, 255, 0.9);
}

[data-bs-theme="dark"] .info-table td:nth-child(even),
[data-bs-theme="blue-theme"] .info-table td:nth-child(even),
[data-bs-theme="semi-dark"] .info-table td:nth-child(even) {
    color: rgba(255, 255, 255, 0.8);
}

/* Breadcrumb em temas escuros */
[data-bs-theme="dark"] .breadcrumb-title,
[data-bs-theme="blue-theme"] .breadcrumb-title,
[data-bs-theme="semi-dark"] .breadcrumb-title {
    color: inherit;
}

/* Card titles em temas escuros */
[data-bs-theme="dark"] .card-title,
[data-bs-theme="blue-theme"] .card-title,
[data-bs-theme="semi-dark"] .card-title {
    color: inherit;
}

/* Alertas em temas escuros */
[data-bs-theme="dark"] .alert,
[data-bs-theme="blue-theme"] .alert,
[data-bs-theme="semi-dark"] .alert {
    color: inherit;
}

/* Botões outline em temas escuros */
[data-bs-theme="dark"] .btn-outline-primary,
[data-bs-theme="blue-theme"] .btn-outline-primary,
[data-bs-theme="semi-dark"] .btn-outline-primary {
    color: var(--bluemed-primary);
    border-color: var(--bluemed-primary);
}

[data-bs-theme="dark"] .btn-outline-primary:hover,
[data-bs-theme="blue-theme"] .btn-outline-primary:hover,
[data-bs-theme="semi-dark"] .btn-outline-primary:hover {
    background-color: var(--bluemed-primary);
    border-color: var(--bluemed-primary);
    color: #fff;
}

/* Info sections em temas escuros */
[data-bs-theme="dark"] .info-section h6,
[data-bs-theme="blue-theme"] .info-section h6,
[data-bs-theme="semi-dark"] .info-section h6 {
    color: inherit;
}

/* Lista de dependentes */
[data-bs-theme="dark"] .dependente-card .card-title,
[data-bs-theme="blue-theme"] .dependente-card .card-title,
[data-bs-theme="semi-dark"] .dependente-card .card-title {
    color: inherit;
}

[data-bs-theme="dark"] .dependente-card p,
[data-bs-theme="blue-theme"] .dependente-card p,
[data-bs-theme="semi-dark"] .dependente-card p {
    color: rgba(255, 255, 255, 0.7);
}

/* ===== RESPONSIVIDADE MOBILE ===== */
@media (max-width: 768px) {
    /* Dashboard - Melhor layout para mobile */
    .welcome-back-img {
        text-align: center;
        padding-top: 20px !important;
    }
    
    .welcome-back-img img {
        max-height: 120px !important;
    }
    
    /* Grid de informações do dashboard */
    .row.g-3 {
        margin-bottom: 10px;
    }
    
    /* Botões de acesso rápido */
    .btn {
        font-size: 14px;
        padding: 10px 15px;
    }
    
    /* Cards */
    .card {
        margin-bottom: 15px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    /* Avatar menor no mobile */
    .avatar-dependente {
        width: 60px !important;
        height: 60px !important;
        font-size: 24px !important;
        margin-right: 15px !important;
    }
    
    /* Dependentes - layout empilhado */
    .dependente-card {
        padding: 15px;
    }
    
    /* Tabelas - scroll horizontal */
    .info-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    /* Formulários */
    .form-label {
        font-size: 14px;
    }
    
    .form-select,
    .form-control {
        font-size: 16px; /* Previne zoom automático no iOS */
    }
    
    /* Breadcrumb menor */
    .breadcrumb-title {
        font-size: 20px !important;
    }
    
    /* Espaçamento entre colunas */
    .col-12 {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    /* Footer responsivo */
    .page-footer {
        padding: 15px 10px;
        font-size: 12px;
        text-align: center;
    }
    
    /* Menu lateral em mobile */
    .sidebar-wrapper {
        width: 260px !important;
    }
    
    /* Carteirinha - ajustes para mobile */
    .carteirinha-frente,
    .carteirinha-verso {
        margin: 0 auto;
        max-width: 100%;
    }
    
    .carteirinha-digital {
        padding: 20px !important;
        min-height: 300px !important;
        margin-bottom: 20px;
    }
    
    .avatar-carteirinha {
        width: 70px !important;
        height: 70px !important;
        font-size: 32px !important;
    }
    
    .carteirinha-info h3 {
        font-size: 18px !important;
    }
    
    .carteirinha-dados {
        padding: 12px !important;
    }
    
    .carteirinha-dados label {
        font-size: 10px !important;
    }
    
    .carteirinha-dados .valor {
        font-size: 13px !important;
    }
    
    /* Botões da carteirinha empilhados */
    .carteirinha-acoes .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    /* Elegibilidade - melhor visualização */
    .elegivel-badge {
        float: none !important;
        display: block;
        text-align: center;
        margin-bottom: 15px;
    }
    
    /* Info table responsiva */
    .info-table td {
        font-size: 13px;
        padding: 8px 10px;
    }
    
    /* Ajuste de badges e tags */
    .badge {
        font-size: 12px;
        padding: 5px 10px;
    }
}

@media (max-width: 576px) {
    /* Extra pequeno - ajustes adicionais */
    h1, .h1 { font-size: 24px; }
    h2, .h2 { font-size: 22px; }
    h3, .h3 { font-size: 20px; }
    h4, .h4 { font-size: 18px; }
    h5, .h5 { font-size: 16px; }
    h6, .h6 { font-size: 14px; }
    
    /* Botões full width em mobile muito pequeno */
    .btn-primary,
    .btn-outline-primary {
        width: 100%;
        margin-bottom: 10px;
    }
    
    /* Reduzir padding geral */
    .main-content {
        padding: 10px;
    }
    
    /* Avatar do usuário menor */
    .rounded-circle[width="60"] {
        width: 50px !important;
        height: 50px !important;
    }
    
    /* Informações empilhadas no dashboard */
    .d-flex.gap-3,
    .d-flex.gap-5 {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .vr {
        display: none !important;
    }
    
    /* Header mobile */
    .top-header {
        padding: 10px !important;
    }
    
    .top-header .logo-text {
        font-size: 16px !important;
    }
    
    /* Tabelas info responsivas - empilhar em mobile pequeno */
    .info-table {
        font-size: 12px;
    }
    
    .info-table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid var(--bs-border-color);
        border-radius: 8px;
        padding: 10px;
    }
    
    .info-table td {
        display: block;
        width: 100% !important;
        border: none !important;
        padding: 5px 0 !important;
    }
    
    .info-table td:nth-child(odd) {
        font-weight: 700;
        padding-bottom: 2px !important;
    }
    
    .info-table td:nth-child(even) {
        padding-bottom: 10px !important;
        border-bottom: 1px solid var(--bs-border-color);
    }
}

/* Prevenir problemas de viewport no iOS */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
}

/* Melhorar touch targets para mobile (mínimo 44x44px) */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .form-check-input,
    .form-select,
    a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Links de menu */
    .metismenu a {
        min-height: 48px;
        padding: 12px 20px;
    }
}

/* ===== CUSTOMIZAÇÃO LOGOS SIDEBAR ===== */
/* Logos no sidebar - Blue Med */
aside.sidebar-wrapper .sidebar-header .logo-icon img.logo-sidebar-icon {
    height: 35px !important;
    width: 35px !important;
    object-fit: contain !important;
    display: none !important;
    margin: 0 auto !important;
}

aside.sidebar-wrapper .sidebar-header .logo-name img.logo-sidebar-full {
    height: 50px !important;
    width: auto !important;
    max-width: 180px !important;
    object-fit: contain !important;
    display: block !important;
}

/* Quando sidebar está minimizado (body.toggled) - MOSTRA LOGO-ICON */
body.toggled:not(.sidebar-hovered) .sidebar-wrapper .sidebar-header .logo-icon img.logo-sidebar-icon {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

body.toggled:not(.sidebar-hovered) .sidebar-wrapper .sidebar-header .logo-name img.logo-sidebar-full {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Quando passa mouse no sidebar minimizado (sidebar-hovered) - VOLTA LOGO-FULL */
body.toggled.sidebar-hovered .sidebar-wrapper .sidebar-header .logo-icon img.logo-sidebar-icon {
    display: none !important;
}

body.toggled.sidebar-hovered .sidebar-wrapper .sidebar-header .logo-name img.logo-sidebar-full {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Prevenir overflow horizontal em containers do Bootstrap */
.container,
.container-fluid,
.row {
    max-width: 100%;
    overflow-x: hidden;
}

.row {
    margin-right: 0;
    margin-left: 0;
}

[class*="col-"] {
    max-width: 100%;
}
