/* ── 文件管理系統 全域樣式 ─────────────────────────────── */

/* Layout */
.dm-layout {
  display: flex;
  height: calc(100vh - 52px);
  overflow: hidden;
}

.dm-sidebar {
  width: 260px;
  min-width: 200px;
  max-width: 320px;
  border-right: 1px solid #dee2e6;
  display: flex;
  flex-direction: column;
  background: #f8f9fa;
  overflow: hidden;
}

.sidebar-header {
  background: #f0f2f5;
  flex-shrink: 0;
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.dm-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.dm-toolbar {
  flex-shrink: 0;
}

.dm-doc-list {
  flex: 1;
  overflow-y: auto;
}

.dm-statusbar {
  flex-shrink: 0;
  font-size: .78rem;
}

/* Sidebar tab/folder items */
.tab-header {
  cursor: pointer;
  border-radius: 4px;
  margin: 1px 4px;
  transition: background .15s;
  user-select: none;
}
.tab-header:hover { background: #e2e6ea; }

.folder-item {
  border-radius: 4px;
  margin: 1px 4px;
  transition: background .15s;
  user-select: none;
  font-size: .875rem;
}
.folder-item:hover { background: #e9ecef; }
.folder-item.active {
  background: #cfe2ff;
  color: #084298;
  font-weight: 600;
}

/* Document table */
.dm-table { font-size: .85rem; }
.dm-table thead th {
  position: sticky;
  top: 0;
  background: #f8f9fa;
  z-index: 1;
  white-space: nowrap;
  font-weight: 600;
  font-size: .8rem;
  border-bottom: 2px solid #dee2e6;
  padding: 6px 8px;
}
.dm-table tbody td {
  padding: 5px 8px;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.dm-table .sortable { cursor: pointer; }
.dm-table .sortable:hover { background: #e9ecef; }
.doc-row:hover { cursor: default; }
.doc-row.table-active td { background: #cfe2ff !important; }

/* Context menu */
.ctx-menu {
  position: fixed;
  z-index: 9999;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 4px 0;
  min-width: 180px;
  font-size: .875rem;
}
.ctx-item {
  padding: 6px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .1s;
}
.ctx-item:hover { background: #f0f4ff; }
.ctx-item.ctx-disabled {
  color: #adb5bd;
  cursor: default;
  pointer-events: none;
}
.ctx-divider {
  border-top: 1px solid #dee2e6;
  margin: 3px 0;
}

/* Flash zone */
.flash-zone { position: sticky; top: 52px; z-index: 100; }

/* Toast */
.toast-msg {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: .875rem;
  color: #fff;
  background: #198754;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.toast-warning { background: #fd7e14; }
.toast-danger   { background: #dc3545; }

/* Utility */
.btn-xs {
  padding: 1px 6px;
  font-size: .78rem;
  line-height: 1.4;
  border-radius: 3px;
}
.btn-xs.btn-close { padding: 2px; }

/* Admin cards hover */
.card:hover .card-body { background: #f0f4ff; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #999; }

/* Permission table cells (click to toggle) */
.perm-cell {
  cursor: pointer;
  user-select: none;
}
.perm-cell:hover { background: #f0f4ff; }

/* ── Mobile layout (< 768px) ── */
@media (max-width: 767px) {

  /* 整體 layout 改為相對定位容器 */
  .dm-layout {
    position: relative;
    overflow: hidden;
  }

  /* 側欄：佔滿全寬，覆蓋在主區上方 */
  .dm-sidebar {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    z-index: 20;
    border-right: none;
    transition: transform .25s ease;
  }
  .dm-sidebar.mobile-hidden {
    transform: translateX(-100%);
    pointer-events: none;
  }

  /* 主區改為全寬 */
  .dm-main { width: 100%; }

  /* 工具列返回按鈕（桌面隱藏） */
  #btnMobileBack { display: inline-flex !important; }

  /* 路徑文字縮短 */
  #currentPath { font-size: .75rem; max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 精簡表格：只保留案號、主旨、狀態 */
  #docTable th:nth-child(1),
  #docTable td:nth-child(1) { display: none; }   /* checkbox */
  #docTable th:nth-child(5),
  #docTable td:nth-child(5),
  #docTable th:nth-child(6),
  #docTable td:nth-child(6),
  #docTable th:nth-child(7),
  #docTable td:nth-child(7),
  #docTable th:nth-child(8),
  #docTable td:nth-child(8),
  #docTable th:nth-child(10),
  #docTable td:nth-child(10),
  #docTable th:nth-child(11),
  #docTable td:nth-child(11) { display: none; }

  /* 案號欄不換行，主旨允許截斷 */
  #docTable td:nth-child(3) { white-space: nowrap; font-size: .8rem; }
  #docTable td:nth-child(4) { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 點擊整列可操作 */
  #docTable tbody tr { cursor: pointer; }

  /* 工具列按鈕文字隱藏，只留圖示 */
  .dm-toolbar .btn-label { display: none; }
}
