/* ============================================================
   SISTEMA NUVEM — CSS Completo (App Privado)
   ============================================================ */

/* ── VARIÁVEIS ─────────────────────────────────────────────── */
:root {
  --sidebar-w: 240px;
  --topbar-h: 56px;

  --sidebar-bg:     #1a1d23;
  --sidebar-hover:  rgba(255,255,255,.07);
  --sidebar-active: rgba(99,102,241,.2);
  --sidebar-accent: #6366f1;
  --sidebar-text:   rgba(255,255,255,.75);
  --sidebar-label:  rgba(255,255,255,.3);

  --bg:       #f1f3f8;
  --surface:  #ffffff;
  --border:   #e2e6ea;
  --text:     #1a1d23;
  --muted:    #6b7280;
  --shadow:   0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --radius:   .75rem;
  --primary:  #6366f1;
  --primary-d:#4f46e5;
  --trans:    .18s ease;
}

[data-bs-theme="dark"] {
  --bg:      #0f1117;
  --surface: #1a1d23;
  --border:  #2d3139;
  --text:    #e2e8f0;
  --muted:   #94a3b8;
  --shadow:  0 1px 4px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--trans), color var(--trans);
}

/* ── SIDEBAR ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--trans);
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 1.2rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.brand-icon {
  width: 36px; height: 36px;
  background: var(--sidebar-accent);
  border-radius: .5rem;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}
.brand-name { color: #fff; font-weight: 700; font-size: .95rem; line-height: 1.1; }
.brand-sub  { color: var(--sidebar-label); font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; }

/* Nav */
.sidebar-nav { padding: .8rem 0; flex: 1; }

.nav-label {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--sidebar-label);
  padding: .5rem 1.1rem .3rem;
}

.nav-link-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem 1.1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  border-left: 3px solid transparent;
  transition: background var(--trans), color var(--trans), border-color var(--trans);
  position: relative;
}
.nav-link-item i { width: 16px; text-align: center; font-size: .9rem; flex-shrink: 0; }
.nav-link-item span { flex: 1; }
.nav-link-item:hover  { background: var(--sidebar-hover); color: #fff; }
.nav-link-item.active {
  background: var(--sidebar-active);
  color: #fff;
  border-left-color: var(--sidebar-accent);
  font-weight: 600;
}

.nav-badge {
  background: var(--sidebar-accent);
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  border-radius: 9999px;
  padding: .1rem .4rem;
  min-width: 18px;
  text-align: center;
}

/* User footer */
.sidebar-user {
  border-top: 1px solid rgba(255,255,255,.07);
  padding: .7rem .8rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.user-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex: 1;
  text-decoration: none;
  border-radius: .5rem;
  padding: .4rem .5rem;
  transition: background var(--trans);
  min-width: 0;
}
.user-row:hover, .user-row.active { background: var(--sidebar-hover); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--sidebar-accent);
  color: #fff; font-weight: 700; font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name { color: #fff; font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: var(--sidebar-label); font-size: .68rem; text-transform: capitalize; }
.logout-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: .4rem;
  color: rgba(255,100,100,.7);
  text-decoration: none;
  transition: background var(--trans), color var(--trans);
  flex-shrink: 0;
}
.logout-btn:hover { background: rgba(255,80,80,.15); color: #ff6b6b; }

/* OVERLAY mobile */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}

/* ── MAIN WRAPPER ──────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left var(--trans);
}

/* ── TOPBAR ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border);
}
.topbar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 1.1rem; padding: .3rem;
  display: none;
}
.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right {
  display: flex; align-items: center; gap: .5rem;
}
.btn-icon-sm {
  background: none; border: 1px solid var(--border);
  border-radius: .5rem; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer; transition: background var(--trans), color var(--trans);
}
.btn-icon-sm:hover { background: var(--bg); color: var(--text); }

/* ── CONTENT ───────────────────────────────────────────────── */
.content-area {
  flex: 1;
  padding: 1.5rem;
  max-width: 1400px;
  width: 100%;
}

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  font-weight: 600;
}
.card-body { padding: 1.25rem; }
.card-footer { background: transparent; border-top: 1px solid var(--border); padding: .75rem 1.25rem; }

/* ── STAT CARDS ────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
  transition: transform var(--trans);
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: .65rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--muted); margin-top: .2rem; }

/* ── DOCUMENT CARD ─────────────────────────────────────────── */
.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow);
  transition: transform var(--trans), box-shadow var(--trans);
}
.doc-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99,102,241,.15); }

/* ── TIPO BORDER COLORS ────────────────────────────────────── */
.tipo-decreto          { border-left-color: #6366f1 !important; }
.tipo-lei              { border-left-color: #22c55e !important; }
.tipo-portaria         { border-left-color: #f97316 !important; }
.tipo-extrato-de-contrato { border-left-color: #a855f7 !important; }
.tipo-edital           { border-left-color: #ef4444 !important; }
.tipo-licitacao        { border-left-color: #14b8a6 !important; }
.tipo-aviso            { border-left-color: #eab308 !important; }
.tipo-outros           { border-left-color: #94a3b8 !important; }

/* ── TABLE ─────────────────────────────────────────────────── */
.table { color: var(--text); }
.table-hover tbody tr:hover { background: rgba(99,102,241,.04); }
.table thead th { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom-width: 1px; }

/* ── SEARCH BAR ────────────────────────────────────────────── */
.search-bar { position: relative; }
.search-bar .form-control { border-radius: .6rem; padding-left: 2.5rem; height: 40px; }
.search-bar .search-icon { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* ── PAGE HEADER ───────────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-header h1 { font-size: 1.5rem; font-weight: 800; margin: 0; }
.page-header p { color: var(--muted); margin: .2rem 0 0; font-size: .88rem; }

/* ── BADGES ────────────────────────────────────────────────── */
.tag-pill {
  background: rgba(99,102,241,.1); color: var(--primary);
  border: 1px solid rgba(99,102,241,.2);
  border-radius: 9999px; padding: .15rem .55rem;
  font-size: .7rem; font-weight: 600;
}
[data-bs-theme="dark"] .tag-pill { background: rgba(99,102,241,.2); }

/* ── FILE PREVIEW ──────────────────────────────────────────── */
.preview-frame { width: 100%; min-height: 620px; border: none; border-radius: .5rem; }
.file-card { border: 2px dashed var(--border); border-radius: var(--radius); padding: 2rem; text-align: center; transition: border-color var(--trans), background var(--trans); }
.file-card:hover { border-color: var(--primary); background: rgba(99,102,241,.04); }
.file-size { font-size: .75rem; color: var(--muted); }

/* ── FORM SECTIONS ─────────────────────────────────────────── */
.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.form-section-title { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-bottom: .75rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }

/* ── FLASH MESSAGES ────────────────────────────────────────── */
.alert { border-radius: var(--radius); border: none; }

/* ── PAGINATION ────────────────────────────────────────────── */
.pagination .page-link { border-radius: .4rem !important; margin: 0 2px; border-color: var(--border); color: var(--text); background: var(--surface); }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── FILTER CHIP ───────────────────────────────────────────── */
.filter-chip { display: inline-flex; align-items: center; gap: .3rem; background: rgba(99,102,241,.1); color: var(--primary); border-radius: 9999px; padding: .25rem .75rem; font-size: .8rem; font-weight: 500; }

/* ── ANIMATIONS ────────────────────────────────────────────── */
.fade-in { animation: fadeUp .25s ease forwards; }
@keyframes fadeUp { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

/* ── LOGIN PAGE ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a1d23 0%, #0f1117 100%);
  padding: 1.5rem;
}
.login-card {
  background: #1e2128; border: 1px solid rgba(255,255,255,.07);
  border-radius: 1.25rem; width: 100%; max-width: 400px;
  padding: 2.5rem; box-shadow: 0 24px 64px rgba(0,0,0,.5);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .logo-icon {
  width: 64px; height: 64px; background: var(--primary); border-radius: 1rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.8rem; color: #fff; margin-bottom: .75rem;
}
.login-logo h1 { color: #fff; font-size: 1.4rem; font-weight: 800; }
.login-logo p  { color: rgba(255,255,255,.4); font-size: .82rem; }
.login-card .form-label { color: rgba(255,255,255,.7); font-size: .85rem; margin-bottom: .4rem; }
.login-card .form-control {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  color: #fff; border-radius: .6rem;
}
.login-card .form-control:focus {
  background: rgba(255,255,255,.09); border-color: var(--primary);
  color: #fff; box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}
.login-card .form-control::placeholder { color: rgba(255,255,255,.2); }
.login-card .btn-primary { background: var(--primary); border-color: var(--primary); border-radius: .6rem; font-weight: 700; padding: .65rem; width: 100%; }
.login-card .btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-wrapper { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .content-area { padding: 1rem; }
}

@media (max-width: 575.98px) {
  .stat-card { padding: 1rem; }
  .stat-value { font-size: 1.4rem; }
}
