/* ==========================================================================
   Global Features Styles - Command Palette, Breadcrumbs, Back-to-Top
   ========================================================================== */

/* ==========================================================================
   COMMAND PALETTE (Ctrl+K)
   ========================================================================== */

.command-palette {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 9000);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

.command-palette.hidden {
  display: none;
}

/* Backdrop */
.command-palette__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(155, 155, 155, 0.095);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity var(--duration-normal, 0.3s) var(--ease-out, ease-out);
}

.command-palette--open .command-palette__backdrop {
  opacity: 1;
}

/* Dialog */
.command-palette__dialog {
  position: relative;
  z-index: 10; /* Ensure it stays above backdrop */
  width: 100%;
  max-width: 600px;
  margin: 0 var(--space-4, 1rem);
  margin: 0 var(--space-4, 1rem);
  
  /* Light Mode (Default) - Solid White */
  background: #ffffff;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  
  border: var(--glass-border, 1px solid rgba(255, 255, 255, 0.2));
  border-radius: var(--radius-2xl, 24px);
  box-shadow: var(--shadow-2xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25));
  overflow: hidden;

  /* Animation */
  opacity: 0;
  transform: translateY(-20px) scale(0.95);
  transition: opacity var(--duration-normal, 0.3s) var(--ease-out, ease-out),
    transform var(--duration-normal, 0.3s) var(--ease-out, ease-out);
  /* Visibility fix */
  visibility: hidden;
}

.command-palette--open .command-palette__dialog {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}

/* Dark Mode - Restore Glassmorphism */
[data-theme="dark"] .command-palette__dialog {
    background: var(--glass-bg, rgba(32, 33, 36, 0.85));
    -webkit-backdrop-filter: var(--glass-blur, blur(12px));
    backdrop-filter: var(--glass-blur, blur(12px));
}

/* Header */
.command-palette__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
}

.command-palette__icon {
  width: var(--icon-size-md);
  height: var(--icon-size-md);
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.command-palette__input {
  flex: 1;
  padding: 0;
  border: none;
  background: transparent;
  font-size: var(--font-size-lg);
  font-family: inherit;
  color: var(--color-text);
  outline: none;
}

.command-palette__input::placeholder {
  color: var(--color-text-tertiary);
}

.command-palette__kbd {
  padding: var(--space-1) var(--space-2);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-family: var(--font-family-mono);
  color: var(--color-text-secondary);
}

/* Body */
.command-palette__body {
  max-height: 400px;
  overflow-y: auto;
  
  /* Custom Scrollbar - Fully Minimal (Hidden) */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.command-palette__body::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

/* Results */
.command-palette__results {
  margin: 0;
  padding: var(--space-2);
  list-style: none;
}

.command-palette__group {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: var(--color-text-tertiary);
}

.command-palette__result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  cursor: pointer;
  color: var(--color-text);

  transition: background-color var(--duration-fast) var(--ease-in-out);
}

.command-palette__result:hover,
.command-palette__result--selected {
  background-color: var(--color-primary-subtle);
}

.command-palette__result--selected {
  color: var(--color-primary);
}

.command-palette__result svg,
.command-palette__result i {
  width: var(--icon-size-sm);
  height: var(--icon-size-sm);
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.command-palette__result--selected svg,
.command-palette__result--selected i {
  color: var(--color-primary);
}

/* Empty state */
.command-palette__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-12);
  color: var(--color-text-tertiary);
}

.command-palette__empty svg {
  width: var(--icon-size-xl);
  height: var(--icon-size-xl);
}

.command-palette__empty.hidden {
  display: none;
}

/* Footer */
.command-palette__footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border-subtle);
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
}

.command-palette__footer kbd {
  display: inline-block;
  padding: 2px var(--space-1);
  background: var(--color-surface-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  margin-right: var(--space-1);
}

/* ==========================================================================
   BREADCRUMBS
   ========================================================================== */

.breadcrumbs {
  padding: var(--space-4) 0;
}

.breadcrumbs__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumbs__item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.breadcrumbs__link {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  text-decoration: none;

  transition: color var(--duration-fast) var(--ease-in-out);
}

.breadcrumbs__link:hover {
  color: var(--color-primary);
}

.breadcrumbs__link:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-focus-ring);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-sm);
}

.breadcrumbs__current {
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.breadcrumbs__separator {
  width: var(--icon-size-xs);
  height: var(--icon-size-xs);
  color: var(--color-text-tertiary);
}

/* Mobile: collapse middle items */
@media (max-width: 767px) {
  .breadcrumbs__list {
    gap: var(--space-1);
  }

  .breadcrumbs__link,
  .breadcrumbs__current {
    font-size: var(--font-size-xs);
  }
}

/* Command palette mobile adjustments */
@media (max-width: 480px) {
  .command-palette {
    padding-top: 10vh;
  }

  .command-palette__dialog {
    max-width: calc(100% - 32px);
    margin: 0 16px;
    border-radius: var(--radius-xl, 16px);
  }

  .command-palette__header {
    padding: var(--space-3);
  }

  .command-palette__input {
    font-size: var(--font-size-base);
  }

  .command-palette__kbd {
    display: none; /* Hide keyboard shortcuts on touch devices */
  }

  .command-palette__body {
    max-height: 50vh; /* Reduce height on mobile */
  }

  .command-palette__footer {
    padding: var(--space-2) var(--space-3);
  }

  .command-palette__footer kbd {
    display: none; /* Hide keyboard hints on touch devices */
  }
}

/* ==========================================================================
   BACK-TO-TOP BUTTON
   ========================================================================== */

.back-to-top {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-fixed);

  width: var(--space-12); /* 48px */
  height: var(--space-12);
  display: flex;
  align-items: center;
  justify-content: center;

  background: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  cursor: pointer;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);

  transition: opacity var(--duration-normal) var(--ease-out),
    visibility var(--duration-normal),
    transform var(--duration-normal) var(--ease-out),
    background-color var(--duration-fast) var(--ease-in-out);
}

.back-to-top--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--color-primary-hover);
  transform: translateY(-2px);
}

.back-to-top:active {
  transform: translateY(0) scale(0.95);
}

.back-to-top:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-focus-ring);
  outline-offset: var(--focus-ring-offset);
}

.back-to-top svg,
.back-to-top i {
  width: var(--icon-size-md);
  height: var(--icon-size-md);
}

/* Mobile positioning */
@media (max-width: 767px) {
  .back-to-top {
    bottom: var(--space-4);
    right: var(--space-4);
    width: var(--space-10); /* 40px */
    height: var(--space-10);
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .back-to-top {
    transition: opacity var(--duration-normal),
      visibility var(--duration-normal);
  }

  .command-palette__dialog,
  .command-palette__backdrop {
    transition: opacity var(--duration-normal);
    transform: none !important;
  }
}
