/* Полка — файловый менеджер команды */

@font-face {
  font-family: "DejaVu Sans";
  src: url("assets/fonts/DejaVuSans.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "DejaVu Sans";
  src: url("assets/fonts/DejaVuSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --font: "DejaVu Sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --text: #171d2b;
  --muted: #5b6577;
  --faint: #8b95a9;
  --bg: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --border: #dde2ec;
  --border-strong: #c3cbe0;
  --accent: #3d56e0;
  --accent-strong: #2f45c8;
  --accent-soft: #eceffe;
  --danger: #d92d20;
  --success: #12805c;
  --radius-lg: 18px;
  --radius-md: 14px;
  --shadow-sm: 0 1px 2px rgba(23, 29, 43, .05);
  --shadow-md: 0 10px 30px rgba(23, 29, 43, .08);
  --shadow-lg: 0 24px 60px rgba(15, 20, 32, .32);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 420px at 8% -12%, #e2e8ff 0%, rgba(226, 232, 255, 0) 62%),
    linear-gradient(180deg, #f7f9fd 0%, var(--bg) 240px);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Скрытый нативный input загрузки: не виден, но доступен для программного выбора файла */
.visually-hidden-file {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  opacity: 0;
  pointer-events: none;
}

:focus-visible {
  outline: 3px solid rgba(61, 86, 224, .5);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: top .15s;
}
.skip-link:focus { top: 12px; }

.icon { display: inline-flex; flex: none; }

/* ---------- Шапка ---------- */

.app-header {
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 28px 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }

.brand-mark {
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 15px;
  background: linear-gradient(150deg, #5b74f2 0%, #3d56e0 70%);
  box-shadow: 0 8px 18px rgba(61, 86, 224, .28);
}

.brand-name {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -.02em;
}

.brand-tagline { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }

.header-actions { margin-left: auto; display: flex; gap: 10px; }

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 14px rgba(61, 86, 224, .22);
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled {
  background: #c6cde1;
  color: #f2f4fa;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn-quiet {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-quiet:hover { border-color: var(--border-strong); background: var(--surface-2); }

/* ---------- Раскладка ---------- */

.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 28px 96px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.content { min-width: 0; }

.sidebar {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* ---------- Хлебные крошки ---------- */

.breadcrumbs { margin: 0 0 12px; }

.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
}

.breadcrumbs li { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.breadcrumbs li + li::before { content: "/"; color: var(--faint); }

.crumb-link {
  appearance: none;
  border: none;
  background: transparent;
  padding: 5px 8px;
  border-radius: 9px;
  font: inherit;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.crumb-link:hover { background: var(--accent-soft); }
.crumb-link.is-current { color: var(--text); }

.crumb-current {
  padding: 5px 8px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ---------- Панель поиска и действий ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  margin-bottom: 4px;
  background: rgba(243, 246, 252, .93);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(221, 226, 236, .9);
}

.search { position: relative; flex: 1 1 300px; max-width: 520px; display: flex; align-items: center; }

.search input {
  width: 100%;
  font: inherit;
  color: inherit;
  padding: 12px 46px 12px 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.search input::placeholder { color: var(--faint); }
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(61, 86, 224, .15);
}
.search input::-webkit-search-cancel-button { display: none; }

.search-icon { position: absolute; left: 14px; color: var(--faint); pointer-events: none; }

.search-clear {
  position: absolute;
  right: 8px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}
.search-clear:hover { background: var(--surface-2); color: var(--text); }

.toolbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Заголовок списка ---------- */

.list-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 16px 2px 14px;
}

.list-title { margin: 0; font-size: 22px; line-height: 1.25; letter-spacing: -.02em; overflow-wrap: anywhere; }
.list-subtitle { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- Папки ---------- */

.folders {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.folder-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  font: inherit;
  color: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.folder-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

.folder-icon {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #b7791f;
  background: linear-gradient(150deg, #fff4da 0%, #ffe7ad 100%);
}

.folder-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.folder-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-count { color: var(--muted); font-size: 13px; }
.folder-chevron { color: var(--faint); flex: none; }

/* ---------- Файлы ---------- */

.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.files:empty { display: none; }

.file-row {
  display: grid;
  grid-template-columns: 26px 46px minmax(0, 1fr) auto 104px 112px;
  grid-template-areas: "check badge main folder size date";
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.file-row:hover { border-color: var(--border-strong); }
.file-row.is-selected {
  border-color: var(--accent);
  background: #f4f6ff;
  box-shadow: inset 0 0 0 1px rgba(61, 86, 224, .35);
}
.file-row.is-new { animation: row-flash 1.6s ease-out 1; }

@keyframes row-flash {
  0% { background: #e5ebff; }
  100% { background: var(--surface); }
}

.file-check { grid-area: check; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); cursor: pointer; }

.type-badge {
  grid-area: badge;
  width: 46px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}
.type-badge[data-type="PDF"] { background: #fee4e2; color: #b42318; }
.type-badge[data-type="XLSX"] { background: #d1fadf; color: #067647; }
.type-badge[data-type="PNG"] { background: #ebe9fe; color: #5f4bd8; }
.type-badge[data-type="JPG"] { background: #e0f2fe; color: #0b6bcb; }
.type-badge[data-type="TXT"] { background: #eaecf0; color: #475467; }

.file-main { grid-area: main; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.file-name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name mark { background: #fff0a8; color: inherit; border-radius: 3px; padding: 0 1px; }
.file-folder-inline, .file-meta-inline { display: none; color: var(--muted); font-size: 12.5px; }

.file-folder {
  grid-area: folder;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size { grid-area: size; color: var(--muted); font-size: 13px; text-align: right; white-space: nowrap; }
.file-date { grid-area: date; color: var(--muted); font-size: 13px; text-align: right; white-space: nowrap; }

/* ---------- Пустые состояния ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 46px 24px;
  text-align: center;
  background: rgba(255, 255, 255, .66);
  border: 1.5px dashed #c7d0e2;
  border-radius: var(--radius-lg);
}

.empty-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  color: var(--faint);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  margin-bottom: 6px;
}

.empty-title { margin: 0; font-size: 18px; }
.empty-text { margin: 0; max-width: 430px; color: var(--muted); font-size: 14.5px; }
.empty .btn { margin-top: 12px; }

.storage-note { margin: 26px 2px 0; color: var(--faint); font-size: 12.5px; }

.noscript { padding: 24px; text-align: center; color: var(--danger); font-weight: 700; }

/* ---------- Свойства ---------- */

.props {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-md);
}

.props-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.props-head .type-badge { width: 44px; height: 30px; }
.props-title { margin: 0; font-size: 16px; }

.props-name {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.props-list { margin: 0; display: flex; flex-direction: column; }
.prop { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 9px 0; border-top: 1px solid #eef1f7; }
.prop:first-child { border-top: none; }
.prop dt { flex: none; color: var(--muted); font-size: 13px; }
.prop dd { margin: 0; min-width: 0; text-align: right; font-size: 14px; overflow-wrap: anywhere; }
.prop-raw { display: block; margin-top: 2px; color: var(--faint); font-size: 12px; }

.props-placeholder {
  padding: 22px;
  color: var(--muted);
  font-size: 14px;
  background: rgba(255, 255, 255, .62);
  border: 1.5px dashed #c7d0e2;
  border-radius: var(--radius-lg);
}

/* ---------- Диалог переноса ---------- */

.dialog {
  border: none;
  padding: 0;
  width: min(460px, calc(100vw - 32px));
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.dialog::backdrop { background: rgba(15, 20, 32, .48); }

.dialog-card { display: flex; flex-direction: column; gap: 16px; padding: 22px; background: var(--surface); }
.dialog-title { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.dialog-note { margin: 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 14px; font-weight: 700; }
.field select {
  font: inherit;
  color: inherit;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(61, 86, 224, .15); }
.field-hint { margin: 0; color: var(--muted); font-size: 13px; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 2px; }

/* ---------- Сообщения ---------- */

.toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(400px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  position: relative;
  pointer-events: auto;
  padding: 13px 42px 13px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: 0 14px 34px rgba(15, 20, 32, .16);
  font-size: 14px;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }

.toast-title { margin: 0; font-weight: 700; }
.toast-text { margin: 4px 0 0; color: var(--muted); }
.toast-list { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; overflow-wrap: anywhere; }
.toast-hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}
.toast-close:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Адаптивность ---------- */

@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; }
  .sidebar.is-empty { display: none; }
}

@media (max-width: 720px) {
  .app-header { padding: 16px 16px 10px; gap: 12px; }
  .layout { padding: 0 16px 110px; }
  .brand-mark { width: 42px; height: 42px; border-radius: 13px; }
  .brand-name { font-size: 21px; }
  .brand-tagline { display: none; }
  .header-actions { margin-left: auto; }
  .header-actions .btn { padding: 11px 14px; }

  .toolbar { padding: 10px 0; gap: 10px; }
  .search { flex-basis: 100%; max-width: none; }
  .toolbar-actions { width: 100%; margin-left: 0; }
  .toolbar-actions .btn { flex: 1; }

  .folders { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .folder-card { padding: 12px; gap: 10px; }
  .folder-icon { width: 38px; height: 38px; border-radius: 12px; }

  .file-row,
  .file-row.has-folder {
    grid-template-columns: 24px 40px minmax(0, 1fr);
    grid-template-areas: "check badge main";
    gap: 10px;
    padding: 12px;
  }
  .type-badge { width: 40px; height: 30px; font-size: 10px; }
  .file-folder, .file-size, .file-date { display: none; }
  .file-folder-inline, .file-meta-inline { display: block; }

  .list-title { font-size: 19px; }

  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
