/**
 * Advanced Vendor Analysis - Professional Styles
 */

/* Container & Header */
.vendor-analysis-pro {
  padding: 0;
  background: #f8fafc;
  min-height: 100vh;
}

.va-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: linear-gradient(135deg, #133452 0%, #1a4a6e 100%);
  border-radius: 12px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(19, 52, 82, 0.3);
}

.va-title h2 {
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 4px 0;
}

.va-title p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  margin: 0;
}

.va-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.va-select {
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
}

.va-select:hover {
  background: rgba(255, 255, 255, 0.2);
}

.va-select option {
  color: #133452;
  background: #fff;
}

.va-select-small {
  padding: 8px 12px;
  font-size: 0.85rem;
  background: #fff;
  color: #333;
  border: 1px solid #e2e8f0;
}

.va-btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.va-btn-primary {
  background: linear-gradient(135deg, #218d8d, #1d7474);
  color: #fff;
}

.va-btn-primary:hover {
  background: linear-gradient(135deg, #26a3a3, #218d8d);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(33, 141, 141, 0.4);
}

/* KPI Grid */
.va-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.va-kpi-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  transition: all 0.3s ease;
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.va-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.va-kpi-highlight {
  border-left: 4px solid #ef4444;
  background: linear-gradient(135deg, #fff5f5 0%, #fff 100%);
}

.va-kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #fff;
  flex-shrink: 0;
}

.va-kpi-content {
  display: flex;
  flex-direction: column;
}

.va-kpi-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #133452;
  line-height: 1.2;
}

.va-kpi-label {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 500;
  margin-top: 2px;
}

/* Charts Grid */
.va-charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.va-chart-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(226, 232, 240, 0.8);
  overflow: hidden;
}

.va-chart-large {
  grid-column: span 1;
}

.va-chart-full {
  grid-column: 1 / -1;
}

.va-chart-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #f8fafc 0%, #fff 100%);
}

.va-chart-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #133452;
  margin: 0 0 2px 0;
}

.va-chart-subtitle {
  font-size: 0.75rem;
  color: #94a3b8;
  margin: 0;
}

.va-chart-body {
  padding: 16px;
}

.va-chart-container {
  min-height: 280px;
}

/* Tiers Legend */
.va-tiers-legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
}

.va-tier-item {
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 8px;
}

.va-tier-name {
  font-weight: 600;
  color: #133452;
  font-size: 0.9rem;
}

.va-tier-count {
  font-size: 0.8rem;
  color: #64748b;
}

.va-tier-desc {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* Table Card */
.va-table-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(226, 232, 240, 0.8);
  margin-bottom: 24px;
  overflow: hidden;
}

.va-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #f8fafc 0%, #fff 100%);
  flex-wrap: wrap;
  gap: 12px;
}

.va-table-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #133452;
  margin: 0;
}

.va-table-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.va-search {
  padding: 10px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  width: 220px;
  transition: all 0.2s ease;
}

.va-search:focus {
  outline: none;
  border-color: #218d8d;
  box-shadow: 0 0 0 3px rgba(33, 141, 141, 0.1);
}

.va-table-body {
  overflow-x: auto;
}

.va-table {
  width: 100%;
  border-collapse: collapse;
}

.va-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.va-th-number {
  text-align: right;
}

.va-table-row {
  cursor: pointer;
  transition: all 0.15s ease;
}

.va-table-row:hover {
  background: linear-gradient(135deg, #f0fdfa 0%, #f8fafc 100%);
}

.va-table td {
  padding: 14px 16px;
  font-size: 0.875rem;
  color: #334155;
  border-bottom: 1px solid #e2e8f0;
}

.va-td-rank {
  width: 50px;
}

.va-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e2e8f0;
  font-weight: 600;
  font-size: 0.8rem;
  color: #475569;
}

.va-rank-gold {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #fff;
}
.va-rank-silver {
  background: linear-gradient(135deg, #cbd5e1, #94a3b8);
  color: #fff;
}
.va-rank-bronze {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
}

.va-td-tier {
  width: 50px;
}

.va-tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
}

.va-td-vendor {
  min-width: 180px;
}

.va-vendor-name {
  font-weight: 600;
  color: #133452;
  margin-bottom: 2px;
}

.va-vendor-id {
  font-size: 0.7rem;
  color: #94a3b8;
}

.va-td-number {
  text-align: right;
  font-family: "Roboto Mono", monospace;
  font-weight: 500;
}

.va-margin-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.va-margin-high {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}
.va-margin-medium {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
}
.va-margin-low {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.va-td-action {
  width: 50px;
  text-align: center;
}

.va-btn-detail {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  opacity: 0.6;
  transition: all 0.2s ease;
}

.va-btn-detail:hover {
  opacity: 1;
  transform: scale(1.2);
}

/* Modal */
.va-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease;
}

.va-modal-open {
  display: flex;
}

.va-modal-content {
  background: #fff;
  border-radius: 16px;
  width: 90%;
  max-width: 700px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease;
}

.va-modal-large {
  max-width: 900px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.va-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: linear-gradient(135deg, #133452 0%, #1a4a6e 100%);
  color: #fff;
}

.va-modal-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
}

.va-modal-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.va-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.va-modal-body {
  padding: 24px;
  max-height: calc(90vh - 80px);
  overflow-y: auto;
}

/* Detail View */
.va-detail {
}

.va-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
}

.va-detail-rank {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.va-detail-rank-num {
  font-size: 2rem;
  font-weight: 800;
  color: #10b981;
}

.va-detail-rank-total {
  font-size: 0.75rem;
  color: #94a3b8;
}

.va-detail-dates {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: #64748b;
  text-align: right;
}

.va-detail-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.va-detail-kpi {
  background: #f8fafc;
  padding: 16px;
  border-radius: 10px;
  text-align: center;
  border: 1px solid #e2e8f0;
}

.va-detail-kpi-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  color: #133452;
}

.va-detail-kpi-label {
  display: block;
  font-size: 0.7rem;
  color: #64748b;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.va-detail-section {
  margin-bottom: 24px;
}

.va-detail-section h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #133452;
  margin: 0 0 12px 0;
}

.va-detail-chart {
  min-height: 200px;
}

.va-detail-chart-small {
  min-height: 150px;
}

.va-detail-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.va-detail-list {
  max-height: 300px;
  overflow-y: auto;
}

.va-detail-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 6px;
  border: 1px solid #e2e8f0;
}

.va-detail-list-rank {
  width: 24px;
  height: 24px;
  background: #218d8d;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.va-detail-list-name {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.va-detail-list-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: #133452;
  flex-shrink: 0;
}

/* Tooltip */
.va-tooltip {
  padding: 12px;
  background: #133452;
  border-radius: 8px;
  color: #fff;
  font-size: 0.85rem;
  min-width: 180px;
}

.va-tooltip-title {
  font-weight: 600;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.va-tooltip-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.va-tooltip-row span {
  color: rgba(255, 255, 255, 0.7);
}

.va-tooltip-hint {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}

/* Loading & Error */
.va-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #64748b;
  font-size: 0.95rem;
}

.va-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: #218d8d;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.va-error {
  padding: 40px 20px;
  text-align: center;
  color: #ef4444;
  font-size: 0.9rem;
}

.va-empty {
  padding: 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
  .va-header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .va-controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  .va-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .va-charts-row {
    grid-template-columns: 1fr;
  }

  .va-table-header {
    flex-direction: column;
    gap: 12px;
  }

  .va-table-controls {
    flex-direction: column;
    width: 100%;
  }

  .va-search {
    width: 100%;
  }

  .va-select-small {
    width: 100%;
  }

  .va-modal-content {
    width: 95%;
    max-height: 95vh;
  }

  .va-detail-kpis {
    grid-template-columns: repeat(2, 1fr);
  }

  .va-detail-columns {
    grid-template-columns: 1fr;
  }

  .va-tiers-legend {
    grid-template-columns: 1fr;
  }
}
