/* =========================================

   FILE NAVIGATOR - Двухпанельный навигатор файлов
   
   ========================================= */

/* =========================================
   ПЕРЕМЕННЫЕ ДЛЯ ТЕМ
   ========================================= */
:root {
  --fn-bg: #F8F9FA;
  --fn-panel-bg: #FFFFFF;
  --fn-header-bg: #F1F3F4;
  --fn-header-bg-dark: #919394;
  --fn-text-primary: #202124;
  --fn-text-muted: #5F6368;
  --fn-text-secondary: #80868B;
  --fn-accent: #1A73E8;
  --fn-accent-light: #E8F0FE;
  --fn-separator: #DADCE0;
  --fn-hover-bg: rgba(0, 0, 0, 0.04);
  --fn-focus-bg: rgba(26, 115, 232, 0.12);
  --fn-active-indicator: var(--fn-accent);
  --fn-row-height: 36px;
  --fn-header-height: 44px;
  --fn-app-header-height: 56px;
  --fn-radius: 8px;
  --fn-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fn-bg: #202124;
    --fn-panel-bg: #292A2D;
    --fn-header-bg: #35363A;
    --fn-text-primary: #E8EAED;
    --fn-text-muted: #9AA0A6;
    --fn-text-secondary: #5F6368;
    --fn-accent: #8AB4F8;
    --fn-accent-light: rgba(138, 180, 248, 0.12);
    --fn-separator: #3C4043;
    --fn-hover-bg: rgba(255, 255, 255, 0.06);
    --fn-focus-bg: rgba(138, 180, 248, 0.16);
  }
}

/* =========================================
   LAYOUT - КОНТЕЙНЕР НАВИГАТОРА
   ========================================= */
.file-navigator {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--fn-bg);
  color: var(--fn-text-primary);
  font-family: var(--cdr-font-family);
  font-size: 14px;
}

/* =========================================
   HEADER - ЗАГОЛОВОК ПРИЛОЖЕНИЯ
   ========================================= */
.fn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--fn-app-header-height);
  padding: 0 8px;
  background: var(--fn-panel-bg);
  border-bottom: 1px solid var(--fn-separator);
  flex-shrink: 0;
}

.fn-header__logo {
  font-size: 20px;
  font-weight: 600;
  color: var(--fn-accent);
}

@media (prefers-color-scheme: dark) {
  .fn-header__logo {
    color: #90CAF9;
  }
}

/* Контейнер для действий в хедере */
.fn-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  margin-right: 16px;
}

/* Кнопка справки */
.fn-header__help-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--fn-accent);
  color: white;
  font-size: 18px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}

.fn-header__help-btn:hover {
  background: var(--fn-accent);
  opacity: 0.9;
  transform: scale(1.05);
}

/* Логотип пользователя */
.fn-header__user-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.fn-header__user-logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* =========================================
   COLUMNS HEADER - ЗАГОЛОВКИ КОЛОНОК
   ========================================= */
.fn-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px 70px 100px;
  height: var(--fn-header-height);
  background: var(--fn-header-bg);
  border-bottom: 1px solid var(--fn-separator);
  flex-shrink: 0;
}

.fn-column {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fn-text-muted);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

@media (prefers-color-scheme: dark) {
  .fn-column {
    background: var(--fn-header-bg-dark);
  }
}

.fn-column:hover {
  background: var(--fn-hover-bg);
}

.fn-column--name {
  justify-content: flex-start;
}

.fn-column--type {
  justify-content: flex-start;
}

.fn-column--size {
  justify-content: flex-end;
}

.fn-column--date {
  justify-content: flex-start;
}

.fn-column__sort {
  margin-left: 6px;
  font-size: 10px;
  color: var(--fn-accent);
}

.fn-column__sort--hidden {
  visibility: hidden;
}

/* =========================================
   PANELS CONTAINER
   ========================================= */
.fn-panels {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* =========================================
   PANEL - ПАНЕЛЬ
   ========================================= */
.fn-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  background: var(--fn-panel-bg);
  overflow: hidden;
  position: relative;
}

/* Синий разделитель между панелями */
.fn-panels::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--fn-accent);
  transform: translateX(-50%);
  z-index: 10;
}

/* Заголовок панели */
.fn-panel__header {
  padding: 0 16px;
  height: 44px;
  min-height: 44px;
  background: var(--fn-panel-bg);
  border-bottom: 1px solid var(--fn-separator);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-sizing: border-box;
}

.fn-panel__title {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--fn-text-muted);
  line-height: 1;
}

.fn-panel__action {
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1;
  height: 26px;
  color: var(--fn-accent);
  background: transparent;
  border: 1px solid var(--fn-accent);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.fn-panel__action:hover {
  background: var(--fn-accent-light);
}

/* Активная панель */
.fn-panel--active {
  background: var(--fn-panel-bg);
}

.fn-panel--active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--fn-active-indicator);
}

.fn-panel--active .fn-panel__title {
  color: #2a2a2a;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .fn-panel--active .fn-panel__title {
    color: #f0f0f0;
  }
}

.fn-panel--active .fn-column {
  color: var(--fn-text-primary);
  font-weight: 600;
}

/* Неактивная панель */
.fn-panel--inactive {
  background: var(--fn-bg);
}

.fn-panel--inactive .fn-panel__header {
  background: var(--fn-bg);
}

.fn-panel--inactive .fn-panel__title {
  color: var(--fn-text-secondary);
}

.fn-panel--inactive .fn-column {
  color: var(--fn-text-secondary);
}

/* =========================================
   FILE LIST
   ========================================= */
.fn-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  list-style: none;
  margin: 0;
  padding: 0;
}

.fn-list:focus {
  outline: none;
}

/* =========================================
   FILE ROW - СТРОКА ФАЙЛА/ПАПКИ
   ========================================= */
.fn-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px 70px 100px;
  align-items: center;
  height: var(--fn-row-height);
  cursor: pointer;
  transition: background 0.1s ease;
}

.fn-row:hover {
  background: var(--fn-hover-bg);
}

.fn-row--focused {
  background: var(--fn-focus-bg);
}

.fn-row--focused:hover {
  background: var(--fn-focus-bg);
}

/* Disabled строка (.. в левой панели) */
.fn-row--disabled {
  color: var(--fn-text-secondary);
  cursor: not-allowed;
}

.fn-row--disabled:hover {
  background: transparent;
}

/* Недоступный файл (не PDF) */
.fn-row--unavailable {
  color: var(--fn-text-secondary);
}

.fn-row__cell {
  padding: 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fn-row__cell--name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fn-row__cell--size {
  text-align: right;
}

/* Иконка */
.fn-row__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--fn-text-muted);
}

.fn-row__icon--folder {
  color: var(--fn-accent);
}

/* =========================================
   OVERLAY - ЗАГРУЗКА
   ========================================= */
.fn-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  .fn-overlay {
    background: rgba(0, 0, 0, 0.6);
  }
}

.fn-overlay--hidden {
  display: none;
}

.fn-overlay__spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--fn-separator);
  border-top-color: var(--fn-accent);
  border-radius: 50%;
  animation: fn-spin 1s linear infinite;
}

.fn-overlay__text {
  font-size: 16px;
  font-weight: 500;
  color: #FFFFFF;
}

.fn-overlay__filename {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================
   FALLBACK - СООБЩЕНИЕ О НЕДОСТУПНОСТИ
   ========================================= */
.fn-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 100%;
  padding: 24px;
  text-align: center;
  color: var(--fn-text-muted);
}

.fn-fallback__icon {
  font-size: 48px;
  opacity: 0.5;
}

.fn-fallback__text {
  max-width: 280px;
  line-height: 1.5;
}

.fn-fallback__button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--fn-accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.fn-fallback__button:hover {
  opacity: 0.9;
}

/* =========================================
   EMPTY STATE
   ========================================= */
.fn-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--fn-text-secondary);
  font-style: italic;
}

/* =========================================
   ERROR STATE - Ошибочные файлы
   ========================================= */
.fn-row--error {
  cursor: not-allowed;
  opacity: 0.6;
}

.fn-row--error:hover {
  background: transparent;
}

.fn-row__error-name {
  color: var(--fn-text-secondary);
  text-decoration: line-through;
}

/* =========================================
   ANIMATIONS
   ========================================= */
@keyframes fn-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================
   RESPONSIVE - МОБИЛЬНАЯ ВЕРСИЯ
   ========================================= */
@media (max-width: 767px) {
  .fn-panels {
    flex-direction: column;
  }

  /* Горизонтальная синяя полоса между панелями */
  .fn-panels::after {
    left: 0;
    right: 0;
    top: 50%;
    bottom: auto;
    width: auto;
    height: 3px;
    transform: translateY(-50%);
  }

  .fn-panel {
    flex: none;
    height: 50%;
  }

  .fn-panel:first-child {
    border-right: none;
    border-bottom: 1px solid var(--fn-separator);
  }

  .fn-panel--active::before {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    height: 3px;
  }

  .fn-panel:first-child.fn-panel--active::before {
    top: 0;
    bottom: auto;
  }

  /* Компактные колонки на мобильных */
  .fn-columns {
    display: none;
    grid-template-columns: minmax(0, 1fr) 50px 50px 70px;
    font-size: 10px;
  }

  .fn-column {
    padding: 0 6px;
    font-size: 10px;
  }

  .fn-panel--active .fn-columns {
    display: grid;
  }

  /* Компактные строки на мобильных */
  .fn-row {
    grid-template-columns: minmax(0, 1fr) 50px 50px 70px;
    font-size: 12px;
  }

  .fn-row__cell {
    padding: 0 6px;
  }

  .fn-row__icon {
    width: 16px;
    height: 16px;
  }

  /* Уменьшаем заголовок панели */
  .fn-panel__header {
    padding: 0 8px;
    height: 36px;
    min-height: 36px;
  }

  .fn-panel__title {
    font-size: 11px;
  }

  .fn-panel__action {
    padding: 3px 6px;
    font-size: 10px;
    height: 22px;
  }
}
