/* ========== Vortex Monitoring - Styles ========== */

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
}

/* ========== Header ========== */
.header {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  padding: 20px 40px;
  border-bottom: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 24px;
  font-weight: 600;
  color: #f8fafc;
}

.header .status {
  display: flex;
  gap: 20px;
  align-items: center;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #94a3b8;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========== Container & Grid ========== */
.container {
  padding: 30px 40px;
  max-width: 1400px;
  margin: 0 auto;
}

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

/* ========== Widgets ========== */
.widget {
  background: #1e293b;
  border-radius: 12px;
  padding: 24px;
  border: 1px solid #334155;
}

.widget h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 10px;
}

.widget-icon {
  font-size: 20px;
}

/* ========== Sessions Live Widget ========== */
.session-subtitle {
  font-size: 14px;
  font-weight: 400;
  color: #64748b;
  margin-left: 8px;
}

.session-count {
  background: #3b82f6;
  color: white;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
}

.session-count.active {
  background: #22c55e;
}

.session-total {
  color: #64748b;
  font-size: 13px;
}

.sessions-info {
  margin-top: 12px;
  padding: 10px 12px;
  background: #0f172a;
  border-radius: 6px;
  font-size: 12px;
  color: #64748b;
  text-align: center;
}

/* Widget as flex column to allow sessions to fill available space */
.widget:has(.sessions-grid) {
  display: flex;
  flex-direction: column;
  min-height: 500px;
}

.widget:has(.sessions-grid) h2 {
  flex-shrink: 0;
}

.sessions-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 8px;
  flex: 1 1 auto;
  min-height: 0;
}

/* Custom scrollbar for sessions */
.sessions-grid::-webkit-scrollbar {
  width: 8px;
}

.sessions-grid::-webkit-scrollbar-track {
  background: #0f172a;
  border-radius: 4px;
}

.sessions-grid::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 4px;
  border: 2px solid #0f172a;
}

.sessions-grid::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Session Section Headers */
.session-section {
  margin-bottom: 16px;
}

.session-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 10px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-section-title .count {
  background: #334155;
  color: #94a3b8;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.session-section-title.active .count {
  background: #22c55e;
  color: white;
}

.session-section-title.idle .count {
  background: #f59e0b;
  color: white;
}

/* Dropdown toggle for idle sessions */
.session-section-title.dropdown-toggle {
  cursor: pointer;
  user-select: none;
  padding: 8px 12px;
  background: #0f172a;
  border-radius: 6px;
  border: 1px solid #334155;
  transition: all 0.2s;
}

.session-section-title.dropdown-toggle:hover {
  background: #1e293b;
  border-color: #475569;
}

.dropdown-arrow {
  margin-left: auto;
  font-size: 10px;
  color: #64748b;
  transition: transform 0.2s;
}

.session-dropdown {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.session-card {
  background: #0f172a;
  border-radius: 8px;
  padding: 14px 16px;
  border: 1px solid #334155;
  transition: all 0.2s;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.session-card:hover {
  border-color: #3b82f6;
  background: #1e293b;
}

.session-card.status-active {
  border-left: 3px solid #22c55e;
}

.session-card.status-idle {
  border-left: 3px solid #f59e0b;
  opacity: 0.85;
}

.session-main {
  flex: 1;
  min-width: 0;
}

.session-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.session-icon {
  font-size: 16px;
}

.session-name {
  font-size: 14px;
  font-weight: 600;
  color: #f8fafc;
}

.session-kind {
  font-size: 10px;
  color: #64748b;
  background: #0f172a;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #334155;
  text-transform: uppercase;
}

/* Legacy styles kept for compatibility */
.session-id {
  font-size: 13px;
  font-weight: 600;
  color: #f8fafc;
  font-family: monospace;
}

.session-type {
  font-size: 11px;
  color: #64748b;
  background: #0f172a;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #334155;
}

.session-model {
  font-size: 12px;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-model-row {
  margin-top: 6px;
}

.model-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.session-meta {
  text-align: right;
  flex-shrink: 0;
}

.session-activity {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
}

/* Legacy styles kept for compatibility */
.session-tokens {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: #64748b;
  font-size: 14px;
}

/* Session Detail Panel */
.session-detail {
  margin-top: 20px;
  padding: 16px;
  background: #0f172a;
  border-radius: 8px;
  border: 1px solid #334155;
  animation: slideIn 0.2s ease;
}

.session-detail.hidden {
  display: none;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #334155;
}

.detail-header h3 {
  font-size: 14px;
  color: #f8fafc;
}

.close-btn {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.close-btn:hover {
  background: #334155;
  color: #f8fafc;
}

.detail-content {
  font-size: 13px;
}

.detail-row {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.detail-label {
  color: #64748b;
  min-width: 80px;
}

.detail-value {
  color: #e2e8f0;
  font-weight: 500;
}

.detail-preview {
  margin-top: 12px;
  padding: 12px;
  background: #1e293b;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.5;
  max-height: 150px;
  overflow-y: auto;
}

.loading-detail, .empty-detail, .error-detail {
  text-align: center;
  padding: 30px;
  color: #64748b;
}

.error-detail {
  color: #ef4444;
}

/* Legacy Agents styles - kept for compatibility */
.agents-grid {
  display: grid;
  gap: 12px;
}

.agent-card {
  background: #0f172a;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #334155;
  transition: all 0.2s;
  max-width: 100%;
  overflow: hidden;
}

.agent-card:hover {
  border-color: #475569;
}

.agent-card.main {
  border-left: 4px solid #3b82f6;
}

.agent-info {
  min-width: 0;
  flex: 1;
}

.agent-info h3 {
  font-size: 14px;
  font-weight: 600;
  color: #f8fafc;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-info p {
  font-size: 12px;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #22c55e;
}

.agent-badge {
  background: #3b82f6;
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

/* ========== Usage Stats ========== */
.usage-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #0f172a;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chart-container {
  position: relative;
  height: 300px;
  margin-top: 20px;
}

/* ========== View Switcher ========== */
.view-switcher {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.view-btn {
  background: #0f172a;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.view-btn:hover {
  border-color: #475569;
  color: #e2e8f0;
}

.view-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

/* ========== Legend ========== */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #334155;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #94a3b8;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ========== Model Stats Table ========== */
.model-stats {
  margin-top: 20px;
}

.model-stats-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 12px;
  padding: 12px;
  background: #0f172a;
  border-radius: 6px 6px 0 0;
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.model-stats-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #334155;
  font-size: 13px;
  align-items: center;
}

.model-stats-row:last-child {
  border-bottom: none;
  border-radius: 0 0 6px 6px;
}

.model-name {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f8fafc;
  font-weight: 500;
}

.model-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/*
========== Upload Section - CONSERVÉ POUR UTILISATION FUTURE ==========
Décommenter avec le widget HTML pour réactiver l'import CSV
Le backend (/api/upload) reste fonctionnel

.upload-section {
  padding: 8px 0;
}

.upload-desc {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 16px;
  line-height: 1.5;
}

.upload-form {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.file-input {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 10px 14px;
  color: #e2e8f0;
  font-size: 13px;
  cursor: pointer;
  flex: 1;
  min-width: 200px;
}

.file-input:hover {
  border-color: #475569;
}

.upload-btn {
  background: #3b82f6;
  border: none;
  color: white;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.upload-btn:hover {
  background: #2563eb;
}

.upload-btn:active {
  transform: scale(0.98);
}

.upload-result {
  margin-top: 16px;
  font-size: 14px;
  font-weight: 500;
}

.upload-success {
  color: #22c55e;
}

.upload-error {
  color: #ef4444;
}

.upload-loading {
  color: #3b82f6;
}

.upload-stats {
  margin-top: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  background: #0f172a;
  border-radius: 8px;
  padding: 16px;
}

.stat-item {
  font-size: 13px;
  color: #94a3b8;
}

.stat-item strong {
  color: #f8fafc;
  font-size: 18px;
  display: block;
  margin-bottom: 4px;
}
*/

/* ========== Refresh Indicator ========== */
.refresh-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #1e293b;
  padding: 12px 20px;
  border-radius: 8px;
  border: 1px solid #334155;
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 10px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #334155;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

/* Tablette et mobile (max-width: 768px) */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 20px;
  }
  
  .header .status {
    flex-wrap: wrap;
    gap: 12px;
  }
  
  .container {
    padding: 16px;
  }
  
  .grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .widget {
    max-width: 100%;
    overflow: hidden;
  }
  
  .usage-stats {
    grid-template-columns: 1fr;
  }
  
  .stat-value {
    font-size: 24px;
  }
  
  .chart-container {
    height: 220px;
  }
  
  /* Tableau modèles : scroll horizontal */
  .model-stats {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .model-stats-header,
  .model-stats-row {
    min-width: 480px;
    grid-template-columns: 1.5fr 0.8fr 0.8fr 0.8fr 0.8fr;
    font-size: 11px;
  }
  
  .agent-card {
    padding: 12px;
    gap: 8px;
  }
  
  .agent-info h3 {
    font-size: 13px;
    max-width: calc(100vw - 140px);
  }
  
  .agent-info p {
    font-size: 11px;
    max-width: calc(100vw - 140px);
  }
  
  .agent-status {
    flex-shrink: 0;
    font-size: 11px;
  }
  
  .agent-badge {
    font-size: 9px;
    padding: 1px 6px;
  }
  
  .refresh-indicator {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .widget h2 {
    font-size: 16px;
  }

  /* Styles upload désactivés - voir section Upload Section en haut du fichier
  .upload-form {
    flex-direction: column;
    align-items: stretch;
  }

  .file-input {
    width: 100%;
  }

  .upload-btn {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
  */

/* Petit mobile (max-width: 480px) */
@media (max-width: 480px) {
  .header h1 {
    font-size: 18px;
  }
  
  .header .status {
    gap: 8px;
  }
  
  .status-item {
    font-size: 12px;
  }
  
  .widget {
    padding: 16px;
    border-radius: 10px;
  }
  
  .view-switcher {
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .view-btn {
    padding: 6px 12px;
    font-size: 12px;
  }
  
  .agent-info h3 {
    font-size: 13px;
  }
  
  .agent-info p {
    font-size: 11px;
  }
  
  .agent-status {
    font-size: 11px;
  }
  
  .refresh-indicator {
    padding: 10px 14px;
    font-size: 11px;
  }
}

/* Très petit écran (max-width: 360px) */
@media (max-width: 360px) {
  .container {
    padding: 12px;
  }
  
  .header {
    padding: 12px 16px;
  }
  
  .header h1 {
    font-size: 16px;
  }
  
  .widget {
    padding: 12px;
  }
  
  .stat-value {
    font-size: 20px;
  }
  
  .chart-container {
    height: 180px;
  }
}
