/* AX1S UX layer — command palette, toasts, focus rings, skeletons, kbd help.
   Подключается после styles.css. Делается additive — не трогает существующие стили.
   Согласуется с дизайн-токенами из styles.css :root (--cyan, --panel, --line, etc.).
*/

/* ════════════════════════════════════════════════════════════════════
   FOCUS RINGS — везде, через :focus-visible (только клавиатура)
   ════════════════════════════════════════════════════════════════════ */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--cyan, #5bc8ff);
  outline-offset: 2px;
  border-radius: 6px;
}
/* Кнопки получают чуть более выраженный ring с glow */
button:focus-visible,
.rail-action:focus-visible,
.profile-chip:focus-visible,
.download-chip:focus-visible {
  outline: 2px solid var(--cyan, #5bc8ff);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(91, 200, 255, 0.15);
}
/* Hide outline на input когда он внутри command palette (там своё) */
.cmd-input:focus-visible { outline: none; box-shadow: none; }

/* ════════════════════════════════════════════════════════════════════
   COMMAND PALETTE
   ════════════════════════════════════════════════════════════════════ */
.cmd-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(5, 5, 6, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
  animation: cmdFade 0.16s ease-out;
}
@keyframes cmdFade { from { opacity: 0; } to { opacity: 1; } }

.cmd-palette {
  width: min(640px, calc(100vw - 32px));
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #161618 0%, #121214 100%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(91, 200, 255, 0.05);
  overflow: hidden;
  animation: cmdSlide 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes cmdSlide {
  from { transform: translateY(-12px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0)     scale(1);    opacity: 1; }
}

.cmd-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}
.cmd-prefix {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 22px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--cyan, #5bc8ff);
  background: rgba(91, 200, 255, 0.10);
  border: 1px solid rgba(91, 200, 255, 0.25);
  border-radius: 6px;
  font-family: var(--font-display, "Space Grotesk", sans-serif);
}
.cmd-input {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text, #e9e9ec);
  font: 16px/1.4 var(--font-display, "Space Grotesk", sans-serif);
  padding: 0;
  outline: 0;
}
.cmd-input::placeholder { color: var(--dim, #54545a); }
.cmd-esc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted, #86868c);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.cmd-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.cmd-group {
  padding: 10px 18px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--dim, #54545a);
}
.cmd-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 18px;
  background: transparent;
  border: 0;
  color: var(--text, #e9e9ec);
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: background 0.08s ease;
}
.cmd-item .cmd-label { font-size: 14px; font-weight: 500; }
.cmd-item .cmd-hint  { font-size: 12px; color: var(--muted, #86868c); }
.cmd-item .cmd-key   {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #86868c);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  font-family: var(--font-display, "Space Grotesk", sans-serif);
}
.cmd-item.is-active,
.cmd-item:hover { background: rgba(91, 200, 255, 0.08); }
.cmd-item.is-active .cmd-key { color: var(--cyan, #5bc8ff); border-color: rgba(91, 200, 255, 0.3); }
.cmd-item[disabled] { opacity: 0.4; cursor: not-allowed; }
.cmd-item[disabled]:hover { background: transparent; }

.cmd-empty {
  padding: 32px 24px;
  text-align: center;
  color: var(--muted, #86868c);
  font-size: 14px;
  line-height: 1.6;
}
.cmd-empty small {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--dim, #54545a);
}

.cmd-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  color: var(--muted, #86868c);
  background: rgba(0, 0, 0, 0.2);
}
.cmd-foot kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  margin-right: 2px;
  font: 10px/1 var(--font-display, "Space Grotesk", sans-serif);
  font-weight: 600;
  color: var(--text, #e9e9ec);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
.cmd-foot-right { margin-left: auto; }

/* ════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ════════════════════════════════════════════════════════════════════ */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 48px));
  pointer-events: none;
}
.toast {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid var(--line, #e8e2d4);
  border-radius: 10px;
  color: var(--text, #1a1a1a);
  font: 13.5px/1.4 var(--font-body, "IBM Plex Sans", sans-serif);
  box-shadow: 0 12px 32px rgba(20, 20, 20, 0.12);
  pointer-events: auto;
  opacity: 0;
  transform: translateX(20px) scale(0.96);
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
}
.toast.is-in { opacity: 1; transform: translateX(0) scale(1); }
.toast.is-out { opacity: 0; transform: translateX(20px) scale(0.96); }
.toast-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex-shrink: 0; }
.toast-icon svg { width: 100%; height: 100%; }
.toast-msg { min-width: 0; word-break: break-word; }
.toast-close {
  background: transparent;
  border: 0;
  color: var(--muted, #595959);
  cursor: pointer;
  font: 18px/1 var(--font-display, sans-serif);
  padding: 0 2px;
  border-radius: 4px;
  line-height: 1;
}
.toast-close:hover { color: var(--text, #1a1a1a); }
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  transform-origin: left center;
  transform: scaleX(1);
  background: currentColor;
  opacity: 0.5;
}
.toast.is-info    { color: var(--text, #1a1a1a); border-color: rgba(200, 16, 46, 0.30); }
.toast.is-info    .toast-icon { color: var(--cyan, #c8102e); }
.toast.is-info    .toast-progress { background: var(--cyan, #c8102e); }
.toast.is-success { color: var(--text, #1a1a1a); border-color: rgba(26, 127, 74, 0.30); }
.toast.is-success .toast-icon { color: var(--success, #1a7f4a); }
.toast.is-success .toast-progress { background: var(--success, #1a7f4a); }
.toast.is-warn    { color: var(--text, #1a1a1a); border-color: rgba(184, 119, 14, 0.30); }
.toast.is-warn    .toast-icon { color: var(--warning, #b8770e); }
.toast.is-warn    .toast-progress { background: var(--warning, #b8770e); }
.toast.is-error   { color: var(--text, #1a1a1a); border-color: rgba(200, 16, 46, 0.40); }
.toast.is-error   .toast-icon { color: var(--danger, #c8102e); }
.toast.is-error   .toast-progress { background: var(--danger, #ff7a6b); }

/* Mobile: тосты на всю ширину снизу */
@media (max-width: 640px) {
  .toast-stack { left: 16px; right: 16px; bottom: 16px; max-width: none; }
}

/* ════════════════════════════════════════════════════════════════════
   KBD HELP MODAL
   ════════════════════════════════════════════════════════════════════ */
.kbd-help { z-index: 1050; }
.kbd-help .modal-card { max-width: 520px; }
.kbd-help-body { padding: 4px 4px 4px; }
.kbd-group { padding: 10px 4px 14px; }
.kbd-group h3 {
  margin: 0 0 8px;
  font: 600 10px/1 var(--font-display, "Space Grotesk", sans-serif);
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--dim, #54545a);
}
.kbd-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text, #e9e9ec);
}
.kbd-row .kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 24px;
  padding: 0 8px;
  font: 600 11px/1 var(--font-display, "Space Grotesk", sans-serif);
  color: var(--text, #e9e9ec);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-bottom-width: 2px;
  border-radius: 5px;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════════════
   SKELETON LOADERS (для будущего применения)
   ════════════════════════════════════════════════════════════════════ */
@keyframes axShimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  display: inline-block;
  background: linear-gradient(90deg,
    rgba(255, 255, 255, 0.04) 0%,
    rgba(255, 255, 255, 0.10) 50%,
    rgba(255, 255, 255, 0.04) 100%);
  background-size: 200% 100%;
  border-radius: 4px;
  animation: axShimmer 1.4s linear infinite;
  color: transparent;
}
.skeleton.is-bar    { height: 12px; width: 100%; }
.skeleton.is-circle { border-radius: 50%; width: 36px; height: 36px; }
.skeleton.is-text   { height: 14px; width: 80%; margin: 4px 0; }

/* ════════════════════════════════════════════════════════════════════
   MOBILE — slide-over для rail
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  .rail { transform: translateX(-100%); transition: transform 0.22s ease; }
  body.rail-open .rail { transform: translateX(0); }
  body.rail-open::after {
    content: "";
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 90;
  }
  .rail-mobile-toggle {
    display: inline-flex !important;
    position: fixed;
    top: 12px; left: 12px;
    z-index: 95;
    width: 36px; height: 36px;
    background: var(--panel, #161618);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 8px;
    color: var(--text, #e9e9ec);
    align-items: center;
    justify-content: center;
  }
}
.rail-mobile-toggle { display: none; }
