/* Nations Viewer Styles */
.nations-viewer-section {
  padding: 80px 20px;
  background: linear-gradient(to bottom, var(--darker), var(--dark));
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.nations-viewer-section .container {
  width: 100% !important;
  max-width: 100% !important;
  padding: 0 !important;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.nations-viewer-section .section-title,
.nations-viewer-section .section-subtitle {
  width: 100%;
  text-align: center;
  margin-bottom: 30px;
}

.nations-viewer-container {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 40px;
  width: auto;
  max-width: 1400px;
  box-sizing: border-box;
}

.nations-loading {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

/* Left Column: Dropdown Panel */
.nations-dropdown-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.dropdown-header {
  padding-bottom: 12px;
  border-bottom: 2px solid rgba(52, 152, 219, 0.3);
}

.dropdown-header h3 {
  margin: 0;
  color: var(--light);
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropdown-header i {
  color: var(--primary);
}

/* Sort Controls */
.sort-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 15px;
  margin-bottom: 15px;
}

.sort-controls label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sort-dropdown {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(52, 152, 219, 0.3);
  background: rgba(30, 35, 45, 0.7);
  color: var(--light);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233498db' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 32px;
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

.sort-dropdown:hover {
  border-color: rgba(52, 152, 219, 0.5);
  background-color: rgba(30, 35, 45, 0.85);
}

.sort-dropdown:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 8px rgba(52, 152, 219, 0.2);
}

.sort-dropdown option {
  background: var(--dark);
  color: var(--light);
  padding: 6px;
}

/* Select Dropdown Styling */
.nations-dropdown {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px solid rgba(52, 152, 219, 0.3);
  background: rgba(30, 35, 45, 0.8);
  color: var(--light);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233498db' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 20px;
  padding-right: 36px;
}

.nations-dropdown:hover {
  border-color: rgba(52, 152, 219, 0.6);
  background-color: rgba(30, 35, 45, 0.95);
  box-shadow: 0 0 10px rgba(52, 152, 219, 0.15);
}

.nations-dropdown:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(52, 152, 219, 0.3);
}

.nations-dropdown option {
  background: var(--dark);
  color: var(--light);
  padding: 8px;
}

/* Quick List of Nations */
.nations-quick-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 5px;
}

.nations-quick-list::-webkit-scrollbar {
  width: 6px;
}

.nations-quick-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

.nations-quick-list::-webkit-scrollbar-thumb {
  background: rgba(52, 152, 219, 0.3);
  border-radius: 10px;
}

.nations-quick-list::-webkit-scrollbar-thumb:hover {
  background: rgba(52, 152, 219, 0.5);
}

/* Nation Quick Item (Legacy name kept for compatibility) */
.nation-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(30, 35, 45, 0.6);
  text-align: left;
  position: relative;
  box-sizing: border-box;
}

.nation-option:hover {
  background: rgba(30, 35, 45, 0.9);
  border-color: rgba(52, 152, 219, 0.5);
  transform: translateX(4px);
}

.nation-option.active {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.25), rgba(52, 152, 219, 0.1));
  border-color: var(--primary);
  box-shadow: inset 0 0 15px rgba(52, 152, 219, 0.15);
}

.option-flag {
  width: 36px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.option-name {
  color: var(--light);
  font-weight: 500;
  font-size: 0.9rem;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.nation-option.active .option-name {
  color: var(--primary);
  font-weight: 600;
}

/* Right Panel: Details */
.nations-details-panel {
  position: relative;
}

.nation-details-card {
  background: rgba(30, 35, 45, 0.9);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 30px;
  height: auto;
  min-height: 600px;
  overflow-y: auto;
  transition: opacity 0.3s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
}

.nation-details-card.updating {
  opacity: 0.6;
}

.nation-header-large {
  display: flex;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  gap: 20px;
}

.nation-header-content {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  width: 100%;
}

.nation-flag-large {
  width: 100px;
  height: 67px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.nation-title-group {
  flex: 1;
  min-width: 0;
}

.nation-name-large {
  margin: 0 0 10px 0;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nation-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.badge i {
  margin-right: 5px;
  flex-shrink: 0;
}

.badge-leader {
  background: rgba(241, 196, 15, 0.15);
  color: #f1c40f;
  border: 1px solid rgba(241, 196, 15, 0.3);
}

.badge-capital {
  background: rgba(52, 152, 219, 0.15);
  color: #3498db;
  border: 1px solid rgba(52, 152, 219, 0.3);
}

.nation-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-box {
  background: rgba(52, 152, 219, 0.1);
  padding: 16px;
  border-radius: 10px;
  text-align: center;
  transition: background 0.3s ease, border-color 0.3s ease;
  border: 1px solid rgba(52, 152, 219, 0.2);
  position: relative;
  height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.stat-box:hover {
  background: rgba(52, 152, 219, 0.15);
  border-color: rgba(52, 152, 219, 0.4);
}

.stat-box i {
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 6px;
  display: block;
  flex-shrink: 0;
}

.stat-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.stat-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.65);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nation-description-box {
  background: rgba(255, 255, 255, 0.02);
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 20px;
  border-left: 3px solid var(--primary);
  max-height: 120px;
  overflow: hidden;
  box-sizing: border-box;
}

.nation-description-box h4 {
  margin: 0 0 10px 0;
  color: var(--light);
  font-size: 0.95rem;
  font-weight: 600;
}

.nation-description-box p {
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.5;
  margin: 0;
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Allies & Enemies Section */
.nation-allies-enemies {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.nation-relations {
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: 10px;
  border-left: 3px solid var(--primary);
  box-sizing: border-box;
}

.nation-relations h4 {
  margin: 0 0 10px 0;
  color: var(--light);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  flex-shrink: 0;
}

.nation-relations i {
  color: var(--primary);
  font-size: 1rem;
  flex-shrink: 0;
}

/* Relations Dropdown Wrapper */
.relations-dropdown-wrapper {
  position: relative;
}

.relations-dropdown {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(52, 152, 219, 0.3);
  background: rgba(30, 35, 45, 0.7);
  color: var(--light);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233498db' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 16px;
  padding-right: 28px;
}

.relations-dropdown:hover {
  border-color: rgba(52, 152, 219, 0.5);
  background-color: rgba(30, 35, 45, 0.85);
}

.relations-dropdown:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 8px rgba(52, 152, 219, 0.2);
}

.relations-dropdown option {
  background: var(--dark);
  color: var(--light);
  padding: 6px;
}

/* Allies & Enemies Grid (Legacy, kept for fallback display) */
.relations-grid {
  display: none;
}

.relations-grid .nation-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.2), rgba(52, 152, 219, 0.1));
  color: rgba(255, 255, 255, 0.9);
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid rgba(52, 152, 219, 0.4);
  transition: all 0.3s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  position: relative;
}

.relations-grid .nation-tag:hover {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.35), rgba(52, 152, 219, 0.2));
  border-color: rgba(52, 152, 219, 0.7);
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.25);
  transform: scale(1.05);
}

.empty-relations {
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.8rem;
  font-style: italic;
  margin: 0;
}

.nation-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
}

/* Loading State */
.nations-loading {
  text-align: center;
  padding: 60px;
  color: rgba(255, 255, 255, 0.6);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 1400px) {
  .nations-viewer-container {
    grid-template-columns: 220px 1fr;
    gap: 35px;
  }
}

@media (max-width: 1200px) {
  .nations-viewer-container {
    grid-template-columns: 220px 1fr;
    gap: 30px;
  }

  .nation-details-card {
    padding: 24px;
    min-height: 550px;
  }

  .nation-stats-row {
    gap: 10px;
  }

  .stat-box {
    height: 100px;
  }

  .stat-value {
    font-size: 1.4rem;
  }
}

@media (max-width: 992px) {
  .nations-viewer-container {
    grid-template-columns: 220px 1fr;
    gap: 20px;
  }

  .nations-dropdown-panel {
    gap: 12px;
  }

  .nations-quick-list {
    max-height: 400px;
  }

  .nation-details-card {
    padding: 20px;
    min-height: 480px;
  }

  .nation-header-large {
    flex-direction: row;
    align-items: flex-start;
  }

  .nation-flag-large {
    width: 75px;
    height: 50px;
  }

  .nation-name-large {
    font-size: 1.4rem;
  }

  .nation-stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }

  .stat-box {
    height: 95px;
    padding: 10px;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  .stat-label {
    font-size: 0.68rem;
  }

  .nation-allies-enemies {
    gap: 8px;
  }

  .nation-relations {
    padding: 10px;
  }

  .nation-relations h4 {
    font-size: 0.85rem;
    margin-bottom: 8px;
  }
}

@media (max-width: 1024px) {
  .nations-viewer-container {
    grid-template-columns: 200px 1fr;
    gap: 25px;
  }

  .nations-dropdown-panel {
    gap: 12px;
  }

  .nations-quick-list {
    max-height: 400px;
  }

  .nation-details-card {
    padding: 20px;
    min-height: 500px;
  }

  .nation-flag-large {
    width: 85px;
    height: 57px;
  }

  .nation-name-large {
    font-size: 1.4rem;
  }
}

@media (max-width: 768px) {
  .nations-viewer-section {
    padding: 40px 12px;
  }

  .nations-viewer-section .container {
    padding: 0 !important;
    width: 100%;
    max-width: 100% !important;
    display: block !important;
  }

  .nations-viewer-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0 !important;
  }

  .nations-dropdown-panel {
    gap: 12px;
    order: -1;
    width: 100%;
  }

  .dropdown-header h3 {
    font-size: 1rem;
  }

  .sort-controls {
    margin-top: 12px;
    margin-bottom: 12px;
    gap: 6px;
  }

  .sort-controls label {
    font-size: 0.8rem;
  }

  .sort-dropdown {
    padding: 8px 10px;
    font-size: 0.85rem;
    padding-right: 28px;
    position: relative;
    z-index: 10;
    pointer-events: auto;
  }

  .nations-quick-list {
    max-height: 200px;
    gap: 6px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .nation-option {
    padding: 8px 10px;
    gap: 8px;
  }

  .option-flag {
    width: 32px;
    height: 21px;
  }

  .option-name {
    font-size: 0.85rem;
  }

  .nations-details-panel {
    width: 100%;
    order: 1;
  }

  .nation-details-card {
    padding: 16px;
    min-height: auto;
    margin-bottom: 20px;
  }

  .nation-header-large {
    flex-direction: row;
    align-items: flex-start;
    margin-bottom: 16px;
    padding-bottom: 12px;
  }

  .nation-header-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
  }

  .nation-flag-large {
    width: 70px;
    height: 47px;
    flex-shrink: 0;
  }

  .nation-name-large {
    font-size: 1.3rem;
  }

  .nation-title-group {
    min-width: 0;
  }

  .badge {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .nation-stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
  }

  .stat-box {
    height: 85px;
    padding: 8px;
  }

  .stat-box i {
    font-size: 1.1rem;
    margin-bottom: 3px;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  .nation-description-box {
    padding: 10px;
    margin-bottom: 12px;
  }

  .nation-description-box h4 {
    font-size: 0.85rem;
    margin-bottom: 6px;
  }

  .nation-description-box p {
    font-size: 0.8rem;
  }

  .nation-allies-enemies {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }

  .nation-relations {
    padding: 8px;
  }

  .nation-relations h4 {
    font-size: 0.8rem;
    margin-bottom: 6px;
  }

  .relations-dropdown {
    padding: 6px 8px;
    font-size: 0.8rem;
  }

  .nation-actions {
    gap: 6px;
    padding-top: 10px;
    flex-direction: column;
  }

  .btn {
    font-size: 0.85rem;
    padding: 8px 12px;
  }
}

@media (max-width: 480px) {
  .nations-viewer-section {
    padding: 30px 12px;
  }

  .nations-viewer-section .container {
    padding: 0 !important;
    width: 100%;
    max-width: 100%;
  }

  .nations-viewer-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 0 !important;
  }

  .nations-dropdown-panel {
    gap: 10px;
    order: -1;
    width: 100%;
  }

  .dropdown-header h3 {
    font-size: 0.95rem;
  }

  .sort-controls {
    margin-top: 10px;
    margin-bottom: 10px;
    gap: 5px;
  }

  .sort-controls label {
    font-size: 0.75rem;
  }

  .sort-dropdown {
    padding: 7px 8px;
    font-size: 0.8rem;
    padding-right: 26px;
    background-size: 14px;
    position: relative;
    z-index: 10;
    pointer-events: auto;
  }

  .nations-quick-list {
    max-height: 150px;
    gap: 6px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .nations-details-panel {
    width: 100%;
    order: 1;
  }

  .nation-option {
    padding: 6px 8px;
    gap: 6px;
  }

  .option-flag {
    width: 28px;
    height: 19px;
  }

  .option-name {
    font-size: 0.8rem;
  }

  .nation-details-card {
    padding: 12px;
  }

  .nation-header-large {
    margin-bottom: 12px;
    padding-bottom: 10px;
    gap: 10px;
  }

  .nation-header-content {
    gap: 10px;
  }

  .nation-flag-large {
    width: 55px;
    height: 37px;
  }

  .nation-name-large {
    font-size: 1rem;
  }

  .nation-title-group {
    min-width: 0;
  }

  .badge {
    padding: 3px 6px;
    font-size: 0.7rem;
  }

  .badge i {
    margin-right: 3px;
  }

  .nation-stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 10px;
  }

  .stat-box {
    height: 70px;
    padding: 6px;
  }

  .stat-box i {
    font-size: 0.9rem;
    margin-bottom: 2px;
  }

  .stat-value {
    font-size: 0.95rem;
  }

  .stat-label {
    font-size: 0.6rem;
  }

  .nation-description-box {
    padding: 8px;
    margin-bottom: 10px;
  }

  .nation-description-box h4 {
    font-size: 0.8rem;
    margin-bottom: 4px;
  }

  .nation-description-box p {
    font-size: 0.75rem;
  }

  .nation-allies-enemies {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 10px;
  }

  .nation-relations {
    padding: 6px;
  }

  .nation-relations h4 {
    font-size: 0.75rem;
    margin-bottom: 6px;
  }

  .nation-relations i {
    font-size: 0.9rem;
  }

  .relations-dropdown {
    padding: 5px 6px;
    font-size: 0.75rem;
  }

  .nation-actions {
    padding-top: 6px;
    gap: 4px;
  }

  .btn {
    font-size: 0.8rem;
    padding: 6px 10px;
  }
}
