/* ============================================================
   Документация — файловый менеджер
   ============================================================ */

.docs-header {
  padding-bottom: 1.5rem;
}

.docs-explorer {
  max-width: 1000px;
  padding: 0 2rem 3rem;
}

/* ---------- Панель управления ---------- */

.docs-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid rgba(176, 38, 255, 0.3);
  border-radius: 18px;
  backdrop-filter: blur(10px);
}

.docs-breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-width: 0;
  font-size: 0.95rem;
}

.docs-crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 260px;
  padding: 0.3rem 0.55rem;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.25s ease;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.docs-crumb:hover {
  color: var(--text-primary);
  background: var(--gradient-soft);
}

.docs-crumb--current {
  color: var(--text-primary);
  background: var(--gradient-soft);
  cursor: default;
}

.docs-crumb-sep {
  color: var(--text-muted);
  opacity: 0.6;
  user-select: none;
}

.docs-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1 1 260px;
  justify-content: flex-end;
}

.docs-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 220px;
  max-width: 320px;
  padding: 0.55rem 0.9rem;
  background: rgba(10, 0, 20, 0.55);
  border: 1px solid rgba(176, 38, 255, 0.3);
  border-radius: 50px;
  transition: all 0.25s ease;
}

.docs-search:focus-within {
  border-color: var(--neon-pink);
  box-shadow: 0 0 18px rgba(255, 43, 214, 0.25);
}

.docs-search-icon {
  font-size: 0.9rem;
  opacity: 0.7;
  line-height: 1;
}

.docs-search-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
}

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

.docs-search-input::-webkit-search-cancel-button {
  filter: invert(1);
  opacity: 0.5;
}

.docs-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid rgba(176, 38, 255, 0.35);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.25s ease;
}

.docs-refresh:hover {
  color: var(--text-primary);
  border-color: var(--neon-pink);
  box-shadow: var(--glow-pink);
}

.docs-refresh.is-spinning span {
  animation: docsSpin 0.9s linear infinite;
}

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

.docs-summary {
  margin: 1rem 0.25rem 0.75rem;
  min-height: 1.3rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ---------- Список ---------- */

.docs-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.docs-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid rgba(176, 38, 255, 0.25);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
  animation: docsRowIn 0.35s ease both;
}

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

.docs-row:hover {
  border-color: var(--neon-pink);
  box-shadow: 0 0 24px rgba(255, 43, 214, 0.18);
  transform: translateY(-2px);
}

.docs-row--folder {
  cursor: pointer;
}

.docs-row--folder:hover {
  border-color: var(--neon-purple);
  box-shadow: var(--glow-purple);
}

.docs-row:focus-visible,
.docs-action:focus-visible,
.docs-refresh:focus-visible,
.docs-crumb:focus-visible,
.docs-modal-close:focus-visible {
  outline: 2px solid var(--neon-pink);
  outline-offset: 2px;
}

.docs-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 13px;
  font-size: 1.45rem;
  line-height: 1;
  background: rgba(176, 38, 255, 0.12);
  border: 1px solid rgba(176, 38, 255, 0.22);
  box-shadow: inset 0 0 18px rgba(176, 38, 255, 0.08);
}

.docs-icon--folder {
  background: rgba(255, 43, 214, 0.14);
  border-color: rgba(255, 43, 214, 0.35);
  box-shadow: inset 0 0 18px rgba(255, 43, 214, 0.12);
}

.docs-item-main {
  min-width: 0;
}

.docs-item-name {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.98rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.docs-row--folder .docs-item-name {
  font-weight: 600;
}

.docs-item-sub {
  margin-top: 0.1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.docs-item-meta {
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.docs-item-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.docs-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.25s ease;
}

.docs-action:hover {
  color: var(--text-primary);
  background: var(--gradient-soft);
  border-color: rgba(176, 38, 255, 0.4);
  box-shadow: 0 0 14px rgba(176, 38, 255, 0.25);
}

.docs-folder-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--neon-pink);
  font-size: 1.15rem;
  border-radius: 10px;
  transition: transform 0.25s ease;
}

.docs-row--folder:hover .docs-folder-arrow {
  transform: translateX(3px);
}

/* ---------- Состояния / скелетон ---------- */

.docs-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 3.5rem 2rem;
  text-align: center;
  background: var(--bg-card);
  border: 1px dashed rgba(176, 38, 255, 0.45);
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

.docs-state[hidden] {
  display: none;
}

.docs-state-icon {
  font-size: 3rem;
  line-height: 1;
  opacity: 0.85;
}

.docs-state-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.docs-state-text {
  max-width: 460px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.docs-state-retry {
  margin-top: 0.5rem;
}

.docs-skeleton {
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 0%,
    rgba(255, 255, 255, 0.09) 50%,
    rgba(255, 255, 255, 0.04) 100%
  );
  background-size: 200% 100%;
  animation: docsShimmer 1.4s ease-in-out infinite;
}

@keyframes docsShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Модальное окно просмотра ---------- */

body.docs-modal-open {
  overflow: hidden;
}

.docs-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.docs-modal[hidden] {
  display: none;
}

.docs-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 0, 12, 0.82);
  backdrop-filter: blur(8px);
  animation: docsFadeIn 0.2s ease both;
}

@keyframes docsFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.docs-modal-window {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(900px, 100%);
  max-height: 90vh;
  max-height: 90dvh;
  background: #14002a;
  border: 1px solid rgba(176, 38, 255, 0.5);
  border-radius: 20px;
  box-shadow: 0 0 60px rgba(176, 38, 255, 0.35);
  overflow: hidden;
  animation: docsModalIn 0.25s ease both;
}

@keyframes docsModalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.docs-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid rgba(176, 38, 255, 0.25);
}

.docs-modal-title {
  min-width: 0;
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.docs-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid rgba(176, 38, 255, 0.35);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.25s ease;
}

.docs-modal-close:hover {
  color: #fff;
  border-color: var(--neon-pink);
  box-shadow: var(--glow-pink);
}

.docs-modal-body {
  display: grid;
  place-items: center;
  flex: 1 1 auto;
  min-height: 180px;
  padding: 1.25rem;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: rgba(5, 0, 12, 0.35);
}

.docs-modal-body img,
.docs-modal-body video {
  max-width: 100%;
  max-height: 65vh;
  max-height: 65dvh;
  border-radius: 12px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.45);
}

.docs-modal-body audio {
  width: 100%;
}

.docs-modal-body iframe {
  width: 100%;
  height: 65vh;
  border: 0;
  border-radius: 12px;
  background: #fff;
}

.docs-modal-body pre {
  width: 100%;
  margin: 0;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(176, 38, 255, 0.2);
  border-radius: 12px;
  color: #d9c9f2;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: left;
}

.docs-modal-note {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.docs-modal-foot {
  display: flex;
  justify-content: flex-end;
  padding: 0.9rem 1.1rem;
  border-top: 1px solid rgba(176, 38, 255, 0.25);
}

.docs-modal-download {
  padding: 0.65rem 1.5rem;
  font-size: 0.92rem;
}

/* ---------- Мобильная версия ---------- */

@media (max-width: 768px) {
  .docs-explorer {
    padding: 0 max(1rem, env(safe-area-inset-left)) 2rem;
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .docs-toolbar {
    align-items: stretch;
    gap: 0.6rem;
    padding: 0.7rem;
    border-radius: 16px;
  }

  .docs-breadcrumbs {
    font-size: 0.9rem;
    gap: 0.25rem;
  }

  .docs-toolbar-actions {
    flex-basis: 100%;
    justify-content: stretch;
    gap: 0.5rem;
  }

  .docs-search {
    max-width: none;
    padding: 0.6rem 0.9rem;
  }

  /* 16px — чтобы iOS не зумил страницу при фокусе на поле */
  .docs-search-input {
    font-size: 16px;
  }

  .docs-refresh {
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
  }

  .docs-summary {
    margin: 0.75rem 0.1rem 0.6rem;
    font-size: 0.85rem;
  }

  .docs-row {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 0.65rem;
    padding: 0.6rem 0.65rem;
    min-height: 60px;
    border-radius: 14px;
  }

  .docs-item-icon {
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
    border-radius: 12px;
  }

  .docs-item-meta {
    display: none;
  }

  .docs-item-name {
    font-size: 0.95rem;
  }

  .docs-item-sub {
    font-size: 0.76rem;
  }

  .docs-crumb {
    max-width: 46vw;
    min-height: 36px;
    padding: 0.25rem 0.5rem;
  }

  .docs-action,
  .docs-folder-arrow {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }

  /* модалка — почти на весь экран, как системный лист */
  .docs-modal {
    padding: 0.5rem;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  }

  .docs-modal-window {
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: 18px;
  }

  .docs-modal-head {
    padding: 0.7rem 0.9rem;
  }

  .docs-modal-title {
    font-size: 0.95rem;
  }

  .docs-modal-close {
    width: 40px;
    height: 40px;
  }

  .docs-modal-body {
    padding: 0.75rem;
  }

  .docs-modal-body iframe {
    height: 60vh;
    height: 60dvh;
  }

  .docs-modal-foot {
    padding: 0.7rem 0.9rem;
  }

  .docs-modal-download {
    flex: 1;
    text-align: center;
    min-height: 48px;
  }
}

@media (max-width: 480px) {
  .docs-toolbar-actions {
    flex-wrap: nowrap;
  }

  .docs-row {
    gap: 0.55rem;
  }

  .docs-state {
    padding: 2rem 1.1rem;
    border-radius: 16px;
  }

  .docs-state-title {
    font-size: 1.1rem;
  }

  .docs-state-text {
    font-size: 0.9rem;
  }

  .docs-skeleton {
    height: 60px;
    border-radius: 14px;
  }
}

/* на тач-устройствах убираем «залипшие» hover-эффекты */
@media (hover: none) {
  .docs-row:hover {
    border-color: rgba(176, 38, 255, 0.25);
    box-shadow: none;
    transform: none;
  }

  .docs-row--folder:hover {
    border-color: rgba(176, 38, 255, 0.25);
    box-shadow: none;
  }

  .docs-action:hover {
    color: var(--text-secondary);
    background: transparent;
    border-color: transparent;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .docs-row,
  .docs-modal-window,
  .docs-modal-backdrop,
  .docs-skeleton {
    animation: none;
  }
}
