/* function-palette.css — AI-Do v4.0 Function Palette (Skills) */

/* ===== Right Panel Structure ===== */
.right-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--glass-border);
  transition: width var(--transition-normal);
}

.right-panel-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-md) var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.right-panel-header h2 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.right-panel-toggle {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast);
}

.right-panel-toggle:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
  border-color: var(--glass-border-light);
}

.right-panel-content {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-md);
  flex: 1;
  gap: var(--space-lg);
}

.right-panel-content::-webkit-scrollbar {
  width: 5px;
}

.right-panel-content::-webkit-scrollbar-track {
  background: transparent;
}

.right-panel-content::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: var(--radius-full);
}

.right-panel-content::-webkit-scrollbar-thumb:hover {
  background: var(--glass-border-light);
}

/* ===== Category Groups ===== */
.skill-category {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.skill-category-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0 var(--space-xs);
}

.skill-category-header svg {
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.skill-category-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.skill-category-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* ===== Skill Cards ===== */
.skill-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.skill-card:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-light);
  transform: translateY(-1px);
  box-shadow: var(--glass-shadow);
}

.skill-card:active {
  transform: translateY(0);
  box-shadow: none;
}

/* Card icon circle */
.skill-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: box-shadow var(--transition-fast);
}

.skill-card-icon svg {
  width: 16px;
  height: 16px;
  color: #fff;
}

/* Card text area */
.skill-card-info {
  flex: 1;
  min-width: 0;
}

.skill-card-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skill-card-desc {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: var(--line-height-normal);
}

/* ===== Category Color Coding ===== */
.skill-card[data-category="Search"] .skill-card-icon { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.skill-card[data-category="Retrieve"] .skill-card-icon { background: linear-gradient(135deg, #34d399, #10b981); }
.skill-card[data-category="Analyze"] .skill-card-icon { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.skill-card[data-category="Create"] .skill-card-icon { background: linear-gradient(135deg, #a78bfa, #8b5cf6); }
.skill-card[data-category="Configure"] .skill-card-icon { background: linear-gradient(135deg, #f472b6, #ec4899); }
.skill-card[data-category="Visualize"] .skill-card-icon { background: linear-gradient(135deg, #2dd4bf, #14b8a6); }
.skill-card[data-category="Journal"] .skill-card-icon { background: linear-gradient(135deg, #fb923c, #f97316); }
.skill-card[data-category="Evolve"] .skill-card-icon { background: linear-gradient(135deg, #e879f9, #d946ef); }

/* Category hover tint */
.skill-card[data-category="Search"]:hover { border-color: rgba(96, 165, 250, 0.3); }
.skill-card[data-category="Retrieve"]:hover { border-color: rgba(52, 211, 153, 0.3); }
.skill-card[data-category="Analyze"]:hover { border-color: rgba(251, 191, 36, 0.3); }
.skill-card[data-category="Create"]:hover { border-color: rgba(167, 139, 250, 0.3); }
.skill-card[data-category="Configure"]:hover { border-color: rgba(244, 114, 182, 0.3); }
.skill-card[data-category="Visualize"]:hover { border-color: rgba(45, 212, 191, 0.3); }
.skill-card[data-category="Journal"]:hover { border-color: rgba(251, 146, 60, 0.3); }
.skill-card[data-category="Evolve"]:hover { border-color: rgba(232, 121, 249, 0.3); }

/* ===== Running State ===== */
.skill-card.running {
  border-color: var(--accent-primary);
  box-shadow:
    0 0 12px rgba(99, 102, 241, 0.2),
    0 0 24px rgba(99, 102, 241, 0.1);
  animation: skillRunPulse 2s ease-in-out infinite;
}

@keyframes skillRunPulse {
  0%, 100% {
    box-shadow:
      0 0 12px rgba(99, 102, 241, 0.2),
      0 0 24px rgba(99, 102, 241, 0.1);
  }
  50% {
    box-shadow:
      0 0 16px rgba(99, 102, 241, 0.35),
      0 0 32px rgba(99, 102, 241, 0.15);
  }
}

.skill-card.running .skill-card-name::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent-primary-light);
  border-radius: 50%;
  margin-left: var(--space-sm);
  vertical-align: middle;
  animation: statusBlink 1.2s ease-in-out infinite;
}

/* ===== Skill Detail Popover ===== */
.skill-detail {
  position: absolute;
  inset: 0;
  z-index: var(--z-dropdown);
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(var(--blur-lg));
  -webkit-backdrop-filter: blur(var(--blur-lg));
  border-left: 1px solid var(--glass-border-light);
  display: flex;
  flex-direction: column;
  padding: var(--space-lg);
  gap: var(--space-md);
  animation: fadeInScale var(--transition-normal) ease-out forwards;
  overflow-y: auto;
}

[data-theme="light"] .skill-detail {
  background: rgba(248, 249, 252, 0.95);
}

.skill-detail-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
  z-index: 1;
}

.skill-detail-close:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.skill-detail-close svg {
  width: 14px;
  height: 14px;
}

.skill-detail-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.skill-detail-icon svg {
  width: 24px;
  height: 24px;
  color: #fff;
}

.skill-detail-name {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
}

.skill-detail-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: var(--line-height-relaxed);
}

.skill-detail-category {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: var(--space-xs) var(--space-sm);
  background: var(--glass-bg-active);
  border-radius: var(--radius-sm);
  width: fit-content;
}

.skill-detail-category svg {
  width: 12px;
  height: 12px;
}

.skill-detail-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  outline: none;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.skill-detail-input::placeholder {
  color: var(--text-tertiary);
}

.skill-detail-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.skill-detail-actions {
  margin-top: auto;
  padding-top: var(--space-md);
  border-top: 1px solid var(--glass-border);
}

.skill-detail-run {
  width: 100%;
  padding: var(--space-sm) var(--space-lg);
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: var(--font-size-base);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
  transition:
    box-shadow var(--transition-fast),
    transform var(--transition-fast);
}

.skill-detail-run:hover {
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}

.skill-detail-run:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.25);
}

.skill-detail-run svg {
  width: 16px;
  height: 16px;
}

/* ===== Empty State ===== */
.skill-palette-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-xl) var(--space-md);
  text-align: center;
  flex: 1;
}

.skill-palette-empty svg {
  width: 40px;
  height: 40px;
  color: var(--text-tertiary);
  opacity: 0.5;
}

.skill-palette-empty p {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  line-height: var(--line-height-relaxed);
}

/* ===== Right Panel Collapsed ===== */
#app.right-panel-collapsed .right-panel {
  width: var(--right-panel-collapsed-width);
  overflow: hidden;
}

#app.right-panel-collapsed .right-panel-header h2 {
  display: none;
}

#app.right-panel-collapsed .right-panel-header {
  justify-content: center;
  padding: var(--space-md) var(--space-xs);
}

#app.right-panel-collapsed .right-panel-toggle svg {
  transform: rotate(180deg);
}

#app.right-panel-collapsed .right-panel-content {
  padding: var(--space-sm) var(--space-xs);
  gap: var(--space-sm);
  align-items: center;
}

#app.right-panel-collapsed .skill-category-header,
#app.right-panel-collapsed .skill-card-info {
  display: none;
}

#app.right-panel-collapsed .skill-category-list {
  align-items: center;
}

#app.right-panel-collapsed .skill-card {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: var(--radius-sm);
}

#app.right-panel-collapsed .skill-card-icon {
  width: 28px;
  height: 28px;
}

#app.right-panel-collapsed .skill-card-icon svg {
  width: 14px;
  height: 14px;
}

#app.right-panel-collapsed .skill-detail {
  display: none;
}

/* ===== Collapsed icon-only categories ===== */
#app.right-panel-collapsed .skill-category {
  gap: var(--space-xs);
}

#app.right-panel-collapsed .skill-category + .skill-category {
  margin-top: var(--space-xs);
  padding-top: var(--space-xs);
  border-top: 1px solid var(--glass-border);
}

/* ===== Full View (#view-skills) ===== */
.skills-full-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.skills-full-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.skills-full-header h2 {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.skills-full-header .glass-button-icon {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
}

.skills-full-header .glass-button-icon:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.skills-full-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg) var(--space-xl);
}

.skills-full-body::-webkit-scrollbar {
  width: 6px;
}

.skills-full-body::-webkit-scrollbar-track {
  background: transparent;
}

.skills-full-body::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: var(--radius-full);
}

/* Full-view grid */
.skills-full-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 360px));
  justify-content: center;
  gap: var(--space-lg);
  max-width: 1200px;
  margin: 0 auto;
}

/* Full-view category group */
.skills-full-category {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.skills-full-category-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: var(--space-xs);
}

.skills-full-category-header svg {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
}

.skills-full-category-header span {
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

/* Full-view skill row */
.skill-full-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast);
}

.skill-full-row:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-light);
}

.skill-full-row-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.skill-full-row-icon svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

/* Inherit category colors for full rows */
.skill-full-row[data-category="Search"] .skill-full-row-icon { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.skill-full-row[data-category="Retrieve"] .skill-full-row-icon { background: linear-gradient(135deg, #34d399, #10b981); }
.skill-full-row[data-category="Analyze"] .skill-full-row-icon { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.skill-full-row[data-category="Create"] .skill-full-row-icon { background: linear-gradient(135deg, #a78bfa, #8b5cf6); }
.skill-full-row[data-category="Configure"] .skill-full-row-icon { background: linear-gradient(135deg, #f472b6, #ec4899); }
.skill-full-row[data-category="Visualize"] .skill-full-row-icon { background: linear-gradient(135deg, #2dd4bf, #14b8a6); }
.skill-full-row[data-category="Journal"] .skill-full-row-icon { background: linear-gradient(135deg, #fb923c, #f97316); }
.skill-full-row[data-category="Evolve"] .skill-full-row-icon { background: linear-gradient(135deg, #e879f9, #d946ef); }

.skill-full-row-info {
  flex: 1;
  min-width: 0;
}

.skill-full-row-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.skill-full-row-desc {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  line-height: var(--line-height-normal);
}

/* Toggle switch in full view */
.skill-full-row-toggle {
  flex-shrink: 0;
}

/* ===== Recent Executions ===== */
.skills-recent-section {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--glass-border);
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.skills-recent-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.skills-recent-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.skills-recent-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
}

.skills-recent-item-name {
  font-weight: 600;
  color: var(--text-primary);
}

.skills-recent-item-time {
  margin-left: auto;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.skills-recent-item-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skills-recent-item-status.success {
  background: var(--success);
}

.skills-recent-item-status.failed {
  background: var(--error);
}

.skills-recent-empty {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  text-align: center;
  padding: var(--space-md);
}

/* ===== Light Theme Overrides ===== */
[data-theme="light"] .right-panel {
  border-left-color: var(--glass-border);
}

[data-theme="light"] .skill-card {
  background: var(--glass-bg);
}

[data-theme="light"] .skill-card:hover {
  background: var(--glass-bg-hover);
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .skills-full-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 340px));
  }
}

@media (min-width: 1600px) {
  .skills-full-grid {
    max-width: 1400px;
  }
}

@media (max-width: 768px) {
  .skills-full-header {
    padding: var(--space-md);
  }

  .skills-full-body {
    padding: var(--space-md);
  }

  .skills-full-grid {
    grid-template-columns: 1fr;
  }
}
