/*
 * CATALOGO DNCP - Estilos Limpios, Modernos e Institucionales
 * Tema: Gobierno del Paraguay (Light & Dark Mode Support)
 */

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

:root {
  /* Colores Institucionales DNCP / Gobierno */
  --brand-primary: #0b3155;     /* Azul institucional oscuro DNCP */
  --brand-secondary: #0056b3;   /* Azul medio vibrante */
  --accent: #0ea5e9;            /* Celeste claro para interacciones/links */
  --accent-hover: #0284c7;

  /* Modo Claro (Por Defecto) */
  --bg-body: #f0f4f8;           /* Gris azulado muy suave */
  --bg-card: #ffffff;           /* Blanco puro para tarjetas */
  --bg-header: #0b3155;         /* Header institucional (azul oscuro) */
  --bg-hover: #f1f5f9;          /* Hover suave */
  --bg-lighter: #f8fafc;
  --border: #e2e8f0;

  --text-primary: #1e293b;      /* Gris oscuro para buena lectura */
  --text-secondary: #475569;    /* Textos secundarios */
  --text-muted: #64748b;        /* Textos apagados / notas */

  /* Colores de estado / valores */
  --yellow: #f59e0b;
  --green: #10b981;             
  --green-bg: #dcfce7;
  --green-text: #166534;
  --red: #ef4444;

  /* Geometría y Sombras (Clean & Modern) */
  --radius: 16px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 15px rgba(14, 165, 233, 0.4);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modo Oscuro */
body.dark-theme {
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --bg-header: #0b1120;
  --bg-hover: #334155;
  --bg-lighter: #0f172a;
  --border: #334155;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --brand-primary: #38bdf8;
  --brand-secondary: #7dd3fc;
  
  --green-bg: rgba(16, 185, 129, 0.15);
  --green-text: #34d399;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s, color 0.3s;
}

a {
  color: var(--brand-secondary);
  text-decoration: none;
  transition: var(--transition);
}
a:hover {
  text-decoration: underline;
}

/* ============================================================
   BOTONES
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}
.btn-accent:hover {
  background: var(--brand-secondary);
  color: #ffffff;
  border-color: var(--brand-secondary);
  box-shadow: var(--shadow-glow);
}

body.dark-theme .btn-accent {
  background: #0284c7;
  color: #fff;
  border-color: #0284c7;
}
body.dark-theme .btn-accent:hover {
  background: #0369a1;
}

.btn-green {
  background: var(--green-bg);
  color: var(--green-text);
  border-color: transparent;
}
.btn-green:hover {
  filter: brightness(0.95);
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
}
body.dark-theme .btn-green:hover { filter: brightness(1.2); }

.back-btn {
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 16px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.back-btn:hover {
  color: var(--brand-primary);
  background: var(--bg-hover);
  transform: translateX(-4px);
}

/* ============================================================
   HEADER
============================================================ */
.header {
  background: var(--bg-header);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none !important;
}
.header-logo-icon {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.header-logo-title {
  color: #ffffff;
  font-weight: 700;
  font-size: 16px;
}
.header-logo-sub {
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.theme-toggle {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  margin-left: auto;
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.2);
  transform: rotate(15deg);
}

.header-divider { width: 1px; height: 24px; background: rgba(255, 255, 255, 0.15); margin: 0 24px; }
.header-badge { display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.15); padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; color: #ffffff; }
.pulse-dot { width: 8px; height: 8px; background: #10b981; border-radius: 50%; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); animation: pulse 2s infinite; }
@keyframes pulse { 0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); } 70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); } 100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }

/* ============================================================
   HERO SECTION (Dinámico)
============================================================ */
.hero {
  /* Fondo moderno con gradiente radial */
  background: radial-gradient(circle at top right, rgba(14, 165, 233, 0.1), transparent 40%),
              radial-gradient(circle at bottom left, rgba(11, 49, 85, 0.05), transparent 40%);
  background-color: var(--bg-card);
  padding: 60px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

body.dark-theme .hero {
  background: radial-gradient(circle at top right, rgba(14, 165, 233, 0.15), transparent 40%),
              radial-gradient(circle at bottom left, rgba(30, 41, 59, 0.8), transparent 40%);
  background-color: var(--bg-card);
}

.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%230b3155' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  z-index: 0;
}
body.dark-theme .hero::before { opacity: 0.2; }

.hero-content { position: relative; z-index: 1; }
.hero h1 { font-size: 42px; font-weight: 800; color: var(--text-primary); line-height: 1.1; margin-bottom: 16px; letter-spacing: -0.03em; }
.hero p { color: var(--text-secondary); font-size: 18px; max-width: 650px; margin: 0 auto 32px auto; }

/* Buscador Global Moderno */
.global-search-hero .search-wrapper {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-lg) !important;
  border-radius: 50px !important;
  padding: 8px 12px !important;
  transition: var(--transition);
}
.global-search-hero .search-wrapper:focus-within {
  border-color: var(--accent) !important;
  box-shadow: var(--shadow-glow) !important;
  transform: translateY(-2px);
}
.global-search-hero input {
  font-size: 16px !important;
  color: var(--text-primary) !important;
}
.global-search-hero input::placeholder { color: var(--text-muted); }

.hero-stats { display: flex; align-items: center; justify-content: center; gap: 32px; margin-top: 40px; position: relative; z-index: 1; }
.hero-stat { display: flex; flex-direction: column; }
.hero-stat-num { font-size: 28px; font-weight: 800; color: var(--brand-primary); }
.hero-stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.hero-divider { width: 1px; height: 30px; background: var(--border); }

/* ============================================================
   MAIN LAYOUT & CARDS
============================================================ */
.main-container {
  display: flex;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
  gap: 32px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-hover);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
}

.card-body { padding: 20px; }

/* Search Inputs in toolbars */
.search-wrapper { position: relative; width: 100%; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--text-muted); }
.search-input, .toolbar-search input {
  width: 100%; padding: 10px 10px 10px 36px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font-family: inherit; font-size: 13px; outline: none; transition: var(--transition);
}
.search-input:focus, .toolbar-search input:focus { border-color: var(--brand-secondary); box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.1); }
.toolbar { display: flex; gap: 12px; align-items: center; }
.toolbar-search { flex: 1; position: relative; }

/* ============================================================
   GRILLA DE OBJETOS DE GASTO
============================================================ */
.og-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.og-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}
.og-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}
.og-card-top { display: flex; justify-content: space-between; margin-bottom: 12px; }
.og-code {
  font-family: monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-primary);
  background: var(--bg-hover);
  padding: 4px 8px;
  border-radius: 6px;
}
.og-desc { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.og-note { font-size: 12px; color: var(--text-muted); margin-top: auto; padding-bottom: 16px; }

.og-footer { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-end; }
.og-price-label { display: block; font-size: 11px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; text-transform: uppercase; }
.og-price { font-size: 16px; font-weight: 700; color: var(--green); }
.og-action-btn { font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 6px; transition: var(--transition); background: var(--bg-hover); color: var(--brand-primary); }
.og-card:hover .og-action-btn { background: var(--brand-primary); color: #fff; }

/* ============================================================
   DETALLES Y TABLAS
============================================================ */
.results-header { display: flex; justify-content: space-between; align-items: flex-end; }
.results-title { display: flex; align-items: center; gap: 16px; font-size: 20px; font-weight: 700; color: var(--text-primary); }
.results-title-icon { width: 48px; height: 48px; background: var(--bg-hover); border: 1px solid var(--border); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; box-shadow: var(--shadow-sm); }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.breadcrumb-item.active { color: var(--brand-secondary); }
.results-count { font-size: 13px; font-weight: 600; color: var(--text-secondary); background: var(--bg-card); padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border); }

.og-detail-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.og-detail-chip { background: var(--bg-hover); border: 1px solid var(--border); padding: 12px 16px; border-radius: var(--radius-sm); }
.og-detail-chip-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; margin-bottom: 4px; }
.og-detail-chip-value { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.og-detail-chip-value.accent { color: var(--brand-secondary); }

/* TABLA DE PRODUCTOS (CON GRÁFICOS VISUALES) */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th {
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
tbody tr { transition: var(--transition); }
tbody tr:hover { background: var(--bg-hover); }

/* Badges de Confianza */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 12px;
}
.badge-high { background: rgba(16, 185, 129, 0.1); color: var(--green); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-medium { background: rgba(245, 158, 11, 0.1); color: var(--yellow); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-low { background: rgba(100, 116, 139, 0.1); color: var(--text-muted); border: 1px solid rgba(100, 116, 139, 0.2); }

/* Barra de Precio (Visual Data) */
.price-bar-container {
  width: 100px;
  height: 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 3px;
  position: relative;
  margin-top: 6px;
  overflow: hidden;
}
.price-bar-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  background: var(--green);
  border-radius: 3px;
}
.price-marker {
  position: absolute;
  top: -2px; bottom: -2px;
  width: 4px;
  background: var(--brand-primary);
  border-radius: 2px;
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
}

.td-code { font-family: monospace; font-weight: 700; color: var(--text-secondary); background: var(--bg-hover); padding: 4px 8px; border-radius: 6px; }
.td-desc { font-weight: 600; color: var(--text-primary); }
.td-price { font-weight: 800; color: var(--green); font-size: 15px; }
.td-price.na { color: var(--text-muted); font-weight: 500; font-size: 13px; }
.td-link { font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 4px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary); }
.td-link:hover { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); text-decoration: none; }

.tag { display: inline-flex; align-items: center; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; }
.tag-green { background: var(--green-bg); color: var(--green-text); border: 1px solid rgba(16, 185, 129, 0.3); }
.tag-blue { background: rgba(14, 165, 233, 0.1); color: var(--accent); border: 1px solid rgba(14, 165, 233, 0.3); }

/* ============================================================
   SIDEBAR (CORREGIDO)
============================================================ */
.sidebar { width: 320px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }
.group-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.group-item { display: flex; flex-direction: column; }
.group-btn {
  display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary);
  font-weight: 600; width: 100%; text-align: left; cursor: pointer; transition: var(--transition);
}
.group-btn:hover { background: var(--bg-hover); border-color: var(--text-muted); }
.group-item.active .group-btn {
  background: rgba(14, 165, 233, 0.1); border-color: var(--accent); color: var(--accent);
}
.group-icon { font-size: 16px; }
.group-code-badge { background: var(--bg-hover); color: var(--text-secondary); font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; font-family: monospace; }
.group-item.active .group-code-badge { background: var(--accent); color: #ffffff; }
.group-count { font-size: 11px; color: var(--text-muted); background: var(--bg-hover); padding: 2px 6px; border-radius: 10px; font-weight: 600; }

.subgroup-list { display: none; flex-direction: column; gap: 4px; margin-left: 20px; margin-top: 8px; padding-left: 12px; border-left: 1px solid var(--border); }
.subgroup-list.open { display: flex; }
.subgroup-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 12px; color: var(--text-secondary); border-radius: 6px; cursor: pointer; transition: var(--transition); }
.subgroup-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.subgroup-item.active { background: rgba(14, 165, 233, 0.1); color: var(--accent); font-weight: 600; }
.subgroup-code { font-family: monospace; font-size: 11px; color: var(--text-muted); }

/* ============================================================
   ESTADOS VACÍOS Y EXTRAS
============================================================ */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 48px; opacity: 0.5; margin-bottom: 16px; }
.empty-title { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.empty-sub { font-size: 14px; color: var(--text-secondary); max-width: 400px; margin: 0 auto; }

.welcome-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 20px 0; }
.welcome-icon-wrapper { width: 64px; height: 64px; background: rgba(14, 165, 233, 0.1); border: 1px solid rgba(14, 165, 233, 0.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 32px; margin-bottom: 24px; color: var(--accent); }
.welcome-title { font-size: 24px; font-weight: 800; color: var(--text-primary); margin-bottom: 12px; }
.welcome-sub { font-size: 15px; color: var(--text-secondary); max-width: 500px; margin-bottom: 32px; }

.fade-in { animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Footer */
.footer { text-align: center; padding: 32px 24px; border-top: 1px solid var(--border); background: var(--bg-card); color: var(--text-muted); font-size: 12px; line-height: 1.6; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
