/**
 * Estilos globais para tabelas e filtros - padrão moderno (COLAB)
 * Cores do site: #005d90 (primary), #013552 (secondary)
 * Incluído no layout para afetar todas as páginas.
 */

/* ---- Header: ícone do usuário ---- */
.content-page .navbar .user-menu-icon-only {
    padding: 0.4rem 0.6rem;
}
.content-page .navbar .user-menu-icon-only::after {
    margin-left: 0.25rem;
}

/* ---- Seletor de unidade (multiestabelecimento) - modelo calendário + nome ---- */
.content-page .navbar .unit-selector-trigger {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
    color: #013552;
    font-weight: 500;
    border: 1px solid rgba(0, 93, 144, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    max-width: 220px;
}
.content-page .navbar .unit-selector-trigger:hover {
    background: #fff;
    border-color: #005d90;
    color: #005d90;
}
.content-page .navbar .unit-selector-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}
.content-page .navbar .unit-selector-dropdown {
    max-height: 280px;
    overflow-y: auto;
}
.content-page .navbar .unit-selector-dropdown .dropdown-item.active {
    background: #005d90;
    color: #fff;
}

/* ---- Saudação e data abaixo do header ---- */
.user-greeting-block {
    padding: 0.6rem 24px 0.9rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}
.user-greeting-date {
    font-size: 0.875rem;
    color: #6c757d;
    margin: 0 0 0.15rem 0;
    font-weight: 400;
}
.user-greeting-text {
    font-size: 1.1rem;
    color: #005d90;
    margin: 0;
    font-weight: 600;
}

/* ---- Cards (filtros e tabelas) ---- */
.content-page .card {
    border-radius: 12px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.content-page .card-header {
    background: linear-gradient(135deg, #005d90 0%, #013552 100%);
    color: #fff;
    font-weight: 600;
    font-size: 1.05rem;
    padding: 0.9rem 1.25rem;
    border-bottom: none;
}

.content-page .card-header i,
.content-page .card-header .fas,
.content-page .card-header .fa {
    color: rgba(255, 255, 255, 0.95);
    margin-right: 0.35rem;
}

.content-page .card-body {
    padding: 1.25rem;
}

.content-page .card-footer {
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 0.75rem 1.25rem;
    border-radius: 0 0 12px 12px;
}

/* ---- Formulários de filtro ---- */
.content-page .card .form-control {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 0.5rem 0.75rem;
}

.content-page .card .form-control:focus {
    border-color: #005d90;
    box-shadow: 0 0 0 0.2rem rgba(0, 93, 144, 0.15);
}

.content-page .card label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.35rem;
}

/* ---- Botões (Buscar, Novo, etc.) ---- */
.content-page .card-footer .btn,
.content-page .card .btn-primary {
    border-radius: 8px;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
}

.content-page .card .btn-primary {
    background: #005d90;
    border-color: #005d90;
}

.content-page .card .btn-primary:hover {
    background: #013552;
    border-color: #013552;
}

.content-page .card .btn-secondary {
    border-radius: 8px;
    background: #6c757d;
    border-color: #6c757d;
}

/* ---- Tabelas ---- */
.content-page .card .table {
    margin-bottom: 0;
}

.content-page .card .table thead th {
    background: linear-gradient(180deg, #005d90 0%, #013552 100%);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.85rem 1rem;
    border: none;
    text-transform: none;
    letter-spacing: 0.02em;
}

.content-page .card .table thead th:first-child {
    border-radius: 0;
}

.content-page .card .table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-color: #e9ecef;
    color: #495057;
}

.content-page .card .table tbody tr:hover {
    background-color: rgba(0, 93, 144, 0.04);
}

.content-page .card .table tbody tr:nth-of-type(even) {
    background-color: #f8f9fa;
}

.content-page .card .table tbody tr:nth-of-type(even):hover {
    background-color: rgba(0, 93, 144, 0.06);
}

/* Botões de ação na tabela */
.content-page .card .table .btn-sm {
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    margin: 0 0.15rem;
}

.content-page .card .table .btn-primary.btn-sm {
    background: #005d90;
    border-color: #005d90;
}

.content-page .card .table .btn-primary.btn-sm:hover {
    background: #013552;
    border-color: #013552;
}

.content-page .card .table .btn-danger.btn-sm,
.content-page .card .table .btn-delete {
    border-radius: 6px;
}

/* Alert dentro da tabela (nenhum registro) */
.content-page .card .table .alert-warning {
    border-radius: 8px;
    border: none;
}

/* ---- Paginação ---- */
.content-page .card .pagination {
    margin-bottom: 0;
}

.content-page .card .pagination .page-link {
    border-radius: 6px !important;
    margin: 0 2px;
    border-color: #dee2e6;
    color: #005d90;
}

.content-page .card .pagination .page-item.active .page-link {
    background: #005d90;
    border-color: #005d90;
}

.content-page .card .pagination .page-link:hover {
    background: rgba(0, 93, 144, 0.08);
    border-color: #005d90;
}

/* ---- Sidebar minimalista ---- */
.sidebar-minimal .content-menu .nav li {
    margin: 0.2rem 0;
}
.sidebar-minimal .content-menu .nav .nav-link {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.sidebar-minimal .content-menu .nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.sidebar-minimal .content-menu .nav .nav-link i {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    opacity: 0.95;
}
.sidebar-minimal .content-menu .nav .nav-link .title {
    font-size: 0.875rem;
    font-weight: 500;
}

/* ---- Página hub (pastas do menu) ---- */
.menu-hub-page {
    padding: 1rem 0;
}
.menu-hub-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #212529;
    margin-bottom: 1.5rem;
}
.menu-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.menu-hub-folder {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    text-decoration: none;
    color: #495057;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.menu-hub-folder:hover {
    border-color: #005d90;
    box-shadow: 0 2px 8px rgba(0, 93, 144, 0.12);
    color: #005d90;
}
.menu-hub-folder-icon {
    font-size: 1.5rem;
    color: #005d90;
}
.menu-hub-folder-label {
    font-size: 0.95rem;
    font-weight: 500;
}

/* ---- Importação de documentos (pastas por tipo/subtipo/período) ---- */
.import-document-folders-page {
    padding: 0.5rem 0 1.5rem;
}
.import-document-folders-page .menu-hub-title {
    margin-bottom: 1.25rem;
}

/* ---- Loading global — progress bar no topo ---- */
#global-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    z-index: 99999;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
    background: rgba(0, 93, 144, 0.12);
}
#global-loading.is-active {
    opacity: 1;
}
#global-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    border-radius: 0 2px 2px 0;
    background: linear-gradient(90deg, #005d90 0%, #2196f3 50%, #005d90 100%);
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.5);
    animation: glb-bar-slide 1.1s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes glb-bar-slide {
    0%   { left: -40%; }
    100% { left: 100%; }
}

/* ---- Banner do site (logo + título no início) ---- */
.site-banner {
    background: #f0f2f5;
    border-bottom: 1px solid #e0e3e8;
    padding: 1rem 1.5rem 1.25rem;
}
.site-banner-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.site-banner-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}
.site-banner-logo-img {
    max-height: 56px;
    width: auto;
    object-fit: contain;
    display: block;
}
.site-banner-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #2c3e50;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.3;
}
@media (min-width: 768px) {
    .site-banner-title { font-size: 1.35rem; }
}

/* ---- Campos Logo e Título no criador de formulários (tamanho padrão do anexo) ---- */
.custom-form-field-logo {
    background: #f0f2f5;
    border-bottom: 1px solid #e0e3e8;
    padding: 1rem 1.5rem 1.25rem;
    margin: 0 -1.25rem 1rem -1.25rem;
}
.custom-form-field-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}
.custom-form-field-logo-img {
    max-height: 56px;
    width: auto;
    object-fit: contain;
    display: block;
}
.custom-form-field-title {
    margin-bottom: 1rem;
}
.custom-form-field-title-text {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #2c3e50;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.3;
}
@media (min-width: 768px) {
    .custom-form-field-title-text { font-size: 1.35rem; }
}

/* ============================================================
   SIDEBAR → TOP NAVIGATION MODE
   ============================================================ */

/* -- Sidebar: flex column para o botão de toggle ficar no fundo -- */
.wrapper .sidebar {
    display: flex;
    flex-direction: column;
}

.wrapper .sidebar .h-100 {
    flex: 1;
    min-height: 0;
    height: auto !important;
}

/* -- Botão de alternar para modo topo (no rodapé da sidebar) -- */
.sidebar-topmode-toggle {
    flex-shrink: 0;
    padding: 0.4rem 0.5rem;
    background: rgba(0, 0, 0, 0.15);
    text-align: center;
}

.sidebar-topmode-toggle button {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    line-height: 1.2;
}

.sidebar-topmode-toggle button:hover {
    background: rgba(255, 255, 255, 0.25);
}

.sidebar-topmode-toggle button i {
    font-size: 1rem;
}

.sidebar-topmode-toggle button span {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* -- Menu de contexto (botão direito) para restaurar menu lateral -- */
#sidebar-topmode-context-menu {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    min-width: 210px;
    user-select: none;
}

#sidebar-topmode-context-menu ul {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
}

#sidebar-topmode-context-menu ul li {
    padding: 0.65rem 1rem;
    cursor: pointer;
    color: #013552;
    font-size: 0.9rem;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#sidebar-topmode-context-menu ul li:hover {
    background: #f0f4f8;
}

/* -- Sidebar em modo topo -- */
body.sidebarTopMode .wrapper .sidebar {
    width: 100%;
    height: 60px;
    padding-top: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    z-index: 1002;
    overflow: hidden;
}

body.sidebarTopMode .wrapper .sidebar .logo {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    line-height: normal;
    padding: 0;
    height: auto;
    display: flex;
    align-items: center;
}

body.sidebarTopMode .wrapper .sidebar .logo .logo-full {
    display: block !important;
    height: 36px;
    width: auto;
}

body.sidebarTopMode .wrapper .sidebar .logo .logo-min {
    display: none !important;
}

/* -- Nav horizontal clonada via JS (#sidebar-topmode-nav) -- */
body.sidebarTopMode #sidebar-topmode-nav {
    display: flex !important;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    height: 60px;
    flex: none;
    max-width: calc(100% - 220px);
    overflow-x: auto;
    overflow-y: hidden;
    list-style: none;
    margin: 0;
    padding: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

body.sidebarTopMode #sidebar-topmode-nav::-webkit-scrollbar {
    display: none;
}

body.sidebarTopMode #sidebar-topmode-nav .nav-item {
    flex-shrink: 0;
    text-align: center;
    margin: 0;
}

body.sidebarTopMode #sidebar-topmode-nav .nav-item a.nav-link {
    padding: 0.4rem 0.65rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    white-space: nowrap;
    color: #fff;
}

body.sidebarTopMode #sidebar-topmode-nav .nav-item a.nav-link i {
    font-size: 1.05rem;
}

body.sidebarTopMode #sidebar-topmode-nav .nav-item a.nav-link span.title {
    font-size: 0.58rem;
    display: block;
    margin-top: 2px;
}

body.sidebarTopMode #sidebar-topmode-nav .nav-item a.nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 6px;
}

/* Esconde o simplebar e o botão de toggle imediatamente via CSS
   (antes do JS rodar), evitando o "flash" do menu lateral */
body.sidebarTopMode .wrapper .sidebar .h-100,
body.sidebarTopMode .wrapper .sidebar .sidebar-topmode-toggle {
    display: none !important;
}

body.sidebarTopMode .wrapper .content-page {
    margin-left: 0;
    margin-top: 60px;
}

body.sidebarTopMode .wrapper .content-page .navbar-top {
    left: 0;
    top: 60px;
}

/* -- Saudação dentro do navbar-top em modo topo -- */
body.sidebarTopMode .user-greeting-block {
    position: fixed;
    top: 60px;
    left: 24px;
    right: auto;
    min-height: 70px;
    height: 70px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: transparent;
    border-bottom: none;
    padding: 0;
    z-index: 1002;
    pointer-events: none;
}
