/* styles.css */

:root {
  --country-color: #003366;
  --individual-color: #8b008b;
  --company-color: #006400;
  --private-company-color: #8b008b;
  --table-border: #ddd;
  --table-header-bg: #f2f2f2;
  --negative-value-color: #b30000;
  --focus-outline: 3px solid #4d90fe;

  /* Additional variables for v2 */
  --bg-secondary: #f8f9fa;
  --primary-color: #003366;
  --text-secondary: #666;
  --border-color: #ddd;
}

/* Default styles for the entire document */
html {
  box-sizing: border-box;
  scroll-behavior: smooth;
}

*, *:before, *:after {
  box-sizing: inherit;
}

body {
  font-family: Arial, sans-serif;
  background: #fff;
  color: #000;
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

/* Main content container - constrain width */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
}

@media (max-width: 768px) {
  main {
    padding: 1rem;
  }
}

/* Splash screen for PWA/mobile */
@media (display-mode: standalone) {
  .splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--country-color) url('../public/images/social.png') no-repeat center center;
    background-size: cover;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 10vh;
    transition: opacity 0.5s ease-out;
  }
  
  .splash-screen.hidden {
    opacity: 0;
    pointer-events: none;
  }
  
  .splash-screen .app-title {
    font-size: 2rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    font-weight: bold;
  }
}

/* Header styles */
header {
  background-color: var(--country-color);
  color: #fff;
  text-align: center;
  padding: 1rem 1rem;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
}

.header-content h1 {
  margin-bottom: 0.5rem;
  font-size: 2rem;
}

.author-links {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.9);
}

.author-links a {
  color: rgba(255, 255, 255, 0.95);
  text-decoration: underline;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
  text-decoration-color: rgba(255, 255, 255, 0.5);
}

.author-links a:hover {
  color: #fff;
  text-decoration-color: #fff;
}

.author-links a:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
  border-radius: 2px;
}

.bluesky-link {
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.bluesky-link a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  transition: color 0.2s ease;
}

.bluesky-link a:hover {
  color: #fff;
  text-decoration: underline;
}

nav {
  background-color: #00509e;
  padding: 0.5rem;
}

nav ul {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
}

nav a {
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background-color 0.3s;
}

nav a:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

nav a:focus {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.section {
  margin: 2rem auto;
  padding: 1.5rem;
  border: 1px solid var(--table-border);
  border-radius: 8px;
  background-color: #fff;
  /* box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); */
  max-width: 1200px;
}

h2 {
  color: #333;
  border-bottom: 2px solid var(--table-border);
  padding-bottom: 0.5rem;
  margin-top: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.metric-explanation {
  background-color: #f9f9f9;
  border-radius: 6px;
  padding: 1rem;
  /* margin-bottom: 1.5rem; */
  border-left: 4px solid #555;
}

.metric-explanation p {
  margin-top: 0;
  font-weight: 500;
}

.metric-explanation ul {
  margin-bottom: 0;
  padding-left: 1.5rem;
}

.metric-explanation li {
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.metric-explanation .type-indicator {
  margin-right: 0.5rem;
  width: 12px;
  height: 12px;
  display: inline-block;
}

.source-container {
  display: flex;
  gap: 2rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.source {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #555;
}

.source-icon {
  width: 24px;
  height: 24px;
}

.table-container {
  overflow-x: auto;
  margin-bottom: 1rem;
  border-radius: 4px;
  /* border: 1px solid var(--table-border); */
}

.table-container:focus {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  table-layout: fixed;
}

th {
  background-color: var(--table-header-bg);
  border: 1px solid var(--table-border);
  padding: 0.75rem;
  text-align: left;
  position: sticky;
  top: 0;
  font-weight: bold;
}

td {
  border: 1px solid var(--table-border);
  padding: 0.75rem;
  text-align: left;
}

/* Row coloring by entity type - Colorblind-friendly palette */
tr.entity-country {
  background-color: rgba(1, 115, 178, 0.12); /* Blue for countries */
  border-left: 4px solid rgba(1, 115, 178, 0.6);
}

tr.entity-individual {
  background-color: rgba(222, 143, 5, 0.12); /* Orange for individuals */
  border-left: 4px solid rgba(222, 143, 5, 0.6);
}

tr.entity-company {
  background-color: rgba(204, 120, 188, 0.12); /* Purple for companies */
  border-left: 4px solid rgba(204, 120, 188, 0.6);
}

/* Hover states */
tr.entity-country:hover {
  background-color: rgba(1, 115, 178, 0.2);
  border-left-color: rgba(1, 115, 178, 0.8);
}

tr.entity-individual:hover {
  background-color: rgba(222, 143, 5, 0.2);
  border-left-color: rgba(222, 143, 5, 0.8);
}

tr.entity-company:hover {
  background-color: rgba(204, 120, 188, 0.2);
  border-left-color: rgba(204, 120, 188, 0.8);
}

/* Table column widths */
.icon-cell {
  width: 40px;
  text-align: center;
}

.rank-cell {
  width: 60px;
  text-align: center;
}

.name-cell {
  width: 35%;
}

.value-cell {
  width: auto;
}

/* Icon size and appearance */
.icon-cell .fa {
  font-size: 1.2rem;
}

/* Entity type styling */
.country-row {
  background-color: rgba(0, 51, 102, 0.05);
}

.country-row td:first-child {
  border-left: 5px solid var(--country-color);
}

.individual-row {
  background-color: rgba(139, 0, 139, 0.05);
}

.individual-row td {
  background-color: rgba(139, 0, 139, 0.05);
}

.individual-row td:first-child {
  border-left: 5px solid var(--individual-color);
}

.company-row {
  background-color: rgba(0, 100, 0, 0.05);
}

.company-row td {
  background-color: rgba(0, 100, 0, 0.05);
}

.company-row td:first-child {
  border-left: 5px solid var(--company-color);
}

.private-company-row {
  background-color: rgba(139, 0, 139, 0.05);
}

.private-company-row td {
  background-color: rgba(139, 0, 139, 0.05);
}

.private-company-row td:first-child {
  border-left: 5px solid var(--private-company-color);
}

.type-indicator {
  font-size: 0.8rem;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  color: white;
  font-weight: bold;
}

.type-country {
  background-color: var(--country-color);
}

.type-individual {
  background-color: var(--individual-color);
}

.type-company {
  background-color: var(--company-color);
}

.type-private-company {
  background-color: var(--private-company-color);
}

.measure-type {
  font-size: 0.7rem;
  font-weight: bold;
  padding: 2px 4px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
  opacity: 0.8;
  white-space: nowrap;
}

.country-measure {
  color: var(--country-color);
  background-color: rgba(0, 51, 102, 0.1);
}

.individual-measure {
  color: var(--individual-color);
  background-color: rgba(139, 0, 139, 0.1);
}

.company-measure {
  color: var(--company-color);
  background-color: rgba(0, 100, 0, 0.1);
}

.private-company-measure {
  color: var(--private-company-color);
  background-color: rgba(139, 0, 139, 0.1);
}

.negative-value {
  color: var(--negative-value-color);
  font-weight: bold;
}

/* Threshold Note Styling */
.threshold-note {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  border-left: 4px solid var(--country-color);
  padding: 0.75rem 1rem;
  margin: 1.5rem 0;
  display: flex;
  align-items: center;
  border-radius: 4px;
  font-size: 1rem;
}

.threshold-note .note-icon {
  font-size: 1.2rem;
  margin-right: 0.75rem;
  color: var(--country-color);
}

.threshold-text strong {
  font-weight: 600;
  color: var(--country-color);
}

.view-instruction {
  font-size: 0.9rem;
  color: #666;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.note-icon {
  font-size: 1.2rem;
}

footer {
  background-color: var(--country-color);
  color: #fff;
  text-align: center;
  padding: 1.5rem 1rem;
  margin-top: 2rem;
}

footer .badges-row {
  margin: 1.5rem auto 0;
}

footer .bluesky-link {
  margin-top: 0.75rem;
}

footer a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: underline;
  transition: color 0.2s ease;
}

footer a:hover {
  color: #fff;
}

.sources-info {
  margin-top: 1.5rem;
}

.sources-info ul {
  padding-left: 1.5rem;
}

/* High contrast mode support */
@media (forced-colors: active) {
  .type-indicator,
  .country-measure,
  .individual-measure,
  .company-measure,
  .private-company-measure {
    border: 1px solid currentColor;
  }
  
  .type-country,
  .country-row td:first-child {
    border-left: 5px solid currentColor;
  }
  
  .type-individual,
  .individual-row td:first-child {
    border-left: 5px solid currentColor;
  }
  
  .type-company,
  .company-row td:first-child {
    border-left: 5px solid currentColor;
  }
  
  .type-private-company,
  .private-company-row td:first-child {
    border-left: 5px solid currentColor;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .source-container {
    flex-direction: column;
    gap: 1rem;
  }
  
  table {
    font-size: 0.85rem;
  }
  
  th, td {
    padding: 0.5rem;
  }
  
  .measure-type {
    display: block;
    margin-top: 4px;
    margin-left: 0;
  }
}

/* Add styles for the compact card layout */
.info-cards-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto 2rem;
  padding: 0 1rem;
}

.info-card {
  flex: 1;
  min-width: 300px;
  background-color: white;
  border-radius: 8px;
  /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
  padding: 1.25rem;
}

.info-card h2 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  color: #1a1a1a;
}

.compact-list {
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}

.compact-list li {
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.collection-date {
  font-size: 0.875rem;
  color: #6c757d;
  margin-top: 0.5rem;
}

/* Load More Button */
.load-more-container {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
}

.load-more-btn {
  background-color: var(--country-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.load-more-btn:hover {
  background-color: #004c99;
}

.load-more-btn:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

/* Share Button */
.share-button {
  background-color: #4267B2;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  margin-left: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.share-button:hover {
  background-color: #365899;
}

.share-button i {
  font-size: 1.1rem;
}

/* Mobile adjustments for share and load more */
@media (max-width: 640px) {
  .load-more-container {
    flex-direction: column;
    gap: 1rem;
  }
  
  .share-button {
    margin-left: 0;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .info-cards-container {
    flex-direction: column;
  }
  
  .info-card {
    min-width: auto;
  }
}

.filter-icon {
  width: 24px;
  height: 24px;
  margin: 0 6px;
  font-size: 1.2rem;
  text-align: center;
  display: inline-block;
  color: #333;
}

/* Icon colors based on entity type */
.fa-globe {
  color: var(--country-color);
}

.fa-user {
  color: var(--individual-color);
}

.fa-building {
  color: var(--company-color);
}

.fa-building-lock {
  color: var(--private-company-color);
}

.name-cell .fa {
  margin-right: 8px;
  opacity: 0.7;
}
/* Additional styles for v2.0 dynamic data system */
.metadata-section {
    background: #f8f9fa;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.metadata-container h3 {
    margin-top: 0;
    color: var(--country-color);
}

.metadata-container ul {
    list-style: none;
    padding: 0;
}

.metadata-container li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--table-border);
}

.last-updated {
    margin-top: 1rem;
    font-size: 0.9em;
    color: #666;
    text-align: right;
}

.data-warning {
    background: #fff3cd;
    color: #856404;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
    border: 1px solid #ffeaa7;
}

.ticker {
    color: #666;
    font-size: 0.9em;
    margin-left: 0.5rem;
}

.type-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
}

.type-country {
    background: rgba(52, 152, 219, 0.1);
    color: #2980b9;
}

.type-individual {
    background: rgba(39, 174, 96, 0.1);
    color: #27ae60;
}

.type-company {
    background: rgba(155, 89, 182, 0.1);
    color: #8e44ad;
}

.entity-details {
    font-size: 0.9em;
    color: #666;
}

#result-count {
    margin: 1rem 0;
    font-weight: 500;
    color: #666;
}

.filter-section {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin: 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

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

.filter-toggle input[type="checkbox"] {
    cursor: pointer;
}

.filter-toggle label {
    cursor: pointer;
    user-select: none;
}

.controls {
    margin-bottom: 2rem;
}

.search-container {
    position: relative;
    margin: 1rem 0;
}

.search-container input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--table-border);
    border-radius: 4px;
}

.search-container i {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.export-buttons {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.btn-export {
    padding: 0.5rem 1rem;
    background: var(--country-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-export:hover {
    background: #004080;
}

.btn-export i {
    font-size: 1rem;
}

/* Information Section */
.info-section {
  background-color: #f8f9fa;
  padding: 2rem 1rem;
  margin-top: 3rem;
  border-top: 1px solid #dee2e6;
}

.info-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
}

.info-content h2 {
  color: var(--primary-color);
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.8rem;
}

.info-content h3 {
  color: var(--primary-color);
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-size: 1.4rem;
}

.info-content p {
  line-height: 1.8;
  margin-bottom: 1rem;
  color: #333;
}

.info-list {
  list-style: none;
  padding-left: 0;
  margin: 1rem 0;
}

.info-list li {
  padding: 0.75rem 0;
  padding-left: 1.5rem;
  position: relative;
  line-height: 1.6;
}

.info-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--primary-color);
  font-weight: bold;
  font-size: 1.2rem;
}

.info-list a {
  color: #0066cc;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.info-list a:hover {
  border-bottom-color: #0066cc;
}

.update-note {
  background-color: #e7f3ff;
  border-left: 4px solid var(--primary-color);
  padding: 1rem;
  margin-top: 1.5rem;
  border-radius: 4px;
  font-size: 0.95rem;
}

.update-note code {
  background-color: #fff;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  color: #d63384;
}

@media (max-width: 768px) {
  .info-content {
    padding: 0 1rem;
  }
  
  .info-content h2 {
    font-size: 1.5rem;
  }
  
  .info-content h3 {
    font-size: 1.2rem;
  }
}

/* Understanding Section at Top */
.understanding-section {
  background-color: #e7f3ff;
  padding: 2rem 1rem;
  border-bottom: 2px solid #0066cc;
}

.understanding-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
}

.understanding-content h2 {
  color: var(--primary-color);
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.8rem;
}

.understanding-content p {
  line-height: 1.8;
  margin-bottom: 1rem;
  color: #333;
}

/* Pagination Controls */
.pagination-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 8px;
  flex-wrap: wrap;
  gap: 1rem;
}

.pagination-info {
  font-weight: 500;
  color: #666;
}

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

.pagination-btn {
  padding: 0.5rem 0.75rem;
  background-color: white;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--primary-color);
}

.pagination-btn:hover:not(:disabled) {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-numbers {
  display: flex;
  gap: 0.25rem;
}

.page-number {
  padding: 0.5rem 0.75rem;
  background-color: white;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #333;
  min-width: 40px;
  text-align: center;
}

.page-number:hover {
  background-color: #e9ecef;
}

.page-number.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.page-size-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-size-selector label {
  font-weight: 500;
  color: #666;
}

.page-size-selector select {
  padding: 0.5rem;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background-color: white;
  cursor: pointer;
  font-size: 1rem;
}

/* Focus styles for accessibility */
button:focus-visible,
input[type="text"]:focus-visible,
input[type="checkbox"]:focus-visible,
select:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Ensure high visibility for pagination and action buttons */
.pagination-btn:focus-visible,
.btn-export:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 3px;
  box-shadow: 0 0 0 1px white, 0 0 0 4px var(--primary-color);
}

@media (max-width: 768px) {
  .understanding-content {
    padding: 0 1rem;
  }
  
  .understanding-content h2 {
    font-size: 1.5rem;
  }
  
  .pagination-container {
    flex-direction: column;
    align-items: stretch;
  }
  
  .pagination-controls {
    justify-content: center;
  }
  
  .pagination-info, .page-size-selector {
    text-align: center;
    justify-content: center;
  }
}
