/* ================================================================
   CC Gestão — Folha de estilos principal
   ================================================================ */

:root {
    --cc-azul:         #2B7DBB;
    --cc-azul-escuro:  #1A5F96;
    --cc-azul-claro:   #EBF4FB;
    --cc-verde:        #27AE7A;
    --cc-verde-claro:  #E8F8F3;
    --cc-cinza-bg:     #F4F6F9;
    --cc-borda:        #DEE4EC;
    --cc-texto:        #2D3748;
    --cc-texto-leve:   #718096;
    --sidebar-bg:      #1A3D5C;
    --sidebar-hover:   #234F78;
    --sidebar-active:  #2B7DBB;
    --sidebar-muted:   #8DAFC8;
    --sidebar-width:   255px;
    --topbar-height:   58px;
    font-family: 'Open Sans', sans-serif;
}

/* ── Reset e base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
    background: var(--cc-cinza-bg);
    color: var(--cc-texto);
    font-size: .92rem;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6,
.fw-bold, .fw-semibold { font-family: 'Montserrat', sans-serif; }

/* ── Wrapper ──────────────────────────────────────────────────── */
#wrapper { min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0;
    z-index: 1000;
    transition: transform .25s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.bg-sidebar { background: var(--sidebar-bg) !important; }

.sidebar-brand { border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-icon { color: var(--cc-azul); }

/* ── Logo institucional — usado somente no cabeçalho dos relatórios ── */
.print-logo-img  { max-height: 70px; max-width: 260px; width: auto; height: auto; object-fit: contain; }
.config-logo-preview { max-height: 120px; max-width: 100%; width: auto; height: auto; object-fit: contain; }

.sidebar-divider {
    border-color: rgba(255,255,255,.1);
    margin: .25rem 0;
}

/* Itens de menu */
#sidebar .nav-link {
    color: rgba(255,255,255,.78);
    border-radius: 6px;
    padding: .52rem .75rem;
    font-size: .85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    transition: background .18s, color .18s;
    white-space: nowrap;
}
#sidebar .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
#sidebar .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}
#sidebar .nav-link .badge {
    font-size: .62rem;
    font-weight: 500;
    padding: .22em .5em;
    border-radius: 4px;
}

/* Rótulos de seção */
.nav-section-label {
    list-style: none;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
    padding: .85rem .75rem .25rem;
    font-family: 'Montserrat', sans-serif;
}

/* Avatar */
.avatar-circle {
    width: 32px; height: 32px;
    background: var(--cc-azul);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 700;
    color: #fff; flex-shrink: 0;
}
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.08); }
.text-sidebar-muted { color: var(--sidebar-muted) !important; }

/* ── Overlay mobile ───────────────────────────────────────────── */
.sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 999;
}

/* ── Conteúdo principal ───────────────────────────────────────── */
#page-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex; flex-direction: column;
    transition: margin-left .25s ease;
    width: calc(100% - var(--sidebar-width));
}

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--cc-borda);
    display: flex; align-items: center;
    padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 900;
}
.topbar .page-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--cc-texto);
}
.topbar .breadcrumb { font-size: .78rem; margin: 0; }

/* Botão toggle mobile */
#btnToggleSidebarTop {
    border: none; background: none;
    color: var(--cc-texto); font-size: 1.2rem;
    padding: .25rem .5rem; margin-right: .75rem;
    border-radius: 4px;
}
#btnToggleSidebarTop:hover { background: var(--cc-azul-claro); }

/* ── Área de conteúdo ─────────────────────────────────────────── */
.content-area {
    padding: 1.5rem;
    flex: 1;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--cc-borda);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--cc-borda);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: .9rem;
    border-radius: 10px 10px 0 0 !important;
    padding: .85rem 1.1rem;
}

/* Cards de módulo (dashboard) */
.module-card {
    border-radius: 10px;
    border: 1px solid var(--cc-borda);
    background: #fff;
    padding: 1.4rem 1.2rem;
    display: flex; flex-direction: column;
    align-items: flex-start;
    cursor: default;
    transition: box-shadow .18s, transform .18s;
    height: 100%;
    position: relative;
    overflow: hidden;
}
.module-card:hover {
    box-shadow: 0 4px 16px rgba(43,125,187,.14);
    transform: translateY(-2px);
}
.module-card.soon { opacity: .72; }
a.module-card, a.module-card:hover { color: inherit; }
.module-card .mod-icon {
    width: 46px; height: 46px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    margin-bottom: .85rem;
    flex-shrink: 0;
}
.module-card h6 {
    font-family: 'Montserrat', sans-serif;
    font-size: .88rem;
    font-weight: 700;
    margin-bottom: .3rem;
}
.module-card p {
    font-size: .78rem;
    color: var(--cc-texto-leve);
    line-height: 1.4;
    margin: 0;
}
.badge-soon {
    position: absolute; top: .75rem; right: .75rem;
    font-size: .6rem; font-weight: 700;
    background: var(--cc-azul-claro);
    color: var(--cc-azul);
    padding: .2em .55em;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ── Cards de KPI ─────────────────────────────────────────────── */
.kpi-card {
    background: #fff;
    border: 1px solid var(--cc-borda);
    border-radius: 10px;
    padding: 1.1rem 1.2rem;
    display: flex; align-items: center; gap: 1rem;
}
.kpi-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.kpi-value {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1;
}
.kpi-label {
    font-size: .75rem;
    color: var(--cc-texto-leve);
    font-weight: 500;
}

/* Cores de ícones */
.icon-azul  { background: var(--cc-azul-claro);  color: var(--cc-azul); }
.icon-verde { background: var(--cc-verde-claro);  color: var(--cc-verde); }
.icon-amarelo { background: #FFF8E7; color: #D4A017; }
.icon-roxo  { background: #F3EEFF; color: #7B4FD0; }
.icon-ciano { background: #E6F9F8; color: #0D9488; }

/* ── Login ────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, #1F567E 60%, #2B7DBB 100%);
    display: flex; align-items: center; justify-content: center;
}
.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 2.5rem 2.2rem;
    width: 100%; max-width: 400px;
    box-shadow: 0 8px 40px rgba(0,0,0,.22);
}
.login-logo {
    width: 62px; height: 62px;
    background: var(--cc-azul-claro);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem; color: var(--cc-azul);
    margin: 0 auto 1.4rem;
}
.login-card h4 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--cc-texto);
    text-align: center;
}
.login-card .subtitle {
    font-size: .78rem;
    color: var(--cc-texto-leve);
    text-align: center;
    margin-bottom: 1.8rem;
}
.btn-login {
    background: var(--cc-azul);
    border-color: var(--cc-azul);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    letter-spacing: .02em;
    padding: .6rem;
}
.btn-login:hover { background: var(--cc-azul-escuro); border-color: var(--cc-azul-escuro); }

/* ── Timeline SAEP ────────────────────────────────────────────── */
.saep-timeline { position: relative; }
.saep-etapa {
    position: relative;
    padding-left: 64px;
    padding-bottom: 2rem;
}
.saep-etapa.saep-etapa-final { padding-bottom: 0; }
.saep-etapa::before {
    content: '';
    position: absolute;
    left: 23px;
    top: 48px;
    bottom: -2rem;
    width: 2px;
    background: var(--cc-borda);
}
.saep-etapa.saep-etapa-final::before { display: none; }
.saep-etapa-marcador {
    position: absolute;
    left: 0; top: 0;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--cc-borda);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    color: var(--cc-texto-leve);
    z-index: 1;
}
.saep-etapa-marcador.preenchida {
    background: var(--cc-azul);
    border-color: var(--cc-azul);
    color: #fff;
}

/* ── Utilitários ──────────────────────────────────────────────── */
.text-cc { color: var(--cc-azul) !important; }
.bg-cc   { background: var(--cc-azul) !important; }
.border-cc { border-color: var(--cc-borda) !important; }

/* ── Responsivo ───────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    #sidebar {
        transform: translateX(-100%);
    }
    #sidebar.show {
        transform: translateX(0);
    }
    #page-content {
        margin-left: 0;
        width: 100%;
    }
    #btnToggleSidebarTop { display: flex !important; }
    .content-area { padding: 1rem; }
}

@media (min-width: 992px) {
    #btnToggleSidebarTop { display: none !important; }
    .sidebar-overlay { display: none !important; }
}

/* ── Impressão (Ctrl+P) — esconde chrome de navegação em qualquer página ── */
@media print {
    #sidebar, .topbar, .sidebar-overlay { display: none !important; }
    #page-content { margin-left: 0 !important; width: 100% !important; }
    .content-area { padding: 0 !important; }
    body { background: #fff !important; }
    .card { border: none !important; box-shadow: none !important; }
    a[href]::after { content: '' !important; }
}

/* ── Mapa Cirúrgico — Visão Linha do Tempo (premium) ──
   Cada sala é uma trilha horizontal; cada cirurgia é um bloco posicionado
   proporcionalmente ao horário/duração dentro da janela do dia (06h–20h). */
.mapa-timeline-wrap {
    overflow-x: auto;
}
.mapa-timeline-eixo {
    display: grid;
    grid-template-columns: 140px 1fr;
    border-bottom: 1px solid var(--cc-borda);
    padding-bottom: 6px;
    margin-bottom: 4px;
    min-width: 900px;
}
.mapa-timeline-eixo-horas {
    position: relative;
    height: 20px;
}
.mapa-timeline-hora-label {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-size: .7rem;
    color: var(--cc-texto-leve);
    font-weight: 600;
}
.mapa-timeline-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: stretch;
    border-bottom: 1px solid var(--cc-borda);
    min-width: 900px;
}
.mapa-timeline-row:last-child { border-bottom: none; }
.mapa-timeline-sala-nome {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 8px;
    font-weight: 600;
    font-size: .82rem;
    color: var(--cc-texto);
    background: var(--cc-cinza-bg);
    border-right: 1px solid var(--cc-borda);
}
.mapa-timeline-track {
    position: relative;
    min-height: 58px;
    background-image: repeating-linear-gradient(to right, var(--cc-borda) 0, var(--cc-borda) 1px, transparent 1px, transparent calc(100% / 14));
    background-size: 100% 100%;
}
.mapa-timeline-agora {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #E53E3E;
    z-index: 3;
}
.mapa-timeline-bloco {
    position: absolute;
    top: 6px;
    bottom: 6px;
    min-width: 46px;
    border-radius: 6px;
    padding: 3px 6px;
    font-size: .7rem;
    line-height: 1.2;
    color: #fff;
    overflow: hidden;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0,0,0,.18);
    transition: transform .12s ease, box-shadow .12s ease;
    z-index: 2;
}
.mapa-timeline-bloco:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,.28);
    color: #fff;
    z-index: 4;
}
.mapa-timeline-bloco.emergencia { outline: 2px solid #D4A017; outline-offset: -2px; }
.mapa-timeline-bloco .hora { font-weight: 700; display: block; }
.mapa-timeline-bloco .paciente { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mapa-timeline-status-agendada           { background: #718096; }
.mapa-timeline-status-paciente_admitido  { background: #3182CE; }
.mapa-timeline-status-em_cirurgia        { background: var(--cc-azul-escuro); }
.mapa-timeline-status-limpeza_concorrente,
.mapa-timeline-status-limpeza_terminal   { background: #D4A017; }
.mapa-timeline-status-liberada           { background: var(--cc-verde); }
.mapa-timeline-status-suspensa           { background: #C53030; text-decoration: line-through; opacity: .75; }
.mapa-timeline-legenda .badge { font-weight: 500; }

@media print {
    .mapa-timeline-wrap { overflow: visible; }
    .mapa-timeline-eixo, .mapa-timeline-row { min-width: 0; }
    .mapa-timeline-bloco:hover { transform: none; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
}
