/* =============================================================
   LicitaNexus — app.css
   Apenas: variáveis CSS + layout base + dark mode
   NÃO define CSS de componentes de templates individuais.
   ============================================================= */

/* ─── 1. VARIÁVEIS — LIGHT MODE ─────────────────────────────── */
:root {
    --sidebar-width-expanded:  260px;
    --sidebar-width-collapsed: 72px;
    --topbar-height:           70px;
    --primary:                 #0d6efd;
    --primary-hover:           #0b5ed7;
    --sidebar-bg-from:         #0d6efd;
    --sidebar-bg-to:           #172031;
    --sidebar-text:            #e0e0e0;
    --sidebar-text-hover:      #ffffff;
    --sidebar-item-hover:      rgba(255,255,255,0.1);
    --sidebar-item-active:     rgba(255,255,255,0.15);
    --main-bg:                 #f0f2f5;
    --border-color:            #dee2e6;
    --text-heading:            #343a40;
}

/* ─── 2. VARIÁVEIS — DARK MODE (custom, não-Bootstrap) ──────── */
[data-theme="dark"] {
    --main-bg:      #1a1d23;
    --border-color: #374151;
    --text-heading: #f1f5f9;
}

/* ─── 3. BODY & BASE ─────────────────────────────────────────── */
body {
    background-color: var(--main-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    padding-top: var(--topbar-height);
    transition: background-color 0.25s ease;
}

/* ─── 4. TOPBAR ──────────────────────────────────────────────── */
#topbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--topbar-height);
    background-color: var(--main-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 1030; padding: 0 1.5rem;
    display: flex; align-items: center;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}
#topbar .logo-topbar { height: 40px; width: auto; }
#topbar .btn:not(.btn-primary) {
    background: var(--surface); border: 1px solid var(--border-strong); color: var(--primary); border-radius: 9px; box-shadow: none;
}
#topbar .btn:not(.btn-primary):hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.topbar-guide-link { color: var(--primary); text-decoration: none; font-weight: 500; }
.topbar-guide-link:hover { text-decoration: underline; }

/* ─── Botão Voltar padrão ────────────────────────────────────────── */
.nexus-btn-voltar {
    font-size: 0.82rem; transition: all 0.2s ease;
}
.nexus-btn-voltar:hover { border-color: var(--primary) !important; color: var(--primary) !important; }

/* Dark topbar */
[data-theme="dark"] #topbar {
    background-color: var(--main-bg);
    border-bottom-color: var(--border-color);
}

/* ─── 5. SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
    background: linear-gradient(180deg, var(--sidebar-bg-from) 0%, var(--sidebar-bg-to) 100%);
    width: var(--sidebar-width-expanded);
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 1031;
    display: flex; flex-direction: column;
    padding: 1rem;
    transition: transform 0.3s ease-in-out;
    transform: translateX(0);
}
body.sidebar-collapsed .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width-expanded) + var(--sidebar-width-collapsed)));
}
#sidebar-toggle-btn {
    background: none; border: none; color: var(--sidebar-text);
    font-size: 1.2rem; cursor: pointer; position: absolute;
    top: 1.25rem; right: 1.25rem; transition: transform 0.3s ease;
}
.sidebar-header {
    padding: 0.5rem 0 1.5rem 0; display: flex; align-items: center; justify-content: center;
}
.sidebar-header .logo-sidebar { max-width: 130px; height: auto; transition: opacity 0.3s ease; }
.sidebar .nav-buttons {
    display: flex; flex-direction: column; gap: 0.25rem; flex-grow: 1;
    overflow-y: auto; overflow-x: hidden; padding-right: 4px;
}
.sidebar .nav-buttons::-webkit-scrollbar { width: 5px; }
.sidebar .nav-buttons::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 4px; }
.sidebar .nav-buttons::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 4px; }
.sidebar .nav-buttons::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.45); }
.sidebar .nav-item-link {
    display: flex; align-items: center; padding: 0.5rem 1rem; border-radius: 0.375rem;
    color: var(--sidebar-text); text-decoration: none; white-space: nowrap;
    overflow: hidden; transition: background-color 0.2s, color 0.2s;
}
.sidebar .nav-item-link:hover { background-color: var(--sidebar-item-hover); color: var(--sidebar-text-hover); }
.sidebar .nav-item-link.active { background-color: var(--sidebar-item-active); color: #fff; font-weight: 600; }
.sidebar .nav-icon {
    width: 30px; min-width: 30px; text-align: center; font-size: 1.2rem;
    margin-right: 0.85rem; transition: margin 0.3s ease-in-out, color 0.2s;
}
.sidebar .nav-text { opacity: 1; transition: opacity 0.2s ease-in-out; }
body.sidebar-collapsed .sidebar-header .logo-sidebar { opacity: 0; pointer-events: none; }
body.sidebar-collapsed #sidebar-toggle-btn { transform: rotate(180deg); }
body.sidebar-collapsed .sidebar .nav-text { opacity: 0; width: 0; pointer-events: none; visibility: hidden; }
body.sidebar-collapsed .sidebar .nav-icon { margin-right: 0; }
.sidebar-collapsed .sidebar .nav-item-link { justify-content: flex-end; padding-left: 0; padding-right: 1rem; }

/* ─── 6. CONTEÚDO PRINCIPAL ──────────────────────────────────── */
/* SEM transição em padding-left/max-width: animar layout reflowa a página
   inteira a cada frame (trava o colapso em telas cheias). O conteúdo encaixa
   instantâneo; só a sidebar desliza via transform (ver base.html). */
#main-content { }
.content-wrapper { max-width: 1000px; margin: 0 auto; padding: 0 1.5rem; }
@media (min-width: 992px) {
    #main-content { padding-left: var(--sidebar-width-expanded); }
    body.sidebar-collapsed #main-content { padding-left: var(--sidebar-width-collapsed); }
    body.sidebar-collapsed .content-wrapper { max-width: 1200px; }
}
.main-header { padding-top: 1.5rem; margin-bottom: 1.5rem; }
.main-header h1, .main-header h2, .main-header h3 {
    font-size: 1.75rem; font-weight: 600; color: var(--text-heading); margin-bottom: 0;
}
/* .main-header .btn: sem MAIÚSCULAS desde 21/10/2026 — padrão único em app-modern.css seção 5 */

/* ─── 7. ÍCONE DE TÍTULO (substitui PNGs) ────────────────────── */
.page-title-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, #0a58ca 100%);
    color: #fff; font-size: 1.1rem; flex-shrink: 0; margin-right: 0.75rem;
}

/* ─── 8. KPI / STAT CARDS — PADRÃO GLOBAL ────────────────────── */
.stat-card {
    border-radius: 12px; background: #fff;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(0,0,0,0.06);
}
.stat-card.clickable-kpi { cursor: pointer; }
.stat-card.clickable-kpi:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.10); }

/* Border-left color variants */
.border-primary-custom { border-left: 4px solid #0d6efd !important; }
.border-danger-custom  { border-left: 4px solid #dc3545 !important; }
.border-warning-custom { border-left: 4px solid #ffc107 !important; }
.border-success-custom { border-left: 4px solid #198754 !important; }
.border-gray-custom    { border-left: 4px solid #6c757d !important; }

/* Label padronizado (substitui inline styles de font-size/weight/spacing) */
.kpi-label {
    font-size: 0.7rem !important; font-weight: 700 !important;
    letter-spacing: 0.5px; text-transform: uppercase;
    color: #64748b; margin-bottom: 0.25rem; white-space: nowrap;
}

/* Caixa de ícone circular do KPI */
.kpi-icon-box {
    width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
}
.kpi-icon-primary { background: rgba(13,110,253,0.10); color: #0d6efd; }
.kpi-icon-danger   { background: rgba(220,53,69,0.10);  color: #dc3545; }
.kpi-icon-warning  { background: rgba(255,193,7,0.15);  color: #d39e00; }
.kpi-icon-success  { background: rgba(25,135,84,0.10);  color: #198754; }
.kpi-icon-gray     { background: rgba(108,117,125,0.10); color: #6c757d; }

/* ─── 9. NOTIFICAÇÕES (movido de base.html inline) ───────────── */
.notification-bell-link {
    font-size: 1.2rem; color: #6c757d; position: relative;
    display: flex; align-items: center; justify-content: center; transition: color 0.2s;
}
.notification-bell-link:hover, .notification-bell-link.show { color: var(--primary); }
.notification-badge-main { position: absolute; top: 2px; right: 0; font-size: 0.6em; padding: 0.2em 0.4em; display: none; }
#notification-dropdown-container {
    width: 380px; padding: 0; overflow: hidden;
    border-radius: 0.5rem; box-shadow: 0 0.5rem 1rem rgba(0,0,0,.15);
    border: 1px solid var(--border-color);
}
@media (max-width: 576px) {
    #notification-dropdown-container {
        width: 92vw; position: fixed !important;
        top: var(--topbar-height) !important; left: 4vw !important; right: 4vw !important; transform: none !important;
    }
}
.notification-tabs .nav-link {
    color: #6c757d; font-size: 0.85rem; font-weight: 600;
    padding: 0.75rem 1rem; border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none;
}
.notification-tabs .nav-link.active { color: var(--primary); background-color: transparent; border-bottom: 2px solid var(--primary); }
.notification-tabs .nav-link:hover { background-color: #f8f9fa; }
.notification-list-wrapper { max-height: 350px; overflow-y: auto; }
.notification-item {
    display: flex; align-items: flex-start; padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0; transition: background-color 0.2s ease;
    text-decoration: none; color: inherit;
}
.notification-item:hover { background-color: #f8f9fa; color: inherit; }
.notification-item:last-child { border-bottom: none; }
.notification-item.unread { background-color: #eaf2ff; }
.notification-item .icon-wrapper {
    flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin-right: 0.75rem; color: #fff; font-size: 0.9rem;
}
.notification-item .content-wrapper { flex-grow: 1; min-width: 0; }
.notification-item .content-wrapper strong { font-size: 0.8rem; display: block; margin-bottom: 0.1rem; }
.notification-item .content-wrapper .message { font-size: 0.75rem; color: #555; margin: 0; line-height: 1.3; }
.notification-item .content-wrapper .timestamp { font-size: 0.65rem; color: #999; display: block; margin-top: 0.25rem; }
.notification-footer {
    padding: 0.75rem; text-align: center; font-size: 0.8rem;
    background-color: #f8f9fa; border-top: 1px solid var(--border-color);
}
.notification-footer a { text-decoration: none; font-weight: 600; }
.empty-state { padding: 2rem; text-align: center; color: #6c757d; font-size: 0.85rem; }
.badge-pulse-atendimento {
    width: 8px; height: 8px; background-color: var(--primary); border-radius: 50%;
    display: inline-block; margin-left: 5px;
    animation: pulse-blue 2s infinite;
}
@keyframes pulse-blue {
    0%   { box-shadow: 0 0 0 0 rgba(13,110,253,0.7); }
    70%  { box-shadow: 0 0 0 10px rgba(13,110,253,0); }
    100% { box-shadow: 0 0 0 0 rgba(13,110,253,0); }
}

/* ─── 9. DARK MODE — Overrides para componentes customizados ─── */
/* (Bootstrap 5.3 cuida dos seus componentes via data-bs-theme="dark") */
[data-theme="dark"] .notification-tabs .nav-link:hover { background-color: rgba(255,255,255,0.05); }
[data-theme="dark"] .notification-item:hover           { background-color: rgba(255,255,255,0.04); }
[data-theme="dark"] .notification-item.unread          { background-color: rgba(13,110,253,0.12); }
[data-theme="dark"] .notification-footer               { background-color: rgba(255,255,255,0.03); }
[data-theme="dark"] .notification-item .content-wrapper .message  { color: #94a3b8; }
[data-theme="dark"] .notification-item .content-wrapper .timestamp { color: #64748b; }
/* Toast container */
#toast-container-global { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; }

/* ═══════════════════════════════════════════════════════════════
   FILTER BAR — sistema de filtros padronizado (todas as páginas)
   ═══════════════════════════════════════════════════════════════ */

/* Contêiner da barra de filtros */
.nexus-filter-bar {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.6rem 1rem;
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

/* Input de busca textual */
.nexus-search-pill {
    display: flex; align-items: center;
    border: 1px solid #ced4da; border-radius: 50rem;
    background: #fff; padding: 0.35rem 1rem;
    min-width: 200px; flex: 1; max-width: 320px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.nexus-search-pill:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.18rem rgba(13,110,253,.18);
}
.nexus-search-pill i { color: #94a3b8; font-size: 0.85rem; flex-shrink: 0; }
.nexus-search-pill input {
    border: none; outline: none; background: transparent;
    width: 100%; margin-left: 0.5rem; font-size: 0.85rem; color: #1e293b;
}

/* Botão dropdown padronizado */
.nexus-dd-btn {
    background: #fff; border: 1px solid #ced4da; border-radius: 50rem;
    padding: 0.35rem 1rem; font-size: 0.82rem; font-weight: 600;
    color: #374151; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 0.4rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.nexus-dd-btn:hover, .nexus-dd-btn.show {
    border-color: var(--primary); color: var(--primary);
    box-shadow: 0 0 0 0.15rem rgba(13,110,253,.12);
}
.nexus-dd-btn.has-value { border-color: var(--primary); color: var(--primary); background: #f0f7ff; }
.nexus-dd-btn::after { margin-left: auto; }

/* Menu dropdown */
.nexus-dd-menu {
    border-radius: 10px !important; min-width: 220px;
    max-height: 320px; overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.10) !important;
    border: 1px solid #e2e8f0 !important;
    padding: 0.5rem 0 !important;
}
.nexus-dd-search-wrapper { padding: 0.4rem 0.6rem 0.5rem; border-bottom: 1px solid #f1f5f9; }
.nexus-dd-search {
    border-radius: 6px !important; font-size: 0.82rem !important;
    background: #f8fafc !important; border: 1px solid #e2e8f0 !important;
    padding: 0.35rem 0.75rem !important;
}
.nexus-dd-search:focus { border-color: var(--primary) !important; box-shadow: none !important; }

/* Itens do dropdown */
.nexus-dd-item {
    font-size: 0.83rem; padding: 0.45rem 1rem; color: #374151; border-radius: 0;
    display: block; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nexus-dd-item:hover  { background: #f0f7ff; color: var(--primary); }
.nexus-dd-item.active { background: #e8f0fe; color: var(--primary); font-weight: 600; }

/* Botão Limpar */
.nexus-clear-btn {
    background: none; border: none; font-size: 0.8rem; font-weight: 600;
    color: #94a3b8; padding: 0.35rem 0.5rem; cursor: pointer;
    transition: color 0.15s; border-radius: 6px; white-space: nowrap;
}
.nexus-clear-btn.active { color: #dc3545; }
.nexus-clear-btn:hover  { color: #dc3545; background: #fff5f5; }

/* Separador visual entre grupos de filtros */
.nexus-filter-divider {
    width: 1px; height: 24px; background: #e2e8f0; flex-shrink: 0;
}

/* Highlight de busca nos itens */
mark.nexus-highlight { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 2px; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVIDADE MOBILE — global (≤ 767px)
   Aplicado em todas as páginas via base.html → app.css
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {

  /* ── Layout base ───────────────────────────────────────────── */
  body { padding-top: var(--topbar-height); }
  /* 0.75rem = 12px: absorve o gutter negativo (-12px) das .row do Bootstrap
     (senão elas vazam ~4px além da viewport). */
  #main-content { padding: 0.75rem !important; }
  /* No mobile o padding do .content-wrapper (1.5rem cada lado) empilhava com o
     do #main-content e o do .container-fluid da página → conteúdo espremido.
     Zera aqui: as bordas ficam por conta do #main-content + container interno. */
  .content-wrapper { padding-left: 0 !important; padding-right: 0 !important; max-width: 100% !important; }

  /* ── Page headers ──────────────────────────────────────────── */
  .main-header {
    flex-wrap: wrap !important;
    gap: 0.5rem;
    padding-top: 0.75rem;
    margin-bottom: 1rem;
  }
  .main-header h1, .main-header h2, .main-header h3 {
    font-size: 1.25rem !important;
  }
  /* Botão Voltar fica abaixo do título no mobile */
  .nexus-btn-voltar { width: 100%; justify-content: center; }

  /* ── KPI cards — empilham em 2 colunas no mobile ───────────── */
  .row.g-3 > .col-md-3,
  .row.g-3 > .col-md-4 { flex: 0 0 50%; max-width: 50%; }
  .row.g-2 > .col-md-3,
  .row.g-2 > .col-md-4 { flex: 0 0 50%; max-width: 50%; }

  /* ── Filter bar — empilha filtros verticalmente ────────────── */
  .nexus-filter-bar { flex-direction: column; align-items: stretch; }
  .nexus-search-pill { max-width: 100% !important; }
  .nexus-dd-btn { width: 100%; justify-content: space-between; }
  .nexus-clear-btn { text-align: center; }
  .nexus-filter-divider { display: none; }

  /* ── Tabelas — scroll horizontal garantido ─────────────────── */
  .table-responsive { -webkit-overflow-scrolling: touch; }
  /* QUALQUER tabela larga dentro do conteúdo vira bloco rolável (não vaza a página).
     Cobre .table (Bootstrap), .table-nexus, .ct-table (Gestão) etc. */
  /* (.ct-table já tem o wrapper .ct-table-wrap com overflow-x:auto — não mexer) */
  #main-content table.table,
  #main-content table.table-nexus,
  .card .card-body > table,
  .card-body > table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

  /* ── Abas (nav-tabs) — rolam em vez de vazar. min-width:0 deixa a UL
        encolher dentro do flex (senão a última aba vaza). ──────────── */
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; min-width: 0; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs .nav-link { white-space: nowrap; }

  /* ── KPIs de valor (dinheiro) ocupam a linha inteira p/ não cortar ── */
  .nexus-kpi.money, .nexus-kpi.kpi-money { grid-column: 1 / -1; }

  /* ── Kanban (board) empilha as colunas no mobile (evita colunas de ~85px) ── */
  .kb-board { grid-template-columns: 1fr !important; }

  /* ── Kanban — colunas empilhadas no mobile ─────────────────── */
  .kanban-column, .kanban-col { min-height: 200px; height: auto !important; margin-bottom: 1rem; }
  #kanbanBoard .col-12 { margin-bottom: 0.75rem; }

  /* ── Busca avançada — sidebar de filtros colapsável ────────── */
  #filtros-sidebar { position: fixed !important; top: 0; left: 0; right: 0; bottom: 0; z-index: 1045; overflow-y: auto; transform: translateX(-100%); transition: transform 0.3s ease; background: #fff; }
  #filtros-sidebar.show { transform: translateX(0); }

  /* ── Sidebar nav ───────────────────────────────────────────── */
  /* A gaveta mobile da sidebar é controlada 100% pelo base.html
     (classe .sidebar-mobile-open + #sidebar-backdrop, breakpoint <992px).
     As regras antigas #sidebar/body.sidebar-open (morta, nenhum JS usava)
     foram removidas por conflitarem via especificidade de ID. */

  /* ── Topbar ────────────────────────────────────────────────── */
  .topbar-guide-link span { display: none !important; }

  /* ── Modais — largura total no mobile ──────────────────────── */
  .modal-dialog { margin: 0.5rem; }
  .modal-dialog.modal-lg, .modal-dialog.modal-xl { max-width: calc(100vw - 1rem) !important; }

  /* ── Cards de edital ───────────────────────────────────────── */
  .edital-card-result .row.g-2 { flex-direction: column; }
  .edital-card-result .col-md-8, .edital-card-result .col-md-4 { width: 100%; }

  /* ── Botões de ação dos cards — viram coluna ───────────────── */
  .action-buttons-column { display: flex; flex-wrap: wrap; gap: 0.35rem; }
  .action-buttons-column .btn, .action-buttons-column form button { width: calc(50% - 0.175rem) !important; }

  /* ── Hub de ferramentas ─────────────────────────────────────── */
  .hub-header { flex-direction: column; align-items: flex-start; }

  /* ── Agenda — botões de tipo enrolam ───────────────────────── */
  .status-filters { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.5rem; }

  /* ── Perfil empresa v2 — tabs ficam scrolláveis ────────────── */
  #editalTabs { overflow-x: auto; flex-wrap: nowrap; }
  #editalTabs .nav-link { white-space: nowrap; }

  /* ── Propostas — header info empilha ───────────────────────── */
  .border-end { border-right: none !important; border-bottom: 1px solid #dee2e6; padding-bottom: 0.75rem; margin-bottom: 0.75rem; }

  /* ── Central de Propostas (visão Lista) — empilha valor+ações ── */
  .prop-row { flex-wrap: wrap; column-gap: 12px; row-gap: 10px; padding: 12px 14px; }
  .prop-right { flex: 1 1 100%; flex-direction: row; align-items: center; justify-content: space-between; text-align: left; }
  .prop-actions { justify-content: flex-start; flex-wrap: wrap; }

  /* ── NexusMap — topbar compacto ─────────────────────────────── */
  #topbar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  #stats-strip { flex-wrap: wrap; font-size: .75rem; }
  .stat-sep { display: none; }
}

@media (max-width: 575px) {
  /* ── KPI cards — 1 coluna em telas muito pequenas ──────────── */
  .row.g-3 > .col-md-3,
  .row.g-3 > .col-md-4 { flex: 0 0 100%; max-width: 100%; }

  /* ── Botões de ação — 1 por linha ──────────────────────────── */
  .action-buttons-column .btn, .action-buttons-column form button { width: 100% !important; }

  /* ── Heading ainda menor ────────────────────────────────────── */
  .main-header h1 { font-size: 1.1rem !important; }
}
