/**
 * Agent Panel Styles
 * Modal overlay, agent cards, badges, and configuration UI
 * Follows vibeWidgets STYLE_GUIDE.md patterns
 */

/* ===========================
   Modal Overlay
   =========================== */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgb(0 0 0 / 85%);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #1e293b;
  border-radius: 12px;
  box-shadow: 0 24px 48px rgb(0 0 0 / 50%);
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-modal-content {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* ===========================
   Agent Panel Header
   =========================== */

.agent-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 30px;
  border-bottom: 1px solid rgb(100 116 139 / 20%);
}

.agent-panel-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: #f8fafc;
}

/* ===========================
   Toolbar
   =========================== */

.agent-panel-toolbar {
  display: flex;
  gap: 12px;
  padding: 18px 30px;
  border-bottom: 1px solid rgb(100 116 139 / 15%);
  background: rgb(15 23 42 / 50%);
}

.agent-search-input {
  flex: 1;
  padding: 9px 18px;
  background: #0f172a;
  border: 1px solid rgb(100 116 139 / 30%);
  border-radius: 9px;
  color: #f8fafc;
  font-size: 15px;
  outline: none;
  transition: all 0.2s ease;
}

.agent-search-input:focus {
  border-color: #09f;
  box-shadow: 0 0 0 3px rgb(0 153 255 / 10%);
}

.agent-search-input::placeholder {
  color: #64748b;
}

/* ===========================
   Filters
   =========================== */

.agent-panel-filters {
  display: flex;
  gap: 9px;
  padding: 12px 30px;
  border-bottom: 1px solid rgb(100 116 139 / 15%);
  background: rgb(15 23 42 / 30%);
}

.filter-btn {
  padding: 6px 18px;
  background: transparent;
  border: 1px solid rgb(100 116 139 / 30%);
  border-radius: 18px;
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  background: rgb(100 116 139 / 10%);
  border-color: rgb(100 116 139 / 40%);
  color: #cbd5e1;
}

.filter-btn.active {
  background: #09f;
  border-color: #09f;
  color: #fff;
}

/* ===========================
   Agent List
   =========================== */

.agent-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 24px 30px;
  gap: 18px;
  display: flex;
  flex-direction: column;
}

.agent-panel-list::-webkit-scrollbar {
  width: 9px;
}

.agent-panel-list::-webkit-scrollbar-track {
  background: rgb(15 23 42 / 50%);
}

.agent-panel-list::-webkit-scrollbar-thumb {
  background: rgb(100 116 139 / 40%);
  border-radius: 9px;
}

.agent-panel-list::-webkit-scrollbar-thumb:hover {
  background: rgb(100 116 139 / 60%);
}

.agent-empty-state {
  text-align: center;
  padding: 60px 30px;
  color: #64748b;
  font-size: 15px;
}

/* ===========================
   Agent Card
   =========================== */

.agent-card-base {
  background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
  border: 1px solid rgb(100 116 139 / 30%);
  border-radius: 12px;
  padding: 18px;
  transition: all 0.3s ease;
  cursor: default;
}

.agent-card-base:hover {
  border-color: rgb(0 153 255 / 50%);
  box-shadow: 0 6px 18px rgb(0 153 255 / 15%);
  transform: translateY(-2px);
}

.agent-card-base.inactive {
  opacity: 0.6;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* Agent Card Header */

.agent-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.agent-card-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-icon {
  font-size: 27px;
  line-height: 1;
}

.agent-name {
  font-size: 18px;
  font-weight: 600;
  color: #f8fafc;
}

.agent-status-badge {
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background: rgb(34 197 94 / 20%);
  color: #4ade80;
  border: 1px solid rgb(34 197 94 / 30%);
}

.badge-muted {
  background: rgb(100 116 139 / 20%);
  color: #94a3b8;
  border: 1px solid rgb(100 116 139 / 30%);
}

/* Agent Card Body */

.agent-card-body {
  margin-bottom: 15px;
}

.agent-description {
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 12px;
}

.agent-stats {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.badge-base {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}

.badge-primary {
  background: rgb(0 153 255 / 20%);
  color: #38bdf8;
  border-color: rgb(0 153 255 / 30%);
}

/* Agent Card Footer */

.agent-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid rgb(100 116 139 / 20%);
}

.agent-last-used {
  font-size: 12px;
  color: #64748b;
}

.agent-card-actions {
  display: flex;
  gap: 6px;
}

/* ===========================
   Buttons
   =========================== */

.btn-base {
  padding: 9px 18px;
  background: #334155;
  border: 1px solid rgb(100 116 139 / 30%);
  border-radius: 9px;
  color: #f8fafc;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-base:hover {
  background: #475569;
  border-color: rgb(100 116 139 / 50%);
  transform: translateY(-1px);
}

.btn-base:active {
  transform: translateY(0);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-icon {
  padding: 9px;
  background: transparent;
  border: none;
}

.btn-primary {
  background: #09f;
  border-color: #09f;
  color: #fff;
}

.btn-primary:hover {
  background: #08e;
  border-color: #08e;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: rgb(100 116 139 / 20%);
  border-color: rgb(100 116 139 / 30%);
}

.btn-danger {
  color: #f87171;
}

.btn-danger:hover {
  background: rgb(239 68 68 / 10%);
  border-color: rgb(239 68 68 / 30%);
}

/* ===========================
   Footer
   =========================== */

.agent-panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 30px;
  border-top: 1px solid rgb(100 116 139 / 20%);
  background: rgb(15 23 42 / 50%);
  color: #64748b;
  font-size: 13px;
}

.agent-footer-actions {
  display: flex;
  gap: 9px;
}

/* ===========================
   Icons (Iconoir)
   =========================== */

.iconoir-plus::before { content: "\\e900"; }
.iconoir-cancel::before { content: "\\e901"; }
.iconoir-edit::before { content: "\\e902"; }
.iconoir-copy::before { content: "\\e903"; }
.iconoir-trash::before { content: "\\e904"; }
.iconoir-download::before { content: "\\e905"; }
.iconoir-upload::before { content: "\\e906"; }
.iconoir-brain::before { content: "\\e907"; }

/* Use actual iconoir classes if available */
[class^="iconoir-"],
[class*=" iconoir-"] {
  font-family: iconoir, sans-serif;
  font-style: normal;
  font-weight: 400;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===========================
   Responsive Design
   =========================== */

@media (width <= 768px) {
  .modal-content {
    width: 95%;
    max-height: 95vh;
  }

  .agent-panel-header,
  .agent-panel-toolbar,
  .agent-panel-filters,
  .agent-panel-list,
  .agent-panel-footer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .agent-panel-toolbar {
    flex-direction: column;
  }

  .agent-card-footer {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .agent-card-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (width <= 480px) {
  .agent-panel-header h2 {
    font-size: 20px;
  }

  .agent-card-base {
    padding: 15px;
  }

  .agent-name {
    font-size: 16px;
  }

  .agent-stats {
    font-size: 11px;
  }

  .btn-sm {
    padding: 5px 10px;
    font-size: 12px;
  }
}

/* ===========================
   Utilities
   =========================== */

.flex-row-center {
  display: flex;
  align-items: center;
  gap: 6px;
}

.flex-row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ===========================
   Animation
   =========================== */

.modal-overlay[style*="display: flex"] .modal-content {
  animation: fadeInScale 0.2s ease-out;
}

/* ===========================
   Agent Configuration Modal
   =========================== */

.agent-config-modal-content {
  max-width: 1200px;
  max-height: 90vh;
}

.agent-config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 30px;
  border-bottom: 1px solid rgb(100 116 139 / 20%);
}

.agent-config-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: #f8fafc;
}

.agent-config-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.agent-config-tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  background: rgb(15 23 42 / 50%);
  border-right: 1px solid rgb(100 116 139 / 20%);
  min-width: 180px;
}

.agent-config-tab {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #94a3b8;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.agent-config-tab:hover {
  background: rgb(100 116 139 / 10%);
  color: #cbd5e1;
}

.agent-config-tab.active {
  background: #09f;
  border-color: #09f;
  color: #fff;
}

.agent-config-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 30px;
}

.agent-config-content::-webkit-scrollbar {
  width: 9px;
}

.agent-config-content::-webkit-scrollbar-track {
  background: rgb(15 23 42 / 50%);
}

.agent-config-content::-webkit-scrollbar-thumb {
  background: rgb(100 116 139 / 40%);
  border-radius: 9px;
}

.agent-config-tab-content h3 {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 600;
  color: #f8fafc;
}

.agent-config-tab-content h4 {
  margin: 24px 0 12px;
  font-size: 16px;
  font-weight: 500;
  color: #cbd5e1;
}

.agent-config-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 30px;
  border-top: 1px solid rgb(100 116 139 / 20%);
  background: rgb(15 23 42 / 50%);
}

/* Form Elements */

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 500;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 15px;
  background: #0f172a;
  border: 1px solid rgb(100 116 139 / 30%);
  border-radius: 9px;
  color: #f8fafc;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: #09f;
  box-shadow: 0 0 0 3px rgb(0 153 255 / 10%);
}

.form-textarea {
  resize: vertical;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
}

.form-range {
  width: 100%;
  height: 6px;
  background: rgb(100 116 139 / 30%);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #09f;
  border-radius: 50%;
  cursor: pointer;
}

.form-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #09f;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.form-hint {
  display: block;
  margin-top: 6px;
  color: #64748b;
  font-size: 12px;
}

.form-hint code {
  background: rgb(0 153 255 / 10%);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

/* Tools List */

.tools-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tool-item {
  padding: 15px;
  background: rgb(15 23 42 / 50%);
  border: 1px solid rgb(100 116 139 / 20%);
  border-radius: 9px;
}

.tool-item-header {
  margin-bottom: 6px;
}

.tool-item-header label {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

.tool-description {
  margin: 0;
  padding-left: 27px;
  color: #94a3b8;
  font-size: 13px;
}

/* Placeholder State */

.agent-config-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 30px;
  text-align: center;
  color: #64748b;
}

.agent-config-placeholder p {
  margin: 12px 0 0;
  font-size: 15px;
}

/* Responsive */

@media (width <= 768px) {
  .agent-config-modal-content {
    width: 95%;
    max-height: 95vh;
  }

  .agent-config-body {
    flex-direction: column;
  }

  .agent-config-tabs {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid rgb(100 116 139 / 20%);
    min-width: auto;
  }

  .agent-config-tab {
    white-space: nowrap;
  }

  .agent-config-tab span {
    display: none;
  }

  .agent-config-content {
    padding: 18px;
  }
}

/* ===========================
   Loading States & Animations
   =========================== */

/* Loading spinner */
.agent-loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgb(99 102 241 / 30%);
  border-radius: 50%;
  border-top-color: #6366f1;
  animation: spin 0.8s linear infinite;
}

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

/* Loading overlay for panels */
.agent-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgb(15 23 42 / 95%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.agent-loading-content {
  text-align: center;
  color: #e2e8f0;
}

.agent-loading-content .agent-loading-spinner {
  width: 40px;
  height: 40px;
  margin-bottom: 16px;
}

.agent-card-base {
  animation: fadeInUp 0.3s ease-out;
}

.modal-content {
  animation: slideInRight 0.3s ease-out;
}

.agent-badge-active {
  animation: pulse 2s ease-in-out infinite;
}

.agent-card-skeleton {
  background: linear-gradient(
    90deg,
    rgb(51 65 85 / 50%) 25%,
    rgb(51 65 85 / 70%) 50%,
    rgb(51 65 85 / 50%) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 12px;
  height: 120px;
  margin-bottom: 12px;
}

/* Success/Error notifications */
.agent-notification {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 16px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgb(0 0 0 / 30%);
  z-index: 10000;
  animation: slideInRight 0.3s ease-out;
  max-width: 400px;
}

.agent-notification-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: 1px solid rgb(255 255 255 / 20%);
}

.agent-notification-error {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  border: 1px solid rgb(255 255 255 / 20%);
}

.agent-notification-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
  border: 1px solid rgb(255 255 255 / 20%);
}

.agent-notification-info {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  border: 1px solid rgb(255 255 255 / 20%);
}

/* Button loading state */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid rgb(255 255 255 / 30%);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

/* Tooltip improvements */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 6px 12px;
  background: rgb(15 23 42 / 95%);
  color: #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1000;
}

[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* Empty state styling */
.agent-empty-state {
  text-align: center;
  padding: 60px 24px;
  color: #94a3b8;
}

.agent-empty-state i {
  font-size: 48px;
  opacity: 0.3;
  margin-bottom: 16px;
}

.agent-empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #cbd5e1;
}

.agent-empty-state p {
  font-size: 14px;
  margin-bottom: 24px;
}

/* Info box for API configuration */
.agent-config-info-box {
  background: linear-gradient(135deg, rgb(59 130 246 / 10%) 0%, rgb(37 99 235 / 10%) 100%);
  border: 1px solid rgb(59 130 246 / 30%);
  border-radius: 8px;
  padding: 16px;
  margin-top: 24px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.agent-config-info-box i {
  font-size: 20px;
  color: #3b82f6;
  flex-shrink: 0;
  margin-top: 2px;
}

.agent-config-info-box p {
  margin: 0;
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1.6;
}

.agent-config-info-box a {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 500;
}

.agent-config-info-box a:hover {
  color: #93c5fd;
  text-decoration: underline;
}
