/* ============================================
   LAYOUT - The AI 500 Style
   ============================================ */

/* Brand Detail Panel */
.brand-detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: #ffffff;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 200;
  overflow-y: auto;
  border-left: 1px solid #e5e7eb;
}

.brand-detail-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 10;
}

.brand-detail-logo {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.brand-logo-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(135deg, #d869f7, #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.5rem;
}

.brand-detail-title {
  flex: 1;
}

.brand-detail-title h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #0f172a;
}

.brand-detail-rank {
  font-size: 0.875rem;
  color: #64748b;
  display: block;
  margin-top: 0.25rem;
}

.brand-detail-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.brand-detail-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.brand-detail-content {
  padding: 1.5rem;
  padding-bottom: 0;
  display: flex;
  flex-direction: column;
}

.brand-detail-section {
  margin-bottom: 2rem;
}

.brand-detail-score {
  background: #f8fafc;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.score-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
  position: relative;
}

.score-label {
  font-size: 0.875rem;
  color: #64748b;
  font-weight: 500;
}

.score-value {
  font-size: 2rem;
  font-weight: 700;
  color: #0f172a;
}

.score-change {
  margin-top: 0.5rem;
}

.change-value {
  font-size: 0.875rem;
  color: #64748b;
}

.metrics-hint {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: help;
  transition: all 0.2s ease;
  z-index: 10;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.metrics-hint:hover {
  background: #cbd5e1;
  color: #475569;
}

.hint-icon {
  line-height: 1;
}

.hint-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  width: 280px;
  padding: 0.75rem;
  background: #1f2937;
  color: #f9fafb;
  border-radius: 6px;
  font-size: 0.75rem;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}

.hint-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 12px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #1f2937;
}

.metrics-hint:hover .hint-tooltip {
  opacity: 1;
  visibility: visible;
}

.brand-detail-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1rem;
  position: relative;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.meta-label {
  font-size: 0.75rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.meta-value {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
}

.section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.llm-pills-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.model-visibility-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.model-visibility-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.model-visibility-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.model-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: #0f172a;
}

.model-percentage {
  font-size: 0.875rem;
  font-weight: 600;
  color: #d869f7;
}

.model-visibility-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.model-visibility-fill {
  height: 100%;
  background: linear-gradient(90deg, #d869f7, #a78bfa);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.movement-chart {
  background: #f8fafc;
  border-radius: 8px;
  padding: 1rem;
  height: 120px;
}

.brand-detail-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: auto;
  padding: 1rem 1.5rem;
  margin-left: -1.5rem;
  margin-right: -1.5rem;
  margin-bottom: 0;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
  position: sticky;
  bottom: 0;
  z-index: 10;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.brand-detail-actions .btn {
  flex: 1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 0.75rem;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 6px;
}

.stat-label {
  font-size: 0.875rem;
  color: #64748b;
}

.stat-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
}

.queries-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

/* Ajustar layout cuando el panel está visible */
.main-layout:has(+ .brand-detail-panel[style*="display: block"]) .main-content {
  margin-right: 400px;
}

/* Clickable company cell */
.company-cell.clickable {
  cursor: pointer;
  transition: background-color 0.2s;
  padding: 0.5rem;
  margin: -0.5rem;
  border-radius: 4px;
}

.company-cell.clickable:hover {
  background: #f8fafc;
}

/* Header */
.main-header {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #10b981, #059669);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 1.25rem;
}

.logo-icon {
  height: 40px;
  width: auto;
  flex-shrink: 0;
}

.logo-text h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.2;
}

.logo-text .subtitle {
  font-size: 0.75rem;
  color: #64748b;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-link {
  color: #475569;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.nav-link:hover {
  color: #0f172a;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Ticker */
.ticker-container {
  background: #f8fafc;
  border-top: 1px solid #e5e7eb;
  padding: 0.5rem 0;
  overflow: hidden;
}

.ticker {
  display: flex;
  gap: 2rem;
  animation: ticker-scroll 30s linear infinite;
  white-space: nowrap;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #475569;
}

.ticker-item .brand-name {
  font-weight: 600;
  color: #0f172a;
}

.ticker-item .change {
  font-weight: 600;
}

.ticker-item .change.positive {
  color: #10b981;
}

.ticker-item .change.negative {
  color: #ef4444;
}

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Main Layout */
.main-layout {
  display: flex;
  max-width: 1600px;
  margin: 0 auto;
  min-height: calc(100vh - 120px);
  position: relative;
}

/* Ajustar contenido cuando el panel de detalles está visible */
body:has(.brand-detail-panel[style*="display: block"]) .main-content {
  margin-right: 400px;
  transition: margin-right 0.3s ease;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  padding: 1.5rem;
  overflow-y: auto;
  height: calc(100vh - 120px);
  position: sticky;
  top: 120px;
}

.sidebar-section {
  margin-bottom: 2rem;
}

.sidebar-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #64748b;
  margin-bottom: 0.75rem;
}

.search-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.search-input:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Top Companies */
.top-companies {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.top-company-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  background: #f8fafc;
  border: 1px solid transparent;
}

.top-company-item:hover {
  background: #ffffff;
  border-color: #e5e7eb;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.top-company-item.active {
  background: #ffffff;
  border-color: #d869f7;
  box-shadow: 0 0 0 3px rgba(216, 105, 247, 0.1);
}

.top-company-rank {
  font-weight: 700;
  color: #d869f7;
  font-size: 0.875rem;
  min-width: 30px;
}

.top-company-name {
  font-weight: 600;
  color: #0f172a;
  font-size: 0.875rem;
  flex: 1;
}

.top-company-sector {
  font-size: 0.75rem;
  color: #64748b;
  text-transform: uppercase;
}

/* Filter Buttons */
.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-btn {
  padding: 0.375rem 0.75rem;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  color: #475569;
}

.filter-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.filter-btn.active {
  background: #d869f7;
  color: #ffffff;
  border-color: #d869f7;
}

/* Summary Box */
.summary-box {
  background: #d869f7;
  border-radius: 8px;
  padding: 1rem;
  color: white;
}

.summary-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.summary-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.summary-change {
  font-size: 0.875rem;
  font-weight: 600;
  opacity: 0.9;
}

/* Leaders List */
.leaders-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.leader-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  padding: 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  background: #f8fafc;
  border: 1px solid transparent;
  margin-bottom: 0.5rem;
}

.leader-item:hover {
  background: #ffffff;
  border-color: #e5e7eb;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.leader-item.active {
  background: #ffffff;
  border-color: #d869f7;
  box-shadow: 0 0 0 3px rgba(216, 105, 247, 0.1);
}

.leader-name {
  font-weight: 600;
  color: #0f172a;
}

.leader-change {
  font-weight: 600;
  font-size: 0.75rem;
}

.leader-change.positive {
  color: #d869f7;
}

.leader-change.negative {
  color: #ef4444;
}

.leader-change.neutral {
  color: #64748b;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 2rem;
  background: #f8fafc;
}

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

.content-title {
  font-size: 0.875rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.last-extraction-info {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 400;
  margin-bottom: 1.25rem;
  padding: 0;
  margin-top: 0;
  line-height: 1.2;
}

.last-extraction-info span {
  color: #64748b;
  font-weight: 500;
}

.sort-select {
  padding: 0.5rem 0.875rem;
  border-radius: 9999px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: #475569;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem 1rem;
  padding-right: 2.25rem;
  transition: all 0.2s ease;
}

.content-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.select-small {
  padding: 0.5rem 0.875rem;
  border-radius: 9999px;
  border: 1px solid #e5e7eb;
  font-size: 0.85rem;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem 1rem;
  padding-right: 2.25rem;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sort-select:hover,
.select-small:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.sort-select:focus,
.select-small:focus {
  outline: none;
  border-color: #d869f7;
  box-shadow: 0 0 0 2px rgba(216, 105, 247, 0.25);
}

/* Table */
.table-wrapper {
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}

.rankings-table {
  width: 100%;
  border-collapse: collapse;
}

.rankings-table thead {
  background: #f8fafc;
  border-bottom: 2px solid #e5e7eb;
}

.rankings-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.rankings-table td {
  padding: 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
}

.rankings-table tbody tr {
  transition: background 0.2s;
  cursor: pointer;
}

.rankings-table tbody tr:hover {
  background: #f8fafc;
}

/* Company Column */
.company-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.brand-favicon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
  display: block;
}

.brand-favicon-placeholder {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: #e5e7eb;
  flex-shrink: 0;
}

.company-rank {
  font-weight: 700;
  color: #64748b;
  font-size: 0.875rem;
  min-width: 40px;
}

.company-rank-change {
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.25rem;
}

.company-rank-change.up {
  color: #10b981;
}

.company-rank-change.down {
  color: #ef4444;
}

.company-info {
  flex: 1;
}

.company-name {
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.company-meta {
  font-size: 0.75rem;
  color: #64748b;
}

/* Visibility Score */
.visibility-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.visibility-score {
  font-weight: 700;
  color: #0f172a;
  min-width: 50px;
}

.visibility-rank {
  font-size: 0.75rem;
  color: #64748b;
}

/* 24H Change */
.change-24h {
  font-weight: 600;
  font-size: 0.875rem;
}

.change-24h.positive {
  color: #10b981;
}

.change-24h.negative {
  color: #ef4444;
}

.change-24h.neutral {
  color: #64748b;
}

/* 7D Chart */
.chart-7d {
  width: 80px;
  height: 30px;
  position: relative;
}

/* Models */
.models-cell {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
}

.mentions-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.mentions-value {
  font-weight: 700;
  color: #0f172a;
}

.countries-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.country-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: #f8fafc;
  border-radius: 4px;
  font-size: 0.75rem;
}

.country-flag {
  font-size: 1rem;
  line-height: 1;
}

.country-code {
  font-weight: 500;
  color: #475569;
  font-size: 0.75rem;
}

.model-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d869f7;
}

.llm-logo {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease;
  cursor: pointer;
  flex-shrink: 0;
}

.llm-logo:hover {
  border-color: #d869f7;
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(216, 105, 247, 0.3);
}

/* Table Footer */
.table-footer {
  margin-top: 1rem;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.footer-stats {
  display: flex;
  gap: 2rem;
  font-size: 0.875rem;
  color: #64748b;
}

.footer-stats strong {
  color: #0f172a;
  font-weight: 700;
}

/* Responsive */
@media (max-width: 1024px) {
  .main-layout {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
  }
  
  .header-nav {
    display: none;
  }
}

