/* =========================================================
   PORTAL DE GESTÃO DE PROJETOS E DOCUMENTOS - DESIGN SYSTEM
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Color Palette - Dark Mode Default */
  --bg-main: #0b0f19;
  --bg-surface: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-elevated: #1f293d;
  --bg-glass: rgba(17, 24, 39, 0.65);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --border-glow: rgba(59, 130, 246, 0.3);

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-faint: #6b7280;
  --text-inverse: #0b0f19;

  /* Brand Accents */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.2);
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.2);
  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.2);
  --rose: #f43f5e;
  --rose-glow: rgba(244, 63, 94, 0.2);
  --purple: #8b5cf6;
  --indigo: #6366f1;

  /* Status Colors */
  --status-ged: #10b981;
  --status-ged-bg: rgba(16, 185, 129, 0.15);
  --status-dev: #3b82f6;
  --status-dev-bg: rgba(59, 130, 246, 0.15);
  --status-aprov: #8b5cf6;
  --status-aprov-bg: rgba(139, 92, 246, 0.15);
  --status-desenv: #f59e0b;
  --status-desenv-bg: rgba(245, 158, 11, 0.15);
  --status-atualizar: #06b6d4;
  --status-atualizar-bg: rgba(6, 182, 212, 0.15);
  --status-cancel: #ef4444;
  --status-cancel-bg: rgba(239, 68, 68, 0.15);

  /* Typography & Sizing */
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.2);

  --sidebar-width: 260px;
  --header-height: 70px;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.75);
  --border-subtle: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.14);
  --border-glow: rgba(59, 130, 246, 0.2);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --text-inverse: #ffffff;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 20px -4px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 32px -6px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.12);
}

/* =========================================================
   RESET & BASE STYLES
   ========================================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.06) 0px, transparent 50%);
  background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.25);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(156, 163, 175, 0.45);
}

/* =========================================================
   APP LAYOUT
   ========================================================= */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  transition: transform var(--transition-normal);
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.logo-badge {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: radial-gradient(circle, rgba(6, 182, 212, 0.25) 0%, rgba(15, 23, 42, 0.9) 100%);
  border: 1px solid rgba(6, 182, 212, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.35);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.logo-badge:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.6);
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
}

.logo-badge svg {
  width: 22px;
  height: 22px;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.1;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
[data-theme="light"] .logo-title {
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 1.25rem 0.85rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
}

.nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.5rem 0.75rem 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  text-decoration: none;
  border: 1px solid transparent;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: transform var(--transition-fast);
}

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .nav-item:hover {
  background: rgba(0, 0, 0, 0.03);
}

.nav-item.active {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(6, 182, 212, 0.1));
  border-color: rgba(59, 130, 246, 0.3);
  font-weight: 600;
  box-shadow: 0 4px 15px -3px rgba(59, 130, 246, 0.15);
}

[data-theme="light"] .nav-item.active {
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.2);
}

.nav-badge {
  margin-left: auto;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
}

.nav-item.active .nav-badge {
  background: var(--primary);
  color: #ffffff;
}

.sidebar-footer {
  padding: 1rem 0.85rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quick-stats-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.78rem;
}

/* =========================================================
   MAIN CONTENT AREA
   ========================================================= */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.top-header {
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.page-title-header {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header-search {
  position: relative;
  width: 320px;
}

.header-search input {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.4rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  outline: none;
  transition: all var(--transition-fast);
}

.header-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-surface);
}

.header-search svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-faint);
}

.header-search .search-kbd {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.68rem;
  padding: 0.15rem 0.4rem;
  background: var(--border-subtle);
  border-radius: 4px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Main Body Viewport */
.content-viewport {
  flex: 1;
  padding: 2rem;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
}

.view-section {
  display: none;
  animation: fadeIn 0.25s ease-out forwards;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   FILTER BAR SYSTEM
   ========================================================= */
.filter-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.filter-title {
  font-size: 0.92rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.filter-title svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-select, .filter-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  outline: none;
  transition: all var(--transition-fast);
  width: 100%;
}

.filter-select:focus, .filter-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* =========================================================
   KPI CARDS GRID
   ========================================================= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
}

.kpi-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient, linear-gradient(90deg, var(--primary), var(--cyan)));
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--icon-bg, rgba(59, 130, 246, 0.12));
  color: var(--icon-color, var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon-wrap svg {
  width: 18px;
  height: 18px;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.kpi-footer {
  font-size: 0.75rem;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* KPI Custom Variants */
.kpi-card.ged {
  --accent-gradient: linear-gradient(90deg, #10b981, #059669);
  --icon-bg: rgba(16, 185, 129, 0.12);
  --icon-color: #10b981;
}
.kpi-card.pending {
  --accent-gradient: linear-gradient(90deg, #3b82f6, #06b6d4);
  --icon-bg: rgba(59, 130, 246, 0.12);
  --icon-color: #3b82f6;
}
.kpi-card.demandas {
  --accent-gradient: linear-gradient(90deg, #f59e0b, #d97706);
  --icon-bg: rgba(245, 158, 11, 0.12);
  --icon-color: #f59e0b;
}
.kpi-card.a1 {
  --accent-gradient: linear-gradient(90deg, #8b5cf6, #6366f1);
  --icon-bg: rgba(139, 92, 246, 0.12);
  --icon-color: #8b5cf6;
}

/* =========================================================
   DASHBOARD CHARTS & ANALYTICS LAYOUT
   ========================================================= */
.dashboard-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.dashboard-grid-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.analytics-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.analytics-title {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.analytics-title svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.chart-wrapper {
  position: relative;
  width: 100%;
  min-height: 260px;
}

/* Mini Table inside Dashboard */
.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.mini-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  border-bottom: 1px solid var(--border-subtle);
}

.mini-table th:last-child,
.mini-table td:last-child {
  text-align: right;
}

.mini-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.mini-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.mini-table tr.total-row td {
  font-weight: 700;
  background: var(--bg-elevated);
  border-top: 2px solid var(--border-strong);
}

/* Timeline Matrix Table */
.timeline-table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.timeline-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
}

.timeline-table th {
  background: var(--bg-elevated);
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.74rem;
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
}

.timeline-table th:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg-elevated);
  min-width: 240px;
}

.timeline-table td {
  padding: 0.65rem 0.85rem;
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
}

.timeline-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg-surface);
  font-weight: 600;
}

.timeline-cell-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 0.35rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.78rem;
}

.timeline-cell-count.positive {
  background: var(--status-ged-bg);
  color: var(--status-ged);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.timeline-cell-count.zero {
  color: var(--text-faint);
}

/* =========================================================
   RESPONSIVE DESIGN
   ========================================================= */
@media (max-width: 1200px) {
  .dashboard-grid-2col,
  .dashboard-grid-3col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .top-header {
    padding: 0 1rem;
  }
  .content-viewport {
    padding: 1rem;
  }
}
