/**
 * AI Summary System - Ranking Display Styles
 * Version: 1.0.0
 * Purpose: Styles for ranking and comparison display
 */

/* ============================================================================
   BASE CONTAINER
   ============================================================================ */

.aisum-ranking-container {
  max-width: 1200px;
  margin: 30px auto;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* ============================================================================
   OVERALL SCORE SECTION
   ============================================================================ */

.aisum-overall-score {
  text-align: center;
  padding: 30px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 12px;
  margin-bottom: 30px;
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.aisum-score-header h3 {
  margin: 0 0 20px 0;
  font-size: 24px;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.aisum-score-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.aisum-score-number {
  font-size: 72px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.aisum-score-max {
  font-size: 32px;
  font-weight: 500;
  opacity: 0.9;
}

.aisum-score-bar {
  width: 100%;
  max-width: 400px;
  height: 10px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  margin: 0 auto 15px;
  overflow: hidden;
}

.aisum-score-bar-fill {
  height: 100%;
  background: #ffffff;
  border-radius: 10px;
  transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.3);
}

.aisum-score-percentage {
  font-size: 20px;
  font-weight: 600;
  opacity: 0.95;
}

/* ============================================================================
   RANKING SECTIONS
   ============================================================================ */

.aisum-ranking-section {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 25px;
  margin-bottom: 25px;
  border: 1px solid #e9ecef;
  transition: all 0.3s ease;
}

.aisum-ranking-section:hover {
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.aisum-ranking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #dee2e6;
}

.aisum-ranking-header h4 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #212529;
}

.aisum-country-name,
.aisum-industry-name {
  font-size: 14px;
  font-weight: 600;
  color: #6c757d;
  background: #ffffff;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid #dee2e6;
}

.aisum-ranking-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================================================================
   RANK BADGE
   ============================================================================ */

.aisum-rank-badge-wrapper {
  display: flex;
  align-items: center;
  gap: 20px;
}

.aisum-rank-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 15px 25px;
  border-radius: 10px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.aisum-rank-badge:hover {
  transform: scale(1.05);
}

.aisum-rank-number {
  font-size: 36px;
  line-height: 1;
}

.aisum-rank-total {
  font-size: 18px;
  opacity: 0.8;
}

/* Rank Badge Colors */
.aisum-rank-gold {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
  color: #856404;
  border: 2px solid #ffc107;
}

.aisum-rank-silver {
  background: linear-gradient(135deg, #c0c0c0 0%, #e0e0e0 100%);
  color: #495057;
  border: 2px solid #adb5bd;
}

.aisum-rank-bronze {
  background: linear-gradient(135deg, #cd7f32 0%, #e09856 100%);
  color: #5a3a1a;
  border: 2px solid #b8693f;
}

.aisum-rank-top10 {
  background: linear-gradient(135deg, #17a2b8 0%, #20c9e0 100%);
  color: #ffffff;
  border: 2px solid #138496;
}

.aisum-rank-default {
  background: linear-gradient(135deg, #6c757d 0%, #858e96 100%);
  color: #ffffff;
  border: 2px solid #545b62;
}

.aisum-percentile {
  font-size: 16px;
  font-weight: 600;
  color: #495057;
  background: #ffffff;
  padding: 8px 16px;
  border-radius: 20px;
  border: 2px solid #10b981;
  white-space: nowrap;
}

/* ============================================================================
   COMPARISON SECTION
   ============================================================================ */

.aisum-comparison {
  background: #ffffff;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.aisum-comparison-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f1f3f5;
}

.aisum-comparison-row:last-child {
  border-bottom: none;
}

.aisum-comparison-row.aisum-gap {
  border-top: 2px solid #dee2e6;
  padding-top: 15px;
  margin-top: 10px;
  font-weight: 600;
}

.aisum-comparison-label {
  font-size: 14px;
  color: #6c757d;
  font-weight: 500;
}

.aisum-comparison-value {
  font-size: 18px;
  font-weight: 700;
  color: #212529;
}

/* Gap Colors */
.aisum-gap-positive {
  color: #10b981 !important;
}

.aisum-gap-negative {
  color: #ef4444 !important;
}

.aisum-gap-neutral {
  color: #6c757d !important;
}

/* Progress Bar */
.aisum-progress-bar {
  width: 100%;
  height: 8px;
  background: #e9ecef;
  border-radius: 10px;
  overflow: hidden;
  margin-top: 10px;
}

.aisum-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  border-radius: 10px;
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   DETAILED COMPARISON TABLE
   ============================================================================ */

.aisum-details-section {
  margin-top: 30px;
  padding: 25px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 1px solid #e9ecef;
}

.aisum-details-section h4 {
  margin: 0 0 20px 0;
  font-size: 20px;
  font-weight: 700;
  color: #212529;
}

.aisum-details-table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.aisum-details-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  font-size: 14px;
}

.aisum-details-table thead {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
}

.aisum-details-table th {
  padding: 15px;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.aisum-details-table td {
  padding: 15px;
  border-bottom: 1px solid #e9ecef;
}

.aisum-details-table tbody tr:last-child td {
  border-bottom: none;
}

.aisum-details-table tbody tr:hover {
  background: #f8f9fa;
}

.aisum-dimension-name {
  font-weight: 600;
  color: #212529;
}

.aisum-user-score {
  font-weight: 700;
  color: #10b981;
}

.aisum-country-score,
.aisum-industry-score {
  color: #6c757d;
}

.aisum-gap-score {
  font-weight: 700;
  font-size: 15px;
}

/* ============================================================================
   ERROR & SUCCESS MESSAGES
   ============================================================================ */

.aisum-error {
  padding: 15px 20px;
  background: #fee;
  color: #c33;
  border: 1px solid #fcc;
  border-radius: 8px;
  font-weight: 500;
  margin: 20px 0;
}

.aisum-success {
  padding: 15px 20px;
  background: #efe;
  color: #383;
  border: 1px solid #cfc;
  border-radius: 8px;
  font-weight: 500;
  margin: 20px 0;
}

/* ============================================================================
   CHART SECTION (Placeholder for Chart.js)
   ============================================================================ */

.aisum-chart-section {
  margin-top: 30px;
  padding: 25px;
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid #e9ecef;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.aisum-chart-section h4 {
  margin: 0 0 20px 0;
  font-size: 20px;
  font-weight: 700;
  color: #212529;
}

#aisum-comparison-chart {
  max-height: 400px;
  width: 100% !important;
  height: auto !important;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
  .aisum-ranking-container {
    padding: 15px;
    margin: 20px auto;
  }

  .aisum-overall-score {
    padding: 20px 15px;
  }

  .aisum-score-number {
    font-size: 48px;
  }

  .aisum-score-max {
    font-size: 24px;
  }

  .aisum-ranking-section {
    padding: 20px 15px;
  }

  .aisum-ranking-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .aisum-rank-badge-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .aisum-rank-number {
    font-size: 28px;
  }

  .aisum-rank-total {
    font-size: 16px;
  }

  .aisum-comparison-row {
    font-size: 14px;
  }

  .aisum-comparison-value {
    font-size: 16px;
  }

  .aisum-details-table {
    font-size: 12px;
  }

  .aisum-details-table th,
  .aisum-details-table td {
    padding: 10px 8px;
  }

  .aisum-details-table th {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .aisum-score-header h3 {
    font-size: 20px;
  }

  .aisum-score-number {
    font-size: 40px;
  }

  .aisum-score-max {
    font-size: 20px;
  }

  .aisum-ranking-header h4 {
    font-size: 18px;
  }

  .aisum-rank-badge {
    padding: 12px 20px;
  }

  .aisum-rank-number {
    font-size: 24px;
  }

  .aisum-rank-total {
    font-size: 14px;
  }

  .aisum-percentile {
    font-size: 14px;
    padding: 6px 12px;
  }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
  .aisum-ranking-container {
    box-shadow: none;
    border: 1px solid #dee2e6;
  }

  .aisum-ranking-section {
    page-break-inside: avoid;
  }

  .aisum-overall-score {
    background: #10b981 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .aisum-rank-badge:hover,
  .aisum-ranking-section:hover {
    transform: none;
    box-shadow: none;
  }
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.aisum-ranking-container {
  animation: fadeIn 0.6s ease-out;
}

.aisum-ranking-section {
  animation: fadeIn 0.8s ease-out backwards;
}

.aisum-ranking-section:nth-child(2) {
  animation-delay: 0.1s;
}

.aisum-ranking-section:nth-child(3) {
  animation-delay: 0.2s;
}

.aisum-details-section {
  animation: fadeIn 1s ease-out 0.3s backwards;
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

.aisum-ranking-container *:focus {
  outline: 2px solid #10b981;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .aisum-ranking-container {
    border: 2px solid #000000;
  }

  .aisum-ranking-section {
    border: 2px solid #000000;
  }

  .aisum-details-table {
    border: 2px solid #000000;
  }
}

/* ============================================================================
   COMPARISON CHARTS (COUNTRY & INDUSTRY)
   ============================================================================ */

.aisum-comparison-chart-section {
  margin-top: 30px;
  padding: 30px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e9ecef;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  animation: fadeIn 1s ease-out 0.4s backwards;
}

.aisum-chart-header {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e9ecef;
}

.aisum-chart-header h4 {
  margin: 0 0 10px 0;
  font-size: 22px;
  font-weight: 700;
  color: #212529;
}

.aisum-chart-description {
  margin: 0;
  font-size: 14px;
  color: #6c757d;
  font-style: italic;
}

.aisum-country-chart-container,
.aisum-industry-chart-container {
  position: relative;
  width: 100%;
  min-height: 400px;
  max-height: 600px;
}

#aisum-country-comparison-chart,
#aisum-industry-comparison-chart {
  width: 100% !important;
  height: auto !important;
  max-height: 500px;
}

.aisum-chart-note {
  margin-top: 20px;
  padding: 15px 20px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border-left: 4px solid #10b981;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  color: #065f46;
}

.aisum-chart-note strong {
  color: #047857;
  font-weight: 700;
}

/* Industry chart note variant */
.aisum-industry-chart-container .aisum-chart-note {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-left-color: #3b82f6;
  color: #1e40af;
}

.aisum-industry-chart-container .aisum-chart-note strong {
  color: #1d4ed8;
}

/* Responsive design for charts */
@media (max-width: 768px) {
  .aisum-comparison-chart-section {
    padding: 20px 15px;
    margin-top: 20px;
  }

  .aisum-chart-header h4 {
    font-size: 20px;
  }

  .aisum-chart-description {
    font-size: 13px;
  }

  .aisum-country-chart-container,
  .aisum-industry-chart-container {
    min-height: 350px;
  }

  .aisum-chart-note {
    font-size: 13px;
    padding: 12px 15px;
  }
}

@media (max-width: 480px) {
  .aisum-chart-header h4 {
    font-size: 18px;
  }

  .aisum-country-chart-container,
  .aisum-industry-chart-container {
    min-height: 300px;
  }

  .aisum-chart-note {
    font-size: 12px;
    padding: 10px 12px;
  }
}

/* Print styles for charts */
@media print {
  .aisum-comparison-chart-section {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #dee2e6;
  }

  .aisum-chart-note {
    background: #f0fdf4 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ============================================================================
   DETAILS HEADER WITH INFO ICON
   ============================================================================ */

.aisum-details-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.aisum-details-header h4 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #212529;
}

.aisum-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 16px;
  font-weight: 700;
  color: #6c757d;
  background: #e9ecef;
  border-radius: 50%;
  cursor: help;
  transition: all 0.3s ease;
  position: relative;
}

.aisum-info-icon:hover {
  background: #10b981;
  color: #ffffff;
  transform: scale(1.1);
}

/* Tooltip styling for info icon */
.aisum-info-icon[title] {
  position: relative;
}

.aisum-info-icon::after {
  content: attr(title);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  padding: 12px 15px;
  margin-top: 10px;
  background: #1f2937;
  color: #ffffff;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
  pointer-events: none;
}

.aisum-info-icon::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 2px;
  border: 8px solid transparent;
  border-bottom-color: #1f2937;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1001;
}

.aisum-info-icon:hover::after,
.aisum-info-icon:hover::before {
  opacity: 1;
  visibility: visible;
}

.aisum-details-context {
  margin: 0 0 20px 0;
  padding: 12px 18px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-left: 4px solid #10b981;
  border-radius: 6px;
  font-size: 14px;
  color: #495057;
  line-height: 1.6;
}

.aisum-details-context strong {
  color: #212529;
  font-weight: 600;
}

/* Sector comparison specific styling */
.aisum-sector-comparison .aisum-details-context {
  border-left-color: #3b82f6;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.aisum-dep-type-score {
  color: #3b82f6;
  font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .aisum-details-header {
    flex-wrap: wrap;
  }

  .aisum-info-icon::after {
    width: 220px;
    left: auto;
    right: 0;
    transform: none;
  }

  .aisum-info-icon::before {
    left: auto;
    right: 10px;
    transform: none;
  }

  .aisum-details-context {
    font-size: 13px;
    padding: 10px 14px;
  }
}

@media (max-width: 480px) {
  .aisum-info-icon::after {
    width: 200px;
    font-size: 12px;
  }

  .aisum-details-context {
    font-size: 12px;
  }
}

/* ============================================================================
   ADMIN DEBUG PANEL (ACCORDION)
   ============================================================================ */

.aisum-admin-debug-section {
  margin-top: 30px;
  border-top: 2px dashed #dee2e6;
  padding-top: 20px;
}

.aisum-debug-accordion {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: 10px;
  overflow: hidden;
}

.aisum-debug-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 20px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: all 0.3s ease;
}

.aisum-debug-toggle::-webkit-details-marker {
  display: none;
}

.aisum-debug-toggle:hover {
  background: rgba(245, 158, 11, 0.2);
}

.aisum-debug-icon {
  font-size: 20px;
}

.aisum-debug-title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: #92400e;
}

.aisum-debug-arrow {
  font-size: 12px;
  color: #92400e;
  transition: transform 0.3s ease;
}

.aisum-debug-accordion[open] .aisum-debug-arrow {
  transform: rotate(180deg);
}

.aisum-debug-content {
  padding: 20px;
  background: #ffffff;
  border-top: 1px solid #f59e0b;
}

.aisum-debug-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.aisum-debug-card {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 15px;
}

.aisum-debug-card h5 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 700;
  color: #374151;
  padding-bottom: 8px;
  border-bottom: 2px solid #10b981;
}

.aisum-debug-card ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.aisum-debug-card li {
  padding: 6px 0;
  font-size: 13px;
  color: #4b5563;
  border-bottom: 1px solid #e5e7eb;
}

.aisum-debug-card li:last-child {
  border-bottom: none;
}

.aisum-debug-card li strong {
  color: #1f2937;
}

.aisum-debug-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 15px;
  border-top: 1px solid #e9ecef;
}

.aisum-debug-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff !important;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
  border-radius: 6px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.aisum-debug-btn:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Responsive */
@media (max-width: 768px) {
  .aisum-debug-grid {
    grid-template-columns: 1fr;
  }

  .aisum-debug-toggle {
    padding: 12px 15px;
  }

  .aisum-debug-title {
    font-size: 14px;
  }

  .aisum-debug-content {
    padding: 15px;
  }

  .aisum-debug-actions {
    flex-direction: column;
  }

  .aisum-debug-btn {
    justify-content: center;
  }
}
