/* Table-specific styling for Elpristabellen Dark Theme */

/* Region Selection Buttons */
.region-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding: 20px;
  background: var(--bg-elevated);
  border-radius: 12px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.region-buttons strong {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.025em;
}

.region-button {
  padding: 10px 20px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.025em;
}

.region-button:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.region-button[style*="background-color:#0056b3"],
.region-button.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary)) !important;
  border-color: transparent !important;
  color: white !important;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Table Styling */
#priceTable {
  width: 100%;
  min-width: 1000px; /* Ensure table is wide enough for content and ads */
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-elevated);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
}

#priceTable thead {
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-elevated) 100%);
  position: sticky;
  top: 72px;
  z-index: 10;
}

#priceTable th {
  padding: 16px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  user-select: none;
  border-bottom: 2px solid var(--border-color);
  position: relative;
  transition: all 0.2s ease;
}

#priceTable th:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-primary);
}

/* Sort icons */
.sort-icons {
  display: inline-flex;
  flex-direction: column;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 0.5;
  font-size: 10px;
  opacity: 0.3;
}

.sort-icons .up,
.sort-icons .down {
  color: var(--text-muted);
  transition: color 0.2s;
}

#priceTable th.sorted-asc .sort-icons {
  opacity: 1;
}

#priceTable th.sorted-asc .sort-icons .up {
  color: var(--accent-primary);
}

#priceTable th.sorted-desc .sort-icons {
  opacity: 1;
}

#priceTable th.sorted-desc .sort-icons .down {
  color: var(--accent-primary);
}

#priceTable tbody tr {
  transition: all 0.2s ease;
  border-bottom: 1px solid var(--border-light);
}

#priceTable tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
  transform: scale(1.01);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#priceTable tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

#priceTable tbody tr:nth-child(even):hover {
  background: rgba(59, 130, 246, 0.05);
}

#priceTable td {
  padding: 14px 12px;
  color: var(--text-secondary);
  font-size: 14px;
  vertical-align: middle;
}

#priceTable td:first-child {
  font-weight: 600;
  color: var(--text-primary);
}

/* Table Links */
#priceTable a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#priceTable a:hover {
  color: var(--accent-primary-hover);
  text-decoration: underline;
}

#priceTable a:after {
  content: '↗';
  font-size: 12px;
  opacity: 0.7;
}

/* Price Highlighting */
#priceTable td[style*="color: green"],
#priceTable td.price-good {
  color: var(--success) !important;
  font-weight: 600;
}

#priceTable td[style*="color: red"],
#priceTable td.price-high {
  color: var(--danger) !important;
  font-weight: 600;
}

#priceTable td[style*="color: orange"],
#priceTable td.price-medium {
  color: var(--warning) !important;
  font-weight: 600;
}

/* Trust Score Icons */
#priceTable img[alt*="Svarta"],
#priceTable img[title*="Svarta"] {
  filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.5));
}

#priceTable img[alt*="Schysst"],
#priceTable img[title*="Schysst"] {
  filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.5));
}

#priceTable img[alt*="Neutral"],
#priceTable img[title*="Neutral"] {
  opacity: 0.7;
}

/* In-table Ad Rows */
#priceTable .table-ad-row {
  background: var(--bg-tertiary) !important;
  border-top: 2px solid var(--border-color);
  border-bottom: 2px solid var(--border-color);
}

#priceTable .table-ad-row:hover {
  transform: none;
  box-shadow: none;
}

#priceTable .table-ad-row td {
  padding: 20px 16px;
}

.table-ad-grid {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap; /* Prevent wrapping - keep ads in one row */
  min-width: 932px; /* Minimum width to fit 3 ads (300*3 + 16*2) */
}

.table-ad-grid .ad-slot {
  width: 300px;
  height: 100px;
  flex-shrink: 0;
}

/* Allow wrapping on smaller screens */
@media (max-width: 1000px) {
  .table-ad-grid {
    flex-wrap: wrap;
    min-width: auto;
  }
}

/* Loading State */
.table-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.table-loading:before {
  content: '';
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty State */
.table-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 16px;
}

.table-empty:before {
  content: '📊';
  display: block;
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Responsive Table */
@media (max-width: 1200px) {
  #priceTable {
    font-size: 13px;
  }

  #priceTable th,
  #priceTable td {
    padding: 12px 8px;
  }
}

@media (max-width: 960px) {
  #priceTable {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #priceTable thead {
    position: static;
  }
}

@media (max-width: 640px) {
  .region-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .region-button {
    width: 100%;
    text-align: center;
  }

  #priceTable th,
  #priceTable td {
    padding: 10px 6px;
    font-size: 12px;
  }
}
