/*
 * Commands Listing Page Styles
 * Used by: layouts/page/commands.html (/commands page - listing of all commands)
 * Do NOT confuse with:
 *   - command-single.css (for individual command pages like /Add-DbaAgDatabase)
 *   - command-docs.css (for documentation styling)
 */

:root {
  /* GitHub Light Theme Colors */
  --bg-light: #ffffff;
  --bg-card-light: #ffffff;
  --bg-hover-light: #f6f8fa;
  --bg-card-gray: #f6f8fa;
  --text-light: #1f2328;
  --text-muted-light: #59636e;
  --border-light: #d1d9e0;
  --border-emphasis-light: #818b98;

  /* GitHub Accent Colors */
  --accent-blue: #0969da;
  --accent-blue-hover: #0860ca;
  --accent-green: #22C55E;
  --accent-green-hover: #1a7f37;
  --accent-gray: #59636e;

  /* GitHub Shadows - More defined */
  --shadow-sm-light: 0 1px 0 rgba(27, 31, 35, 0.04), 0 0 0 1px rgba(27, 31, 35, 0.04);
  --shadow-md-light: 0 3px 6px rgba(140, 149, 159, 0.15);
  --shadow-lg-light: 0 8px 24px rgba(140, 149, 159, 0.2);
  --shadow-xl-light: 0 12px 28px rgba(140, 149, 159, 0.25);
}

/* Default - Light mode */
body {
  --bg-primary: var(--bg-light);
  --bg-card: var(--bg-card-light);
  --bg-hover: var(--bg-hover-light);
  --text-primary: var(--text-light);
  --text-secondary: var(--text-muted-light);
  --border: var(--border-light);
  --shadow-sm: var(--shadow-sm-light);
  --shadow-md: var(--shadow-md-light);
  --shadow-lg: var(--shadow-lg-light);
  --shadow-xl: var(--shadow-xl-light);
}

/* Global Styles */
.commands-container {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 200px);
  transition: background-color 0.3s ease, color 0.3s ease;
  background-color: var(--bg-light);
  color: var(--text-light);
}

/* Header Section */
.commands-header {
  padding: 120px 40px 60px 40px;
  text-align: center;
  margin-top: 0;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-light);
}

.commands-header-content {
  max-width: 800px;
  margin: 0 auto;
}

.commands-title {
  font-size: 40px;
  font-weight: 700;
  margin: 0 0 10px 0;
  letter-spacing: -0.5px;
  color: var(--text-light);
}

.commands-subtitle {
  font-size: 16px;
  margin: 0 0 30px 0;
  color: var(--text-muted-light);
  font-weight: 500;
}

/* Search Input */
.search-container {
  position: relative;
  max-width: 500px;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  padding: 14px 44px 14px 16px;
  font-size: 16px;
  border-radius: 6px;
  transition: all 0.2s ease;
  border: 1px solid var(--border-light);
  background-color: var(--bg-hover-light);
  color: var(--text-light);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  background-color: var(--bg-card-light);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.12);
}

.search-input::placeholder {
  color: var(--text-secondary);
}

.search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 44px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: none;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.search-clear:hover {
  color: var(--text-primary);
}

.search-clear.visible {
  display: flex;
}

/* Layout */
.commands-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 40px;
  padding: 40px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* Sidebar */
.commands-sidebar {
  position: sticky;
  top: 100px;
  height: fit-content;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 24px 20px;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
}

/* Modern Scrollbar Styling - Sidebar */
.commands-sidebar::-webkit-scrollbar {
  width: 6px;
}

.commands-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.commands-sidebar::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 10px;
  transition: background-color 0.3s ease;
}

.commands-sidebar:hover::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.15);
}

.commands-sidebar::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.25);
}

.commands-sidebar {
  background-color: transparent;
  border: 1px solid var(--border-light);
  border-radius: 6px;
}

.filter-section {
  margin-bottom: 32px;
}

.filter-section:last-child {
  margin-bottom: 0;
}

.filter-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin: 0 0 12px 0;
  display: block;
}

.filter-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Category items - same style as action items */
.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.15s ease;
  user-select: none;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  position: relative;
}

.category-item:hover {
  background-color: var(--bg-hover-light);
}

.category-item.active {
  background-color: transparent;
  color: var(--accent-blue);
  font-weight: 600;
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent-blue);
}

.category-item .filter-count {
  font-size: 12px;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 12px;
  background-color: rgba(175, 184, 193, 0.2);
  color: var(--text-muted-light);
}

.category-item.active .filter-count {
  background-color: rgba(9, 105, 218, 0.12);
  color: var(--accent-blue);
}

/* Shared filter count styling */
.filter-count {
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: right;
  padding: 2px 8px;
  border-radius: 4px;
}

/* Action Filters - Styled like categories */
.filter-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.action-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.15s ease;
  user-select: none;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  position: relative;
}

.action-item:hover {
  background-color: var(--bg-hover-light);
}

.action-item.active {
  background-color: transparent;
  color: var(--accent-blue);
  font-weight: 600;
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent-blue);
}

.action-item .filter-count {
  font-size: 12px;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 12px;
  background-color: rgba(175, 184, 193, 0.2);
  color: var(--text-muted-light);
}

.action-item.active .filter-count {
  background-color: rgba(9, 105, 218, 0.12);
  color: var(--accent-blue);
}

/* Popular Button */
.popular-button {
  width: 100%;
  padding: 12px 16px;
  background-color: transparent;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 14px;
  position: relative;
}

.popular-button:hover {
  background-color: var(--bg-hover-light);
  border-color: var(--accent-blue);
}

.popular-button.active {
  background-color: transparent;
  color: var(--accent-blue);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent-blue);
}

/* Main Content */
.commands-main {
  display: flex;
  flex-direction: column;
}

.commands-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
}

.commands-count {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
  font-weight: 600;
}

.sort-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sort-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.sort-select {
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background-color: var(--bg-hover-light);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sort-select:hover {
  border-color: var(--accent-blue);
}

.sort-select:focus {
  outline: none;
  border-color: var(--accent-blue);
  background-color: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.12);
}

/* Command Grid */
.commands-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
  animation: fadeIn 0.3s ease;
}

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

/* Popularity Note */
.popularity-note {
  margin-top: 24px;
  margin-bottom: 8px;
  font-size: 13px;
  color: rgba(139, 148, 158, 0.7);
  font-style: italic;
  text-align: right;
  display: none;
}

.popularity-note.show {
  display: block;
}

.command-card {
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.15s ease;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  background-color: var(--bg-card-gray);
  border: 1px solid var(--border-light);
  color: var(--text-light);
}

.command-card:hover {
  background-color: var(--bg-card-light);
  border-color: var(--border-emphasis-light);
  box-shadow: var(--shadow-lg-light);
}

.command-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.command-name {
  font-size: 20px;
  font-weight: 700;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--accent-green);
  margin: 0;
  word-break: break-word;
  flex: 1;
}

.command-popular {
  font-size: 18px;
  flex-shrink: 0;
}

.command-description {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.command-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.tag {
  display: inline-block;
  padding: 4px 8px;
  background-color: var(--bg-hover-light);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-category {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-weight: 500;
}

/* No Results State */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 40px;
}

.no-results.hidden {
  display: none;
}

.no-results-text {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--text-primary);
}

.no-results-hint {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 24px 0;
}

.reset-button {
  padding: 10px 20px;
  background-color: var(--accent-blue);
  color: white;
  border: 1px solid var(--accent-blue);
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.reset-button:hover {
  background-color: var(--accent-blue-hover);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .commands-header {
    padding: 40px 20px;
  }

  .commands-title {
    font-size: 28px;
  }

  .commands-subtitle {
    font-size: 14px;
  }

  .commands-layout {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 20px;
  }

  .commands-sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
  }

  .filter-section {
    margin-bottom: 0;
  }

  .commands-header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .sort-container {
    width: 100%;
  }

  .sort-select {
    width: 100%;
  }

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

@media (max-width: 480px) {
  .commands-title {
    font-size: 24px;
  }

  .commands-layout {
    padding: 16px;
  }

  .commands-sidebar {
    grid-template-columns: 1fr;
  }

  .command-card {
    padding: 16px;
  }

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

  .command-description {
    font-size: 13px;
  }
}

/* Loading State */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Accessibility */
.filter-input:focus-visible,
.action-item:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* Print Styles */
@media print {
  .commands-header,
  .commands-sidebar,
  .commands-header-bar {
    display: none;
  }

  .commands-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .command-card {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}
