/* Action Desk - Minimal Styling */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background: #f5f5f5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
header {
  text-align: center;
  padding: 40px 20px;
  background: white;
  border-radius: 8px;
  margin-bottom: 30px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
  font-size: 2.5rem;
  color: #f38020;
  margin-bottom: 10px;
}

.subtitle {
  color: #666;
  font-size: 1.1rem;
}

/* Controls */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 15px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-primary {
  background: #f38020;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #d97010;
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.last-updated {
  color: #666;
  font-size: 0.9rem;
}

/* Loading & Error States */
.loading {
  text-align: center;
  padding: 40px;
  background: white;
  border-radius: 8px;
  color: #666;
  font-size: 1.1rem;
}

.error {
  padding: 15px;
  background: #fee;
  border: 1px solid #fcc;
  border-radius: 5px;
  color: #c00;
  margin-bottom: 20px;
}

/* Chart Container */
.chart-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  padding: 25px;
  margin-bottom: 30px;
}

.chart-container h2 {
  color: #333;
  font-size: 1.3rem;
  margin-bottom: 20px;
  text-align: center;
}

.chart-wrapper {
  max-width: 300px;
  margin: 0 auto;
}

/* Tooltip */
.urgency-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.info-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  background: #4a90e2;
  color: white;
  border-radius: 50%;
  text-align: center;
  font-size: 11px;
  line-height: 16px;
  cursor: help;
  font-weight: bold;
  font-family: serif;
}

.tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  z-index: 1000;
  background: #333;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  line-height: 1.4;
  width: 240px;
  top: 130%;
  left: 50%;
  transform: translateX(-50%);
  transition: opacity 0.3s;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  white-space: normal;
}

.tooltip-text::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent #333 transparent;
}

.urgency-tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Insights Table */
#insights-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  overflow: hidden;
}

#insights-table {
  width: 100%;
  border-collapse: collapse;
}

#insights-table thead {
  background: #f9f9f9;
  border-bottom: 2px solid #e0e0e0;
}

#insights-table th {
  padding: 15px;
  text-align: left;
  font-weight: 600;
  color: #555;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#insights-table td {
  padding: 15px;
  border-bottom: 1px solid #f0f0f0;
}

#insights-table tbody tr:hover {
  background: #f9f9f9;
}

#insights-table tbody tr:last-child td {
  border-bottom: none;
}

/* Urgency Badge */
.urgency-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 50px;
  text-align: center;
}

.urgency-critical {
  background: #fee;
  color: #c00;
  border: 1px solid #fcc;
}

.urgency-high {
  background: #ffecd1;
  color: #d97010;
  border: 1px solid #ffd4a8;
}

.urgency-medium {
  background: #fff4e6;
  color: #996300;
  border: 1px solid #ffe4b3;
}

.urgency-low {
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

/* Text Utilities */
.text-center {
  text-align: center;
}

.text-muted {
  color: #999;
  font-size: 0.85rem;
  font-family: 'Courier New', monospace;
}

/* Expand Button */
.expand-header {
  width: 40px;
  text-align: center;
}

.expand-cell {
  text-align: center;
  width: 40px;
}

.expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  color: #f38020;
  padding: 5px 10px;
  transition: transform 0.2s;
}

.expand-btn:hover {
  transform: scale(1.2);
}

/* Detail Row */
.detail-row td {
  padding: 0 !important;
  background: #f9f9f9;
  border-top: none !important;
}

.breakdown-container {
  padding: 20px 30px;
  border-top: 2px solid #e0e0e0;
}

.breakdown-container h4 {
  margin-bottom: 15px;
  color: #555;
  font-size: 1rem;
}

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

.breakdown-item {
  display: flex;
  flex-direction: column;
  padding: 15px;
  background: white;
  border-radius: 5px;
  border-left: 3px solid #f38020;
}

.breakdown-label {
  font-size: 0.85rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}

.breakdown-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: #f38020;
  margin-bottom: 3px;
}

.breakdown-weight {
  font-size: 0.8rem;
  color: #999;
}

.urgency-explanation {
  padding: 15px;
  background: white;
  border-radius: 5px;
  border-left: 3px solid #4a90e2;
  color: #555;
  line-height: 1.6;
  margin: 0;
}

/* Empty State */
#empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

#empty-state p {
  font-size: 1.1rem;
}

/* API Info Section */
.api-info {
  margin-top: 40px;
  padding: 30px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.api-info h2 {
  margin-bottom: 20px;
  color: #333;
  font-size: 1.5rem;
}

.endpoint {
  margin-bottom: 15px;
  padding: 15px;
  background: #f9f9f9;
  border-left: 3px solid #f38020;
  border-radius: 4px;
}

.endpoint code {
  background: #333;
  color: #fff;
  padding: 4px 8px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
}

.endpoint p {
  margin-top: 8px;
  color: #666;
}

/* Footer */
footer {
  text-align: center;
  padding: 30px;
  color: #999;
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
  header h1 {
    font-size: 2rem;
  }

  .controls {
    flex-direction: column;
    gap: 10px;
  }

  #insights-table {
    font-size: 0.85rem;
  }

  #insights-table th,
  #insights-table td {
    padding: 8px;
  }

  /* Hide cluster ID on mobile but keep expand button */
  #insights-table th:nth-child(5),
  #insights-table td:nth-child(5) {
    display: none;
  }

  .breakdown-grid {
    grid-template-columns: 1fr;
  }

  .breakdown-container {
    padding: 15px;
  }

  .tooltip-text {
    width: 200px;
    font-size: 0.75rem;
    padding: 6px 10px;
  }

  .chart-wrapper {
    max-width: 250px;
  }
}

/* Prevent table overflow */
#insights-container {
  overflow-x: auto;
}

#insights-table {
  table-layout: auto;
  min-width: 100%;
}

#insights-table td {
  word-wrap: break-word;
  max-width: 300px;
}
