/* Authority Status Widget Styles */

.authority-section {
  margin: var(--ts-spacing-xl) 0;
  padding: var(--ts-spacing-md);
  background: var(--ts-surface-elevated, #ffffff);
  border: 1px solid var(--ts-border-subtle, rgba(148, 163, 184, 0.24));
  border-radius: 18px;
  position: relative; /* Ensure tooltips can position relative to section */
  overflow: visible; /* Allow tooltips to extend beyond section bounds */
}

  .authority-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--ts-spacing-md);
    flex-wrap: wrap; /* Allow header to wrap on mobile */
    gap: var(--ts-spacing-sm);
  }

  .authority-section .section-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--ts-text-main, #1e293b);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap; /* Allow header text to wrap on mobile */
    min-width: 0; /* Allow flex item to shrink */
  }

.authority-section-header-tooltip {
  display: inline-flex;
  align-items: center;
  cursor: help;
}

.authority-status-container {
  display: flex;
  flex-direction: column;
  gap: var(--ts-spacing-md);
}

.authority-loading {
  text-align: center;
  padding: var(--ts-spacing-xl);
  color: var(--ts-text-muted, #64748b);
}

/* Empty State */
.authority-empty-state {
  text-align: center;
  padding: var(--ts-spacing-lg) var(--ts-spacing-md);
  color: var(--ts-text-muted, #64748b);
}

.authority-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0 auto var(--ts-spacing-sm);
  color: var(--vs-signal-500, #7fd7ff);
  opacity: 0.6;
}

.authority-empty-icon svg {
  width: 40px;
  height: 40px;
}

.authority-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ts-text-main, #1e293b);
  margin-bottom: var(--ts-spacing-xs);
}

.authority-empty-message {
  font-size: 14px;
  color: var(--ts-text-muted, #64748b);
  line-height: 1.5;
  max-width: 400px;
  margin: 0 auto;
}

/* Global Persona Badge - Compact Design */
.authority-global {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ts-spacing-md);
  padding: var(--ts-spacing-sm) var(--ts-spacing-md);
  background: var(--ts-surface-subtle, #f8fafc);
  border-radius: 10px;
  flex-wrap: wrap;
}

.authority-global-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--ts-surface-elevated, #ffffff);
  border: 1.5px solid;
  border-radius: 6px;
  font-size: 0.875rem;
}

.authority-global-icon {
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.authority-global-info {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.authority-global-label {
  font-size: 11px;
  color: var(--ts-text-muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.authority-global-tier {
  font-size: 13px;
  font-weight: 600;
}

.authority-global-stats {
  display: flex;
  gap: var(--ts-spacing-md);
  justify-content: flex-end;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap; /* Allow stats to wrap on smaller screens */
}

.authority-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 60px;
}

.authority-stat-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--ts-text-main, #020617);
  line-height: 1.2;
}

/* All stats now use the same size - removed primary stat special sizing */

.authority-stat-label {
  font-size: 0.7rem; /* 11.2px - reduced from 12px */
  color: #64748b; /* Mid-gray for better readability */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Zone Alerts */
.authority-zones {
  display: flex;
  flex-direction: column;
  gap: var(--ts-spacing-sm);
}

  .authority-zone-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--ts-spacing-sm);
    padding: var(--ts-spacing-sm) var(--ts-spacing-md); /* Reduced padding */
    border-radius: 8px;
    border-left: 3px solid;
    width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-wrap: break-word;
  }

.authority-zone-exploring {
  background: #eff6ff;
  border-color: #3b82f6;
}

.authority-zone-caution {
  background: #fef3c7;
  border-color: #facc15; /* More vibrant warning yellow */
  border-left-width: 4px;
}

.authority-zone-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.authority-zone-content {
  flex: 1;
}

.authority-zone-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ts-text-main, #020617);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

  .authority-zone-domains {
    font-size: 12px;
    color: var(--ts-text-muted, #64748b);
    line-height: 1.5; /* Slightly tighter */
    overflow-wrap: break-word;
    word-wrap: break-word;
    max-width: 100%;
  }

/* Domain Cards */
.authority-domains {
  display: flex;
  flex-direction: column;
  gap: var(--ts-spacing-md);
}

.authority-domains-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ts-text-main, #020617);
  margin-bottom: var(--ts-spacing-xs);
}

.authority-domains-list {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
  -webkit-overflow-scrolling: touch;
  /* Better scrollbar visibility */
  scrollbar-gutter: stable;
}

.authority-domains-list::-webkit-scrollbar {
  height: 6px;
}

.authority-domains-list::-webkit-scrollbar-track {
  background: transparent;
}

.authority-domains-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 3px;
}

.authority-domains-list::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.6);
}

.authority-domain-card {
  flex: 0 0 200px; /* Fixed width, smaller and wider */
  min-width: 200px;
  max-width: 200px;
  padding: var(--ts-spacing-md);
  background: var(--ts-surface-elevated, #ffffff);
  border: 1px solid var(--ts-border-subtle, rgba(148, 163, 184, 0.24));
  border-radius: 10px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden; /* Prevent text overflow */
}

.authority-domain-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.authority-domain-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: var(--ts-spacing-sm);
  min-height: 40px; /* Ensure consistent height */
}

.authority-domain-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ts-text-main, #020617);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2; /* Max 2 lines */
  -webkit-box-orient: vertical;
  flex: 1;
  min-width: 0; /* Allow flex item to shrink */
}

.authority-domain-tier {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: currentColor;
  color: white !important;
  opacity: 0.9;
  flex-shrink: 0; /* Prevent tier badge from shrinking */
  white-space: nowrap;
}

.authority-domain-stats {
  display: flex;
  gap: 6px;
  justify-content: space-between;
}

.authority-domain-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0; /* Allow flex item to shrink */
}

.authority-domain-stat-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--ts-text-main, #020617);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
}

.authority-domain-stat-label {
  font-size: 0.7rem; /* 11.2px - smaller to fit better */
  color: #64748b; /* Mid-gray for better contrast */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em; /* Improved letter spacing */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
}

/* Tooltip styles */
.authority-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: help;
  z-index: 1; /* Ensure tooltip container is above other content */
}

.authority-section-header-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: help;
  z-index: 1;
}

.authority-tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--ts-text-muted, #64748b);
  opacity: 0.7;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.authority-tooltip:hover .authority-tooltip-icon,
.authority-tooltip-icon:hover {
  opacity: 1;
  color: var(--ts-accent, #0ea5e9);
}

.authority-tooltip-content {
  position: absolute;
  top: 100%; /* Position below the icon instead of above */
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--ts-surface, #ffffff);
  border: 1px solid var(--ts-border-subtle, rgba(148, 163, 184, 0.24));
  border-radius: 8px;
  padding: var(--ts-spacing-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 240px;
  max-width: 320px;
  z-index: 99999; /* Very high z-index to ensure it's on top of all content */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-size: 0.875rem;
  line-height: 1.6;
  margin-top: 8px; /* Spacing below icon */
  margin-bottom: 0;
  word-wrap: break-word;
  white-space: normal;
}

/* Adjust tooltip position for zone alerts - show below */
.authority-zone-title .authority-tooltip-content {
  left: auto;
  right: 0;
  top: 100%;
  bottom: auto;
  transform: translateY(8px);
  margin-top: 8px;
  margin-bottom: 0;
}

.authority-zone-title .authority-tooltip:hover .authority-tooltip-content,
.authority-zone-title .authority-tooltip-icon:hover + .authority-tooltip-content,
.authority-zone-title .authority-tooltip-icon:hover ~ .authority-tooltip-content {
  transform: translateY(4px);
  opacity: 1 !important;
  pointer-events: auto;
}

/* Header tooltip positioning - show below icon */
.authority-section-header-tooltip .authority-tooltip-content {
  bottom: auto;
  top: 100%;
  left: 0;
  transform: translateY(8px);
  margin-top: 8px;
  margin-bottom: 0;
}

.authority-section-header-tooltip:hover .authority-tooltip-content,
.authority-section-header-tooltip:focus .authority-tooltip-content,
.authority-section-header-tooltip .authority-tooltip-icon:hover + .authority-tooltip-content,
.authority-section-header-tooltip .authority-tooltip-icon:hover ~ .authority-tooltip-content {
  transform: translateY(4px);
  opacity: 1 !important;
  pointer-events: auto;
}

.authority-tooltip:hover .authority-tooltip-content,
.authority-tooltip:focus .authority-tooltip-content,
.authority-tooltip-icon:hover + .authority-tooltip-content,
.authority-tooltip-icon:hover ~ .authority-tooltip-content {
  opacity: 1 !important;
  pointer-events: auto;
  transform: translateX(-50%) translateY(4px); /* Move down slightly on hover */
}

.authority-tooltip-title {
  font-weight: 600;
  color: var(--ts-text-main, #020617);
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.authority-tooltip-text {
  color: var(--ts-text-muted, #64748b);
  font-size: 0.875rem;
}

/* Responsive - Tablet and below */
@media (max-width: 1024px) {
  /* Use grid layout on tablet for better space utilization */
  .authority-domains-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--ts-spacing-md);
    overflow-x: visible;
    padding-bottom: 0;
  }
  
  .authority-domain-card {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    width: 100%;
  }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
  .authority-section {
    padding: var(--ts-spacing-sm);
    margin: var(--ts-spacing-lg) 0;
    overflow-x: hidden; /* Prevent horizontal overflow */
    max-width: 100%;
    box-sizing: border-box;
  }

  .authority-global {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--ts-spacing-sm);
    width: 100%;
    box-sizing: border-box;
  }

  .authority-global-badge {
    width: 100%;
    box-sizing: border-box;
  }

  .authority-global-stats {
    width: 100%;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: var(--ts-spacing-sm);
  }

  .authority-stat {
    min-width: 50px; /* Reduced from 60px for better mobile fit */
    flex: 0 1 auto; /* Allow stats to shrink if needed */
  }

  /* Keep horizontal scroll on mobile for domain cards */
  .authority-domains-list {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    padding-bottom: 8px;
  }

  .authority-domain-card {
    flex: 0 0 160px; /* Smaller cards on mobile */
    min-width: 160px;
    max-width: 160px;
    padding: var(--ts-spacing-sm);
  }

  .authority-domain-name {
    font-size: 13px;
  }

  .authority-domain-stat-value {
    font-size: 13px;
  }

  .authority-domain-stat-label {
    font-size: 0.65rem; /* 10.4px - slightly larger for readability */
  }

  .authority-domain-stats {
    flex-direction: row; /* Keep horizontal on mobile for compactness */
    align-items: center;
    gap: 4px;
  }

  .authority-tooltip-content {
    min-width: 200px;
    max-width: 280px;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .authority-section {
    padding: var(--ts-spacing-xs) var(--ts-spacing-sm);
  }

  .authority-global-stats {
    gap: var(--ts-spacing-xs);
  }

  .authority-stat {
    min-width: 45px; /* Even smaller on very small screens */
    font-size: 0.9rem; /* Slightly smaller text */
  }

  .authority-stat-value {
    font-size: 18px; /* Slightly smaller on very small screens */
  }

  .authority-domain-card {
    flex: 0 0 140px; /* Even smaller on very small screens */
    min-width: 140px;
    max-width: 140px;
    padding: var(--ts-spacing-xs) var(--ts-spacing-sm);
  }

  .authority-domain-name {
    font-size: 12px;
    -webkit-line-clamp: 2;
  }

  .authority-domain-stat-value {
    font-size: 12px;
  }

  .authority-domain-stat-label {
    font-size: 0.6rem; /* 9.6px */
  }

  .authority-domain-stats {
    gap: 2px;
  }

  .authority-domains-title {
    font-size: 14px;
  }
}

