/* =============================================
   InfoBancos — Design System (Light Theme)
   ============================================= */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---- CSS Custom Properties ---- */
:root {
  /* Colors */
  --color-bg: #f5f7fa;
  --color-bg-alt: #edf0f5;
  --color-surface: #ffffff;
  --color-surface-hover: #f8fafc;
  --color-primary: #0d6efd;
  --color-primary-dark: #0a58ca;
  --color-primary-light: #e7f1ff;
  --color-secondary: #198754;
  --color-secondary-light: #d1e7dd;
  --color-accent: #6f42c1;
  --color-danger: #dc3545;
  --color-danger-light: #f8d7da;
  --color-warning: #ffc107;
  --color-warning-light: #fff3cd;
  --color-text: #1a1a2e;
  --color-text-secondary: #5a6070;
  --color-text-muted: #8b92a5;
  --color-border: #dee2e8;
  --color-border-light: #eef1f6;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-4xl: 2.5rem;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Borders */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.12);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --max-width: 1200px;
  --navbar-height: 64px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-dark);
}

img {
  max-width: 100%;
  height: auto;
}

/* ---- Navbar ---- */
.navbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  height: var(--navbar-height);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.navbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 800;
  font-size: var(--font-size-xl);
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.navbar-brand:hover {
  color: var(--color-primary);
}

.navbar-brand .brand-icon {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  list-style: none;
}

.navbar-links a {
  color: var(--color-text-secondary);
  font-weight: 500;
  font-size: var(--font-size-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.navbar-links a:hover,
.navbar-links a.active {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.navbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: var(--font-size-xl);
  color: var(--color-text);
  cursor: pointer;
  padding: var(--space-sm);
}

/* ---- Hero ---- */
.hero {
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 50%, #084298 100%);
  color: white;
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
  position: relative;
  z-index: 10;
}

.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='%23ffffff' fill-opacity='0.05'%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");
  opacity: 0.5;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 700px;
  margin: 0 auto;
}

.hero h1 {
  font-size: var(--font-size-4xl);
  font-weight: 800;
  margin-bottom: var(--space-md);
  letter-spacing: -1px;
  line-height: 1.2;
}

.hero p {
  font-size: var(--font-size-lg);
  opacity: 0.9;
  margin-bottom: var(--space-xl);
  max-width: 550px;
  margin-left: auto;
  margin-right: auto;
}

/* ---- Search ---- */
.search-container {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  padding-left: 48px;
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  border: 2px solid transparent;
  border-radius: var(--radius-full);
  background: white;
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-base);
  outline: none;
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-xl), 0 0 0 4px rgba(13, 110, 253, 0.15);
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: var(--font-size-lg);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 50;
}

.search-results.active {
  display: block;
  animation: slideDown 0.2s ease;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--color-border-light);
  text-decoration: none;
  color: var(--color-text);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--color-primary-light);
  color: var(--color-text);
}

.search-result-item .result-name {
  font-weight: 600;
  font-size: var(--font-size-sm);
}

.search-result-item .result-type {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* ---- Container ---- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

/* ---- Section ---- */
.section-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-lg);
  letter-spacing: -0.5px;
}

.section-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: calc(-1 * var(--space-md));
  margin-bottom: var(--space-xl);
}

/* ---- Cards Grid ---- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: all var(--transition-base);
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
  display: block;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
  color: var(--color-text);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.card-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.card-badge {
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  white-space: nowrap;
}

.card-badge.green {
  background: var(--color-secondary-light);
  color: var(--color-secondary);
}

.card-badge.red {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.card-metric {
  margin-bottom: var(--space-sm);
}

.card-metric-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.card-metric-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.card-footer {
  display: flex;
  gap: var(--space-lg);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border-light);
}

.card-footer-item {
  text-align: center;
  flex: 1;
}

.card-footer-item .label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  display: block;
}

.card-footer-item .value {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

/* ---- Quick Links ---- */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}

.quick-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text);
  transition: all var(--transition-base);
}

.quick-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
  color: var(--color-text);
}

.quick-link .ql-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xl);
  flex-shrink: 0;
}

.quick-link .ql-icon.blue {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.quick-link .ql-icon.green {
  background: var(--color-secondary-light);
  color: var(--color-secondary);
}

.quick-link .ql-icon.purple {
  background: #f3e8ff;
  color: var(--color-accent);
}

.quick-link .ql-text h3 {
  font-size: var(--font-size-base);
  font-weight: 600;
  margin-bottom: 2px;
}

.quick-link .ql-text p {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ---- Table ---- */
.table-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrapper td {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--color-border-light);
  /* Permitir quebra de texto nas colunas maiores para caber na tela */
  white-space: normal;
  vertical-align: middle;
}

.table-wrapper th {
  background: var(--color-bg);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--color-border);
}

.table-wrapper tr:last-child td {
  border-bottom: none;
}

.table-wrapper tr:hover td {
  background: var(--color-surface-hover);
}

.table-wrapper .text-right {
  text-align: right;
  white-space: nowrap;
}

.table-wrapper .text-center {
  text-align: center;
  white-space: nowrap;
}

.table-wrapper .font-bold {
  font-weight: 600;
}

.table-wrapper .text-positive {
  color: var(--color-secondary);
  font-weight: 600;
}

.table-wrapper .text-negative {
  color: var(--color-danger);
  font-weight: 600;
}

.table-wrapper .rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: var(--font-size-xs);
}

.rank-badge.gold {
  background: #fef3c7;
  color: #92400e;
}

.rank-badge.silver {
  background: #e5e7eb;
  color: #4b5563;
}

.rank-badge.bronze {
  background: #fed7aa;
  color: #9a3412;
}

.rank-badge.normal {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  flex-wrap: wrap; /* Envolve as abas sem precisar de scroll na maioria das telas */
  gap: var(--space-xs);
  margin-bottom: var(--space-xl);
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 0;
  /* Removed overflow-x: auto; to prevent ugly scrollbars */
}

.tab-btn {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  margin-bottom: -2px;
}

.tab-btn:hover {
  color: var(--color-primary);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ---- Charts ---- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.chart-card h3 {
  font-size: var(--font-size-base);
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

/* ---- Institution Header ---- */
.inst-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-xl) var(--space-lg);
}

.inst-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  flex-wrap: wrap;
}

.inst-avatar {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--font-size-2xl);
  font-weight: 800;
  flex-shrink: 0;
}

.inst-info h1 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.3;
}

.inst-meta {
  display: flex;
  gap: var(--space-lg);
  margin-top: var(--space-xs);
  flex-wrap: wrap;
}

.inst-meta span {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.inst-meta span strong {
  color: var(--color-text-secondary);
}

/* ---- Summary Cards ---- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.summary-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
}

.summary-card .sc-label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.summary-card .sc-value {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text);
}

.summary-card .sc-value.positive {
  color: var(--color-secondary);
}

.summary-card .sc-value.negative {
  color: var(--color-danger);
}

/* ---- Info / About Page ---- */
.about-content {
  max-width: 800px;
  margin: 0 auto;
}

.about-content h2 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

.about-content p {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  line-height: 1.8;
  margin-bottom: var(--space-md);
}

.about-content ul {
  margin-left: var(--space-lg);
  margin-bottom: var(--space-md);
}

.about-content li {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  line-height: 1.8;
}

.disclaimer {
  background: var(--color-warning-light);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-top: var(--space-xl);
}

.disclaimer h3 {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: #856404;
  margin-bottom: var(--space-sm);
}

.disclaimer p {
  font-size: var(--font-size-sm);
  color: #664d03;
  line-height: 1.6;
}

/* ---- Footer ---- */
.footer {
  margin-top: auto;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-xl) var(--space-lg);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.footer-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.footer-links {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
}

.footer-links a {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.footer-links a:hover {
  color: var(--color-primary);
}

/* ---- Utilities ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.4s ease;
}

/* ---- Loading Skeleton ---- */
.skeleton {
  background: linear-gradient(90deg, var(--color-bg) 25%, var(--color-bg-alt) 50%, var(--color-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .hero h1 {
    font-size: var(--font-size-3xl);
  }

  .hero p {
    font-size: var(--font-size-base);
  }

  .navbar-links {
    display: none;
    position: absolute;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
  }

  .navbar-links.open {
    display: flex;
  }

  .navbar-toggle {
    display: block;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .inst-header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }

  .table-wrapper {
    overflow-x: auto;
  }
}

@media (max-width: 480px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: var(--font-size-2xl);
  }

  .inst-meta {
    flex-direction: column;
    gap: var(--space-xs);
  }
}

/* ---- Table Link Styles ---- */
.table-wrapper a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
}

.table-wrapper a:hover {
  text-decoration: underline;
}

/* ---- No results ---- */
.no-results {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
  color: var(--color-text-muted);
}

.no-results .icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.no-results h3 {
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-sm);
  color: var(--color-text-secondary);
}

/* ---- Back link ---- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
  transition: color var(--transition-fast);
}

.back-link:hover {
  color: var(--color-primary);
}
