/* Matrix Tree Visualization Styles - UK Themed */

/* Loading & Error States */
.matrix-loading,
.matrix-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.spinner-large {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 215, 0, 0.2);
  border-top-color: #FFD700;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.matrix-error svg {
  color: #C8102E;
  margin-bottom: 20px;
}

.matrix-error h3 {
  color: #012169;
  margin-bottom: 8px;
  font-family: 'Georgia', serif;
}

.matrix-error p {
  color: #6b7280;
}

/* Container */
.matrix-tree-container {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(1, 33, 105, 0.1);
  overflow: hidden;
  border: 2px solid rgba(255, 215, 0, 0.3);
}

/* Header Section */
.matrix-header {
  background: linear-gradient(135deg, #012169 0%, #001a4d 100%);
  padding: 32px;
  color: white;
  border-bottom: 3px solid #FFD700;
}

.matrix-title h2 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px 0;
  font-family: 'Georgia', serif;
}

.matrix-address {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  opacity: 0.9;
  margin: 0;
  color: #FFD700;
}

/* Statistics Grid */
.matrix-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.stat-card {
  background: rgba(255, 215, 0, 0.15);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.stat-card:hover {
  background: rgba(255, 215, 0, 0.25);
  transform: translateY(-2px);
  border-color: #FFD700;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-content h3 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: #FFD700;
  font-family: 'Georgia', serif;
}

.stat-content p {
  font-size: 14px;
  margin: 0;
  opacity: 0.9;
}

/* Controls Section */
.matrix-controls {
  padding: 24px 32px;
  background: rgba(1, 33, 105, 0.03);
  border-bottom: 2px solid rgba(255, 215, 0, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.level-filter {
  display: flex;
  align-items: center;
  gap: 12px;
}

.level-filter label {
  font-weight: 600;
  color: #012169;
  font-family: 'Georgia', serif;
}

.level-select {
  padding: 8px 16px;
  border: 2px solid rgba(255, 215, 0, 0.4);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #012169;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
}

.level-select:hover {
  border-color: #FFD700;
}

.level-select:focus {
  outline: none;
  border-color: #FFD700;
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.2);
}

/* Legend */
.matrix-legend {
  display: flex;
  gap: 24px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #6b7280;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.legend-dot.filled {
  background: #FFD700;
  border: 2px solid #C8102E;
}

.legend-dot.empty {
  background: #e5e7eb;
  border: 2px solid #9ca3af;
}

/* Tree Scroll Container */
.matrix-tree-scroll {
  padding: 32px;
  max-height: 800px;
  overflow-y: auto;
}

.matrix-tree-scroll::-webkit-scrollbar {
  width: 8px;
}

.matrix-tree-scroll::-webkit-scrollbar-track {
  background: rgba(1, 33, 105, 0.05);
}

.matrix-tree-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 215, 0, 0.5);
  border-radius: 4px;
}

.matrix-tree-scroll::-webkit-scrollbar-thumb:hover {
  background: #FFD700;
}

/* Matrix Tree */
.matrix-tree {
  max-width: 100%;
}

/* Matrix Level */
.matrix-level {
  margin-bottom: 32px;
  animation: fadeInUp 0.4s ease;
}

.matrix-level[data-level="0"] {
  margin-bottom: 48px;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Level Header */
.level-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid rgba(255, 215, 0, 0.3);
}

.level-badge {
  display: inline-block;
  padding: 6px 16px;
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: #012169;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'Georgia', serif;
}

.level-badge.root {
  background: linear-gradient(135deg, #012169 0%, #001a4d 100%);
  color: #FFD700;
  border: 2px solid #FFD700;
}

.level-stats {
  font-size: 13px;
  font-weight: 600;
  color: #012169;
}

.level-progress {
  flex: 1;
  height: 6px;
  background: rgba(1, 33, 105, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-left: auto;
  max-width: 200px;
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.level-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #FFD700 0%, #FFA500 100%);
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* Level Nodes */
.level-nodes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.matrix-level[data-level="0"] .level-nodes {
  display: flex;
  justify-content: center;
}

/* Matrix Node */
.matrix-node {
  background: white;
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s ease;
  cursor: default;
}

.matrix-node.filled {
  border-color: #FFD700;
  cursor: pointer;
  background: linear-gradient(to bottom, white, rgba(255, 215, 0, 0.05));
}

.matrix-node.filled:hover {
  border-color: #C8102E;
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
  transform: translateY(-2px);
}

.matrix-node.root-node {
  border-color: #FFD700;
  background: linear-gradient(135deg, rgba(1, 33, 105, 0.05) 0%, rgba(255, 215, 0, 0.05) 100%);
  border-width: 3px;
}

.matrix-node.empty {
  background: rgba(1, 33, 105, 0.02);
  border-style: dashed;
  opacity: 0.7;
}

/* Node Avatar */
.node-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #012169;
  flex-shrink: 0;
  border: 2px solid #FFD700;
}

.root-node .node-avatar {
  background: linear-gradient(135deg, #012169 0%, #001a4d 100%);
  color: #FFD700;
  border-color: #FFD700;
}

.node-avatar.empty {
  background: #e5e7eb;
  color: #9ca3af;
  border-color: #d1d5db;
}

/* Node Info */
.node-info {
  flex: 1;
  min-width: 0;
}

.node-address {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: 600;
  color: #012169;
  margin: 0 0 4px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matrix-node.empty .node-address {
  color: #9ca3af;
  font-family: inherit;
}

.node-label,
.node-position {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #C8102E;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Matrix Info Section */
.matrix-info {
  padding: 32px;
  background: rgba(1, 33, 105, 0.03);
  border-top: 2px solid rgba(255, 215, 0, 0.3);
}

.matrix-info h4 {
  color: #012169;
  font-size: 18px;
  margin: 0 0 16px 0;
  font-family: 'Georgia', serif;
}

.matrix-info ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.matrix-info li {
  padding: 8px 0;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.6;
}

.matrix-info strong {
  color: #012169;
  font-weight: 600;
}

/* Node Details Modal */
.node-details-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.node-details-modal.show {
  opacity: 1;
}

.node-details-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(1, 33, 105, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.node-details-container {
  background: white;
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(1, 33, 105, 0.4);
  animation: slideUp 0.3s ease;
  border: 2px solid #FFD700;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.node-details-header {
  padding: 24px;
  border-bottom: 2px solid rgba(255, 215, 0, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to bottom, rgba(1, 33, 105, 0.05), transparent);
}

.node-details-header h3 {
  margin: 0;
  font-size: 20px;
  color: #012169;
  font-family: 'Georgia', serif;
}

.close-details {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 215, 0, 0.2);
  border-radius: 8px;
  font-size: 24px;
  color: #012169;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  border: 1px solid rgba(255, 215, 0, 0.4);
}

.close-details:hover {
  background: rgba(255, 215, 0, 0.3);
  color: #C8102E;
  border-color: #FFD700;
}

.node-details-content {
  padding: 24px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(1, 33, 105, 0.1);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-weight: 600;
  color: #6b7280;
  font-size: 14px;
}

.detail-value {
  font-weight: 600;
  color: #012169;
  font-size: 14px;
  font-family: 'Courier New', monospace;
}

.node-details-actions {
  padding: 24px;
  border-top: 2px solid rgba(255, 215, 0, 0.3);
}

.btn-view-matrix {
  width: 100%;
  padding: 12px 24px;
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  color: #012169;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Georgia', serif;
}

.btn-view-matrix:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.5);
}

.btn-view-matrix:active {
  transform: translateY(0);
}

/* Load More Button Styles */
.load-more-container {
  text-align: center;
  padding: 32px 20px;
  margin: 20px 0;
}

.load-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  color: #012169;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
  font-family: 'Georgia', serif;
}

.load-more-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 215, 0, 0.5);
}

.load-more-btn:active:not(:disabled) {
  transform: translateY(0);
}

.load-more-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.load-more-btn svg {
  transition: transform 0.3s ease;
}

.load-more-btn:hover:not(:disabled) svg {
  transform: translateY(2px);
}

/* Spinner for load more button */
.spinner-small {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(1, 33, 105, 0.3);
  border-top-color: #012169;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Loading more indicator (fallback) */
.loading-more {
  text-align: center;
  padding: 30px 16px;
  color: #6b7280;
  font-size: 14px;
}

.loading-more .spinner-small {
  margin: 0 auto 10px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .matrix-header {
    padding: 24px 20px;
  }

  .matrix-title h2 {
    font-size: 24px;
  }

  .matrix-stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .matrix-controls {
    padding: 20px;
    flex-direction: column;
    align-items: stretch;
  }

  .level-filter {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .level-select {
    width: 100%;
  }

  .matrix-legend {
    justify-content: center;
  }

  .matrix-tree-scroll {
    padding: 20px;
  }

  .level-nodes {
    grid-template-columns: 1fr;
  }

  .matrix-info {
    padding: 20px;
  }

  .load-more-container {
    padding: 24px 16px;
  }

  .load-more-btn {
    padding: 12px 24px;
    font-size: 14px;
    width: 100%;
    max-width: 300px;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .stat-card {
    padding: 16px;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
  }

  .stat-content h3 {
    font-size: 20px;
  }

  .matrix-node {
    padding: 12px;
  }

  .node-avatar {
    width: 36px;
    height: 36px;
  }

  .node-address {
    font-size: 12px;
  }
}