/* БЛОК: Сетка, таблица, строки файлов */
.btn-secondary {
  background: var(--yd-hover);
  color: var(--yd-text);
}
.btn-icon {
  padding: 8px;
}
.main {
  flex: 1;
  min-height: 0;
  margin: 16px 24px 24px;
  background: var(--yd-bg);
  border-radius: var(--yd-radius);
  border: 1px solid var(--yd-border);
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.main.files-view-table .file-table {
  min-height: 120px;
}
.main.files-view-icons .file-grid {
  min-height: 120px;
}
.main.files-view-empty {
  min-height: 160px;
}
.main.files-view-table .file-grid {
  display: none !important;
}
.main.files-view-icons .file-table {
  display: none !important;
}
.main.files-view-empty .file-table,
.main.files-view-empty .file-grid {
  display: none !important;
}
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 12px;
  padding: 12px 16px 20px;
  align-items: start;
}
.grid-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
  min-width: 0;
  transition: background 0.12s, border-color 0.12s;
}
.grid-item:hover {
  background: var(--yd-hover);
  border-color: var(--yd-border);
}
.grid-item:active { opacity: 0.85; }
.grid-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  overflow: hidden;
  margin-bottom: 8px;
}
.grid-icon-wrap.folder { background: #fff3e0; }
.grid-icon-wrap.file { background: #f5f5f6; }
.grid-icon-wrap.img { background: #e3f2fd; padding: 0; }
.grid-icon-wrap.img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.grid-icon-wrap.doc { background: #e8f5e9; }
.grid-icon-wrap.zip { background: #fce4ec; }
.grid-icon-wrap.video { background: #f3e5f5; }
.grid-name {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.grid-meta {
  font-size: 11px;
  color: var(--yd-text-muted);
  margin-top: 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-ctx-menu {
  position: fixed;
  z-index: 2000;
  min-width: 168px;
  padding: 6px;
  background: var(--yd-bg);
  border: 1px solid var(--yd-border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
}
.file-ctx-menu[hidden] {
  display: none;
}
.file-ctx-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 14px;
  text-align: left;
  color: var(--yd-text);
  cursor: pointer;
}
.file-ctx-item:hover {
  background: var(--yd-hover);
}
.file-ctx-item--danger {
  color: var(--yd-red);
}
.file-ctx-item--danger:hover {
  background: #ffebee;
}
.file-ctx-item.file-ctx-item--hidden,
.file-ctx-item[hidden] {
  display: none !important;
}
.file-ctx-sep {
  height: 1px;
  margin: 4px 8px;
  background: var(--yd-border);
}
.file-ctx-item:disabled,
.file-ctx-item--disabled {
  opacity: 0.42;
  color: var(--yd-text-muted);
  cursor: not-allowed;
  pointer-events: none;
}
.file-ctx-item:disabled:hover,
.file-ctx-item--disabled:hover {
  background: transparent;
}
.file-row.file-cut-pending,
.grid-item.file-cut-pending {
  opacity: 0.5;
  outline: 1px dashed var(--yd-red);
  outline-offset: -1px;
}
.grid-loading,
.grid-error {
  grid-column: 1 / -1;
  padding: 40px 16px;
  text-align: center;
  color: var(--yd-text-muted);
  font-size: 14px;
}
.grid-error { color: #f44336; }
.file-table {
  width: 100%;
  border-collapse: collapse;
}
.file-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--yd-text-muted);
  background: var(--yd-hover);
  border-bottom: 1px solid var(--yd-border);
  box-shadow: 0 1px 0 var(--yd-border);
}
.file-table th:first-child { padding-left: 20px; }
.file-table th:last-child { text-align: right; padding-right: 20px; width: 120px; }
.file-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--yd-border);
  font-size: 14px;
}
.file-table td:first-child { padding-left: 20px; }
.file-table td:last-child { text-align: right; padding-right: 20px; }
.file-table tr:last-child td { border-bottom: none; }
.file-row {
  cursor: default;
}
.file-row.folder-row { cursor: pointer; }
.file-item-name {
  display: flex;
  align-items: center;
  gap: 12px;
}
.file-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
  background: #f5f5f6;
  position: relative;
}
.file-icon.folder { background: #fff3e0; }
.file-icon.file { background: #f5f5f6; }
.file-icon.img { 
  background: #e3f2fd;
  padding: 0;
}
.file-icon.img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}
.file-icon.doc { background: #e8f5e9; }
.file-icon.zip { background: #fce4ec; }
.file-icon.video { background: #f3e5f5; }
.file-name { font-weight: 500; word-break: break-all; }
.file-size { color: var(--yd-text-muted); font-size: 13px; }
.file-date { color: var(--yd-text-muted); font-size: 13px; }
.file-actions { display: flex; gap: 4px; justify-content: flex-end; }
.file-actions .btn { padding: 6px 10px; font-size: 12px; }
.file-actions .btn-danger {
  background: transparent;
  color: var(--yd-text-muted);
}
.file-actions .btn-danger:hover { background: #ffebee; color: #f44336; }
.empty-state {
  padding: 80px 24px;
  text-align: center;
  color: var(--yd-text-muted);
  font-size: 15px;
}
.empty-state p { margin-bottom: 8px; }
.empty-state .hint { font-size: 13px; opacity: 0.8; }
