body {
  background-color: #f8f9fa;
  overflow-x: hidden;
}
[data-bs-theme="dark"] body {
  background-color: #121212;
}
.sidebar-column {
  height: 100vh;
  overflow: hidden;
}
.main-column {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1030;
}
[data-bs-theme="dark"] .mobile-overlay {
  background: rgba(0, 0, 0, 0.6);
}
.resize-divider {
  width: 4px;
  flex: 0 0 4px;
  cursor: col-resize;
  background: linear-gradient(
    to right,
    transparent 0,
    transparent 2px,
    #dee2e6 2px,
    #dee2e6 4px
  );
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  height: 100vh;
  align-self: stretch;
  position: relative;
  z-index: 1020;
}
[data-bs-theme="dark"] .resize-divider {
  background: linear-gradient(
    to right,
    transparent 0,
    transparent 2px,
    #343a40 2px,
    #343a40 4px
  );
}
.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  align-content: flex-start;
}
.file-list.list {
  flex-direction: column;
}
.file-item {
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 6px;
  display: flex;
  align-items: center;
  width: 260px;
  background-color: #fff;
  position: relative;
  box-sizing: border-box;
}
[data-bs-theme="dark"] .file-item {
  background-color: #1e1f22;
  border-color: #343a40;
}
.file-item:hover {
  background-color: #dfefff;
  border-color: #ced4da;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
[data-bs-theme="dark"] .file-item:hover {
  background-color: #2a2e32;
  border-color: #495057;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.file-list.list .file-item {
  width: 100%;
}
.file-thumb {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
}
.file-thumb .file-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
}
.file-meta {
  flex: 1;
  min-width: 0;
}
.file-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
}
.file-sub {
  color: #6c757d;
  font-size: 0.7rem;
}
[data-bs-theme="dark"] .file-sub {
  color: #adb5bd;
}
.file-actions {
  display: flex;
  gap: 6px;
  position: absolute;
  right: 8px;
  top: 8px;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.file-item:hover .file-actions {
  opacity: 0;
  pointer-events: none;
}
.file-actions .btn {
  padding: 2px 6px;
}
.context-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  z-index: 1065;
  min-width: 180px;
  padding: 4px;
}
[data-bs-theme="dark"] .context-menu {
  background: #1e1f22;
  border-color: #343a40;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
.context-menu .menu-item {
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.context-menu .menu-item:hover {
  background-color: #f1f3f5;
}
[data-bs-theme="dark"] .context-menu .menu-item:hover {
  background-color: #2f3438;
}
.context-menu .menu-sep {
  height: 1px;
  margin: 4px 0;
  background: #e9ecef;
}
[data-bs-theme="dark"] .context-menu .menu-sep {
  background: #343a40;
}
.select-mode .file-item .form-check-input {
  display: block !important;
  z-index: 2;
}
.file-item.selected {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.1);
}
.folder-link.active span {
  font-weight: 600;
  color: #0d6efd;
}
.folder-link {
  cursor: pointer;
}
.file-meta .inline-input {
  width: 100%;
  height: 28px;
  font-size: 0.9rem;
  padding: 2px 6px;
}
.drag-over {
  background-color: rgba(13, 110, 253, 0.08);
  outline: 1px dashed #0d6efd;
}
.toolbar-sticky {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: #fff;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  box-shadow: 0 4px 5px rgba(0, 0, 0, 0.1);
}
[data-bs-theme="dark"] .toolbar-sticky {
  background: #1e1f22;
  box-shadow: 0 4px 5px rgba(0, 0, 0, 0.4);
}
.toolbar-sticky .tool-bar {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.toolbar-sticky .tool-bar > * {
  flex: 0 0 auto;
}
.sidebar-sticky {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}
.breadcrumb-bar {
  width: 100%;
  border: 1px solid #dee2e6;
  background: #fff;
  padding: 0.375rem 0.75rem;
  border-radius: 5px;
}
[data-bs-theme="dark"] .breadcrumb-bar {
  background: #1e1f22;
  border-color: #343a40;
}
.bottom-bar {
  background: #fff;
  border-top: 1px solid #dee2e6;
}
[data-bs-theme="dark"] .bottom-bar {
  background: #1e1f22;
  border-top-color: #343a40;
}
.bottom-bar #storage-info {
  box-shadow: inset 10px 0 10px rgba(0, 0, 0, 0.2);
  border-left: 1px solid #2b2b2b;
}
/* El listado ocupa el espacio disponible y hace scroll interno */
.file-list {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
}
.file-list.list {
  flex-direction: column;
  width: 100%;
  flex-wrap: nowrap;
}
.file-list.grid .file-actions {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  padding: 4px;
  z-index: 1061;
  top: 0;
  right: 8px;
  transform: translateY(-100%) translateY(-6px);
}
[data-bs-theme="dark"] .file-list.grid .file-actions {
  background: #1e1f22;
  border-color: #343a40;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.file-list.grid .file-actions::before {
  content: "";
  position: absolute;
  bottom: -14px;
  right: 16px;
  border-width: 7px;
  border-style: solid;
  border-color: #dee2e6 transparent transparent transparent;
}
[data-bs-theme="dark"] .file-list.grid .file-actions::before {
  border-color: #343a40 transparent transparent transparent;
}
.file-list.grid .file-actions::after {
  content: "";
  position: absolute;
  bottom: -12px;
  right: 16px;
  border-width: 6px;
  border-style: solid;
  border-color: #fff transparent transparent transparent;
}
[data-bs-theme="dark"] .file-list.grid .file-actions::after {
  border-color: #1e1f22 transparent transparent transparent;
}
.file-list.grid .file-item.popover-below .file-actions {
  top: auto;
  bottom: 0;
  transform: translateY(100%) translateY(6px);
}
.file-list.grid .file-item.popover-below .file-actions::before {
  content: "";
  position: absolute;
  top: -14px;
  bottom: auto;
  right: 16px;
  border-width: 7px;
  border-style: solid;
  border-color: transparent transparent #dee2e6 transparent;
}
[data-bs-theme="dark"]
  .file-list.grid
  .file-item.popover-below
  .file-actions::before {
  border-color: transparent transparent #343a40 transparent;
}
.file-list.grid .file-item.popover-below .file-actions::after {
  content: "";
  position: absolute;
  top: -12px;
  bottom: auto;
  right: 16px;
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent #fff transparent;
}
[data-bs-theme="dark"]
  .file-list.grid
  .file-item.popover-below
  .file-actions::after {
  border-color: transparent transparent #1e1f22 transparent;
}
.suggest-list {
  position: absolute;
  z-index: 1050;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #dee2e6;
  border-top: none;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}
[data-bs-theme="dark"] .suggest-list {
  background: #1e1f22;
  border-color: #343a40;
}
.suggest-item {
  padding: 6px 10px;
  cursor: pointer;
}
.suggest-item strong {
  font-weight: 700;
}
.suggest-item.active,
.suggest-item:hover {
  background-color: #f1f3f5;
}
[data-bs-theme="dark"] .suggest-item.active,
[data-bs-theme="dark"] .suggest-item:hover {
  background-color: #2f3438;
}
/* Quitar borde a items anidados del árbol (solo padres con borde) */
#folderTree .children-list .list-group-item {
  border: 0 !important;
}

.preview-image-area {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
}
.preview-image-area img {
  max-width: 100%;
  max-height: 100%;
  transform-origin: 0 0;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}
.preview-image-area img.zoomed {
  cursor: grab;
}
#previewModal .modal-dialog {
  margin-top: 1rem;
  margin-bottom: 1rem;
  height: calc(100vh - 2rem);
}
#previewModal .modal-content {
  height: 100%;
  display: flex;
  flex-direction: column;
}
#previewModal .modal-header,
#previewModal .modal-footer {
  flex-shrink: 0;
}
#previewModal .modal-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  background: #000;
}
.preview-fill {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
}
#previewPdf {
  width: 100%;
  border: 0;
}
#previewText {
  margin-bottom: 0;
  border-radius: 0;
}
#previewAudio {
  padding: 0 20%;
}

@media (max-width: 767.98px) {
  #sidebarCol {
    display: none;
  }
  #columnsResizer {
    display: none;
  }
  #mainCol {
    flex: 0 0 100%;
    max-width: 100%;
  }
  .container-fluid.mobile-sidebar-open #sidebarCol {
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 330px;
    background: #fff;
    border-right: 1px solid #dee2e6;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    z-index: 1040;
  }
  [data-bs-theme="dark"] .container-fluid.mobile-sidebar-open #sidebarCol {
    background: #1e1f22;
    border-right-color: #343a40;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.6);
  }
  .container-fluid.mobile-sidebar-open .mobile-overlay {
    display: block !important;
  }
  .file-item {
    width: calc(50vw - 22px);
  }
}
