body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  margin: 0;
  overflow: hidden;
}

a[href]{
  user-select: none;
}

body.dark {
  background-color: #121212;
  color: #f0f0f0;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1f2937;
  color: #ffffff;
  padding: 1rem;
  box-sizing: border-box;
  position: relative;
  z-index: 10;
}

.header h1 {
  margin: 0;
  font-size: 1.5em;
  user-select: none;
}

.view-toggle {
  display: flex;
  align-items: center;
  gap: 16px;
}

.view-toggle .info {
  cursor: pointer;
  transition: color 0.3s;
}

.view-toggle .info:hover {
  color: #0099ff;
}

.view-toggle > div:last-child {
    display: flex;
    gap: 5px; 
}
div > span[class^=material-symbols] {
  display: flex;
  user-select: none;
}

.view-toggle button {
  background-color: #333;
  color: #ccc;
  border: 1px solid #555;
  padding: 8px 15px;
  cursor: pointer;
  border-radius: 5px;
  transition: background-color 0.3s, color 0.3s;
  user-select: none;
}

.view-toggle button:hover {
  background-color: #444;
}

.view-toggle button.active {
  background-color: #007bff;
  color: white;
  border-color: #007bff;
}

.container {
  display: flex;
  height: calc(100vh - 64px);
}

.sidebar {
  width: 250px;
  padding: 1rem;
  background-color: #1a1a1a;
  color: #fff;
  font-size: 1.1rem;
  overflow-y: auto;
  box-sizing: border-box;
  border-right: 1px solid #333;
  flex-shrink: 0;
}

.sidebar ul,
.country-list {
  list-style-type: none;
  padding-left: 0;
  margin-left: 0;
}

.sidebar .region > button{
  display: block;
  width: 100%;
  padding: 0.4rem 0.2rem;
  background: none;
  border: none;
  color: #f0f0f0;
  text-align: left;
  cursor: pointer;
  font-weight: bold;
  user-select: none;
}

.sidebar .country-item:hover {
  background-color: #2d3748;
  border-radius: 4px;
}

.sidebar .region button:hover {
  background-color: #2d3748;
  border-radius: 4px;
}

.country-item {
  user-select: none;
  padding: 5px 5px 5px 1rem;
  font-size: 0.95rem;
  color: #ccc;
  cursor: pointer;
  font-weight: normal;
  border-radius: 3px;
  transition: background-color 0.2s;
}

.country-item:hover {
    background-color: #2d3748;
}

.region-divider {
  border: none;
  border-top: 1px solid #555;
  margin: 0.3rem 0 0.5rem 0;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1rem;
  gap: 1rem;
}

.map-container,
.table-container {
  border-radius: 6px;
  border: 1px solid #444;
  box-sizing: border-box;
}

.map-container {
  height: 60%;
  position: relative;
  background: #000011;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  cursor: grab;
}

#legends {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(26, 26, 26, 0.9);
    backdrop-filter: blur(5px);
    border-radius: 8px;
    border: 1px solid #444;
    z-index: 1000;
    cursor: pointer;
    transition: transform 0.4s ease-in-out, background-color 0.4s;
    user-select: none;
    box-sizing: border-box;
    max-width: 200px;
    max-height: 50%;
    overflow-y: auto;
    padding: 10px 10px 10px 20px;
}

#legends.hidden {
    transform: translateX(calc(100% - 20px));
    background-color: rgba(26, 26, 26, 0.5);
}

#legends.hidden > * {
    visibility: hidden;
}

#legends h4 {
    margin: 0 0 8px 0;
    text-align: center;
    border-bottom: 1px solid #555;
    font-size: 13px;
    padding-bottom: 6px;
    font-weight: bold;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    font-size: 11px;
}

.legend-color-box {
    width: 14px;
    height: 14px;
    margin-right: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

#legends::-webkit-scrollbar {
    width: 6px;
}
#legends::-webkit-scrollbar-track {
    background: transparent;
}
#legends::-webkit-scrollbar-thumb {
    background-color: rgba(128, 128, 128, 0.5);
    border-radius: 3px;
}

.table-container {
  height: 40%;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  color: #f8fafc;
}

th, td {
  border: 1px solid #555;
  padding: 0.5rem;
  text-align: left;
}

th {
  background-color: #2d3748;
  position: sticky;
  top: 0;
  z-index: 1;
}

.article-link {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid #4da6ff;
  border-radius: 5px;
  background-color: transparent;
  color: #4da6ff;
  text-decoration: none;
  font-weight: bold;
  font-size: 13px;
  transition: all 0.2s ease-in-out;
}

.article-link:hover {
  background-color: #4da6ff;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

.article-link:active {
  transform: translateY(0);
  box-shadow: none;
}

#news-table-body tr.highlighted {
    background-color: #007bff !important;
    color: white;
    transition: background-color 0.3s ease;
}

#news-table-body tr.highlighted a.article-link {
    color: white;
    border-color: white;
}

@media (max-width: 768px) {

  body {
    overflow: auto;
  }

  .container {
    flex-direction: column;
    height: auto;
  }

  .header {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }
  .header h1 {
    font-size: 1.3em;
    width: 100%;
    text-align: center;
  }

  
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #333;
    overflow-y: visible;
  }

  .sidebar > #regions {
    
    display: grid;
    
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem; 
  }
  
  .sidebar > #regions > .region {
      text-align: center;
      border-radius: 4px;
      padding: 0.6rem 0.2rem; 
      font-size: 0.9em;
  }

  .sidebar > #regions > .region > button {
    width: 100%;
    font-weight: bold;
  }
  
  .country-list {
      grid-column: 1 / -1;
      font-size: 0.2em;
      max-height: 10vh;
      overflow-y: auto;
      padding: 0 1rem;
      box-sizing: border-box;
      margin-top: 0.5rem;
  }

  .main {
    height: auto;
    min-height: 100vh;
    padding: 0.8rem;
    gap: 0.8rem;
  }
  
  .map-container {
      height: 50vh;
      min-height: 300px;
  }
  
  .table-container {
      height: auto;
      max-height: 60vh;
      overflow-x: auto;
  }

  th, td {
    padding: 0.4rem;
    font-size: 0.9em;
  }
  
  .article-link {
      padding: 5px 10px;
      font-size: 12px;
  }

  #legends {
      max-width: 160px;
      padding: 8px 8px 8px 18px;
  }
  #legends.hidden {
      transform: translateX(calc(100% - 18px));
  }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.2em;
    }
    .view-toggle button {
        padding: 6px 10px;
        font-size: 0.9em;
    }

    .main {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .map-container {
        height: 45vh;
        min-height: 250px;
    }

    th, td {
        padding: 0.3rem 0.4rem;
        font-size: 0.85em;
    }

    td {
        word-break: break-all;
    }

    #legends {
        max-width: 130px;
    }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7); 
  backdrop-filter: blur(3px);
  display: none; 
  justify-content: center;
  align-items: center;
  z-index: 2000; 
}

.modal {
  background-color: #2c2c2c;
  color: #f0f0f0;
  padding: 2rem 2.5rem;
  border-radius: 10px;
  max-width: 650px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 5px 15px rgba(0,0,0,0.5);
  border: 1px solid #555;
}

.modal-visible {
  display: flex; 
}

.modal .close-button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 2rem;
  color: #aaa;
  cursor: pointer;
  line-height: 1;
}
.modal .close-button:hover {
  color: #fff;
}

.modal h2 {
  margin-top: 0;
  color: #0099ff;
  border-bottom: 1px solid #555;
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

.modal h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #f0f0f0;
  margin-top: 1.5rem;
  font-size: 1.1em;
  border-bottom: 1px solid #444;
  padding-bottom: 0.4rem;
}

.modal p, .modal li {
  line-height: 1.6;
}

.modal ul {
  padding-left: 25px;
  list-style-type: disc;
}
.modal ul ul {
  list-style-type: circle;
  margin-top: 0.5rem;
}

.modal li {
  margin-bottom: 0.8rem;
}

.modal strong {
  color: #ff8a80;
  font-weight: 600;
}

.modal a {
  color: #ffd54f;
  text-decoration: underline;
  transition: color 0.2s ease;
}

.modal a:hover {
  color: #ffc107;
}
.modal::-webkit-scrollbar {
    width: 8px;
}
.modal::-webkit-scrollbar-track {
    background: #2c2c2c;
    border-radius: 4px;
}
.modal::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 4px;
}