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

:root {
  --bg-primary: #080813;
  --bg-secondary: #0f1026;
  --bg-card: rgba(18, 20, 50, 0.4);
  --border-glass: rgba(255, 255, 255, 0.06);
  --border-glass-focus: rgba(0, 212, 255, 0.4);
  
  --accent-cyan: #00d4ff;
  --accent-violet: #7c3aed;
  --accent-cyan-rgb: 0, 212, 255;
  
  --text-primary: #f1f3f9;
  --text-secondary: #9aa0c0;
  --text-muted: #565f89;
  
  --positive: #00e676;
  --negative: #ff5252;
  --neutral: #ffc107;
  
  --positive-bg: rgba(0, 230, 118, 0.1);
  --negative-bg: rgba(255, 82, 82, 0.1);
  --neutral-bg: rgba(255, 193, 7, 0.1);
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(124, 58, 237, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(0, 212, 255, 0.04) 0%, transparent 45%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-card);
  border-radius: 4px;
  border: 1px solid var(--border-glass);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

/* Glassmorphism utility */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.25);
  transition: var(--transition-smooth);
}

.glass-panel:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

/* Header */
header {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

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

.brand-logo {
  font-size: 1.85rem;
  font-weight: 800;
  font-family: 'Outfit', sans-serif;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-violet) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.brand-tag {
  background: var(--border-glass);
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid var(--border-glass);
}

.last-update {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  background: rgba(0, 212, 255, 0.05);
  border: 1px solid rgba(0, 212, 255, 0.15);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  color: var(--accent-cyan);
}

.last-update::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

.disclaimer {
  font-size: 0.775rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.015);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border-left: 3px solid var(--accent-violet);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.disclaimer a {
  color: var(--accent-cyan);
  text-decoration: none;
}
.disclaimer a:hover {
  text-decoration: underline;
}

/* Control Bar */
.control-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.kpi-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.825rem;
}

.kpi-badge-icon {
  font-size: 0.95rem;
}

.kpi-badge-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.kpi-badge-value {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--accent-cyan);
}

.input-wrapper {
  position: relative;
}

.search-input {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  padding: 0.45rem 1rem;
  padding-left: 2.25rem;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.875rem;
  width: 250px;
  outline: none;
  transition: var(--transition-smooth);
}

.search-input:focus {
  border-color: var(--border-glass-focus);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.15);
}

.search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
  width: 14px;
  height: 14px;
}

.select-custom {
  appearance: none;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  padding: 0.45rem 2.25rem 0.45rem 0.85rem;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239aa0c0'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}

.select-custom:focus {
  border-color: var(--border-glass-focus);
  background-color: rgba(255, 255, 255, 0.06);
}

.select-custom option {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-compare {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.1) 0%, rgba(124, 58, 237, 0.1) 100%);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  padding: 0.45rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition-smooth);
}

.btn-compare:hover {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.2) 0%, rgba(124, 58, 237, 0.2) 100%);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.15);
}

.btn-compare.active {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-violet) 100%);
  border-color: transparent;
  color: #080813;
}

/* KPI Cards Grid */
.kpis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.kpi-card {
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-radius: 12px;
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  color: var(--accent-cyan);
}

.kpi-card:nth-child(2) .kpi-icon { color: var(--positive); }
.kpi-card:nth-child(3) .kpi-icon { color: var(--accent-violet); }
.kpi-card:nth-child(4) .kpi-icon { color: var(--neutral); }

.kpi-info {
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 0.725rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-value {
  font-size: 1.35rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  margin-top: 0.05rem;
}

/* Table Container & Table */
.table-section {
  margin-bottom: 2rem;
  overflow: hidden;
  border-radius: 12px;
}

.table-wrapper {
  overflow-x: auto;
  width: 100%;
}

.stock-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.stock-table th, 
.stock-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border-glass);
  white-space: nowrap;
}

.stock-table th {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.015);
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: var(--transition-smooth);
}

.stock-table th:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.stock-table th .sort-indicator {
  display: inline-block;
  margin-left: 0.2rem;
  font-size: 0.7rem;
  opacity: 0.5;
  transition: var(--transition-smooth);
}

.stock-table th.active-sort {
  color: var(--accent-cyan);
}
.stock-table th.active-sort .sort-indicator {
  opacity: 1;
}

.stock-table tbody tr {
  transition: var(--transition-smooth);
}

.stock-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
  box-shadow: inset 3px 0 0 var(--accent-cyan);
}

.stock-table td.ticker-cell {
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.5px;
}

/* Color codes */
.val-excellent {
  color: var(--positive);
  font-weight: 600;
}
.val-good {
  color: #b9f6ca;
}
.val-neutral {
  color: var(--text-primary);
}
.val-warning {
  color: #ffe082;
}
.val-bad {
  color: var(--negative);
  font-weight: 600;
}

/* Badges */
.badge-trend {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.725rem;
  font-weight: 700;
  text-align: center;
}

.trend-up {
  background: var(--positive-bg);
  color: var(--positive);
}

.trend-down {
  background: var(--negative-bg);
  color: var(--negative);
}

.trend-mixed {
  background: var(--neutral-bg);
  color: var(--neutral);
}

/* Comparison section container */
.compare-container {
  display: none;
  margin-bottom: 1.25rem;
  animation: fadeIn 0.4s ease-out;
}

.compare-container.active {
  display: block;
}

.compare-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-glass);
}

.compare-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-violet) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.compare-selectors {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.compare-vs {
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.compare-grid {
  padding: 0.75rem 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.compare-summary-card {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
}

.compare-list-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
}

.compare-ticker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.compare-ticker-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.75rem;
  font-family: 'Outfit', sans-serif;
}

.compare-ticker-badge.in {
  background: var(--positive-bg);
  color: var(--positive);
  border: 1px solid rgba(0, 230, 118, 0.15);
}

.compare-ticker-badge.out {
  background: var(--negative-bg);
  color: var(--negative);
  border: 1px solid rgba(255, 82, 82, 0.15);
}

/* Mini Sparkline Canvas */
.sparkline-canvas {
  vertical-align: middle;
  margin-left: 0.35rem;
}

/* Loading skeleton */
.skeleton-row td {
  padding: 0.6rem 0.85rem;
}

.skeleton-text {
  height: 12px;
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 3px;
}

.skeleton-text.ticker { width: 50px; }
.skeleton-text.number { width: 35px; }

/* Delta styling */
.delta-val {
  font-size: 0.65rem;
  display: block;
  font-weight: 500;
  margin-top: 0.1rem;
}
.delta-up {
  color: var(--negative); /* Preço subiu = ruim para comprar */
}
.delta-down {
  color: var(--positive); /* Preço caiu = bom para comprar */
}
.delta-positive-indicator-up {
  color: var(--positive); /* Yield subiu = bom */
}
.delta-positive-indicator-down {
  color: var(--negative); /* Yield caiu = ruim */
}

/* Footer */
footer {
  margin-top: 2.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border-glass);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.775rem;
}

footer a {
  color: var(--accent-cyan);
  text-decoration: none;
}
footer a:hover {
  text-decoration: underline;
}

/* About Section & Book Promo */
.about-section {
  display: grid;
  grid-template-columns: 2fr 1.2fr;
  gap: 1.25rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.about-card, .book-card {
  padding: 1.25rem;
}

.about-title, .book-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--accent-cyan);
}

.about-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.about-warning {
  margin-top: 0.85rem;
  padding: 0.6rem 0.85rem;
  background: rgba(255, 82, 82, 0.04);
  border-left: 3px solid var(--negative);
  border-radius: 6px;
  font-size: 0.775rem;
  color: #ff9999;
  line-height: 1.5;
}

.book-promo {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  text-align: left;
}

.book-image {
  max-width: 100px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: var(--transition-smooth);
}

.book-image:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 16px rgba(0, 212, 255, 0.2);
}

.book-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.book-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.book-btn {
  display: inline-block;
  align-self: flex-start;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-violet) 100%);
  color: #080813;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  font-size: 0.775rem;
  font-weight: 700;
  text-decoration: none;
  transition: var(--transition-smooth);
}

.book-btn:hover {
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.4);
  transform: translateY(-1px);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes loading {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .control-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-input {
    width: 100%;
  }
  
  .kpis-grid {
    grid-template-columns: 1fr;
  }
  
  .compare-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .compare-selectors {
    width: 100%;
    justify-content: space-between;
  }
  
  .about-section {
    grid-template-columns: 1fr;
  }
  
  .book-promo {
    flex-direction: row;
    align-items: flex-start;
  }
}
