/**
 * File Explorer Frontend Styles
 * Authored by Shafat Mahmud Khan — https://itsmeshafat.com
 */

/* =====================================================================
   THEME TOKENS — light (default), dark, mono
   Applied via data-ffe-theme on the container.
   ===================================================================== */

.frontend-file-explorer-frontend-container {
  --ffe-bg:              #fff;
  --ffe-bg-secondary:    #f7f8fa;
  --ffe-bg-hover:        #f0f2f5;
  --ffe-bg-item:         #fff;
  --ffe-text:            #1a1a2e;
  --ffe-text-muted:      #64748b;
  --ffe-border:          #e2e8f0;
  --ffe-accent:          #6366f1;
  --ffe-accent-hover:    #4f46e5;
  --ffe-accent-light:    #eef2ff;
  --ffe-accent-gradient: linear-gradient(135deg, #6366f1, #818cf8);
  --ffe-radius:          10px;
  --ffe-radius-card:     8px;
  --ffe-shadow-item:     0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --ffe-shadow-hover:    0 4px 12px rgba(99,102,241,0.12);
  --ffe-transition:      0.18s cubic-bezier(0.4,0,0.2,1);
  --ffe-sidebar-bg:      #f8fafc;
  --ffe-sidebar-width:   240px;
  --ffe-sidebar-active:  #6366f1;
  --ffe-sidebar-active-text: #fff;
  --ffe-folder-color:    #f59e0b;
}

.frontend-file-explorer-frontend-container[data-ffe-theme="dark"] {
  --ffe-bg:              #0f172a;
  --ffe-bg-secondary:    #1e293b;
  --ffe-bg-hover:        #263348;
  --ffe-bg-item:         #1e293b;
  --ffe-text:            #f1f5f9;
  --ffe-text-muted:      #94a3b8;
  --ffe-border:          #334155;
  --ffe-accent:          #818cf8;
  --ffe-accent-hover:    #6366f1;
  --ffe-accent-light:    #1e1b4b;
  --ffe-accent-gradient: linear-gradient(135deg, #818cf8, #a5b4fc);
  --ffe-shadow-item:     0 1px 3px rgba(0,0,0,0.3);
  --ffe-shadow-hover:    0 4px 12px rgba(0,0,0,0.4);
  --ffe-sidebar-bg:      #1a2537;
  --ffe-sidebar-active:  #818cf8;
  --ffe-sidebar-active-text: #0f172a;
  color-scheme: dark;
}

.frontend-file-explorer-frontend-container[data-ffe-theme="mono"] {
  --ffe-bg:              #fff;
  --ffe-bg-secondary:    #fafafa;
  --ffe-bg-hover:        #f3f4f6;
  --ffe-bg-item:         #fff;
  --ffe-text:            #111827;
  --ffe-text-muted:      #6b7280;
  --ffe-border:          #d1d5db;
  --ffe-accent:          #111827;
  --ffe-accent-hover:    #374151;
  --ffe-accent-light:    #f3f4f6;
  --ffe-accent-gradient: linear-gradient(135deg, #111827, #374151);
  --ffe-shadow-item:     0 1px 2px rgba(0,0,0,0.05);
  --ffe-shadow-hover:    0 2px 6px rgba(0,0,0,0.1);
  --ffe-sidebar-bg:      #f9fafb;
  --ffe-sidebar-active:  #111827;
  --ffe-sidebar-active-text: #fff;
}

.frontend-file-explorer-frontend-container[data-ffe-theme="ocean"] {
  --ffe-bg:              #fff;
  --ffe-bg-secondary:    #f0f9ff;
  --ffe-bg-hover:        #e0f2fe;
  --ffe-bg-item:         #fff;
  --ffe-text:            #0c1a2e;
  --ffe-text-muted:      #0369a1;
  --ffe-border:          #bae6fd;
  --ffe-accent:          #0ea5e9;
  --ffe-accent-hover:    #0284c7;
  --ffe-accent-light:    #e0f2fe;
  --ffe-accent-gradient: linear-gradient(135deg, #0ea5e9, #06b6d4);
  --ffe-shadow-item:     0 1px 3px rgba(14,165,233,0.08);
  --ffe-shadow-hover:    0 4px 12px rgba(14,165,233,0.16);
  --ffe-sidebar-bg:      #f0f9ff;
  --ffe-sidebar-active:  #0ea5e9;
  --ffe-sidebar-active-text: #fff;
  --ffe-folder-color:    #0ea5e9;
}

.frontend-file-explorer-frontend-container[data-ffe-theme="dusk"] {
  --ffe-bg:              #fff;
  --ffe-bg-secondary:    #fdf4ff;
  --ffe-bg-hover:        #fae8ff;
  --ffe-bg-item:         #fff;
  --ffe-text:            #1a0a2e;
  --ffe-text-muted:      #9333ea;
  --ffe-border:          #e9d5ff;
  --ffe-accent:          #a855f7;
  --ffe-accent-hover:    #9333ea;
  --ffe-accent-light:    #faf5ff;
  --ffe-accent-gradient: linear-gradient(135deg, #a855f7, #ec4899);
  --ffe-shadow-item:     0 1px 3px rgba(168,85,247,0.08);
  --ffe-shadow-hover:    0 4px 12px rgba(168,85,247,0.16);
  --ffe-sidebar-bg:      #fdf4ff;
  --ffe-sidebar-active:  #a855f7;
  --ffe-sidebar-active-text: #fff;
  --ffe-folder-color:    #a855f7;
}

.frontend-file-explorer-frontend-container[data-ffe-theme="forest"] {
  --ffe-bg:              #fff;
  --ffe-bg-secondary:    #f0fdf4;
  --ffe-bg-hover:        #dcfce7;
  --ffe-bg-item:         #fff;
  --ffe-text:            #052e16;
  --ffe-text-muted:      #15803d;
  --ffe-border:          #bbf7d0;
  --ffe-accent:          #16a34a;
  --ffe-accent-hover:    #15803d;
  --ffe-accent-light:    #dcfce7;
  --ffe-accent-gradient: linear-gradient(135deg, #16a34a, #22c55e);
  --ffe-shadow-item:     0 1px 3px rgba(22,163,74,0.08);
  --ffe-shadow-hover:    0 4px 12px rgba(22,163,74,0.14);
  --ffe-sidebar-bg:      #f0fdf4;
  --ffe-sidebar-active:  #16a34a;
  --ffe-sidebar-active-text: #fff;
  --ffe-folder-color:    #16a34a;
}

/* ---- Gradient themes ---- */

.frontend-file-explorer-frontend-container[data-ffe-theme="aurora"] {
  background-image: linear-gradient(140deg, #0d0221 0%, #150a2a 40%, #071526 100%);
  --ffe-bg:              transparent;
  --ffe-bg-secondary:    rgba(255,255,255,0.04);
  --ffe-bg-hover:        rgba(167,139,250,0.14);
  --ffe-bg-item:         rgba(255,255,255,0.07);
  --ffe-text:            #e2d9f3;
  --ffe-text-muted:      #a78bfa;
  --ffe-border:          rgba(167,139,250,0.2);
  --ffe-accent:          #a78bfa;
  --ffe-accent-hover:    #c4b5fd;
  --ffe-accent-light:    rgba(167,139,250,0.14);
  --ffe-accent-gradient: linear-gradient(135deg, #7c3aed, #06b6d4);
  --ffe-shadow-item:     0 1px 4px rgba(0,0,0,0.4);
  --ffe-shadow-hover:    0 4px 16px rgba(124,58,237,0.35);
  --ffe-sidebar-bg:      rgba(255,255,255,0.03);
  --ffe-sidebar-active:  #a78bfa;
  --ffe-sidebar-active-text: #0d0221;
  --ffe-folder-color:    #a78bfa;
  color-scheme: dark;
}

.frontend-file-explorer-frontend-container[data-ffe-theme="sunset"] {
  background-image: linear-gradient(135deg, #fff7ed 0%, #fef3c7 50%, #fce7f3 100%);
  --ffe-bg:              transparent;
  --ffe-bg-secondary:    rgba(255,255,255,0.6);
  --ffe-bg-hover:        rgba(249,115,22,0.1);
  --ffe-bg-item:         rgba(255,255,255,0.75);
  --ffe-text:            #1c1917;
  --ffe-text-muted:      #78716c;
  --ffe-border:          rgba(249,115,22,0.22);
  --ffe-accent:          #f97316;
  --ffe-accent-hover:    #ea580c;
  --ffe-accent-light:    rgba(249,115,22,0.1);
  --ffe-accent-gradient: linear-gradient(135deg, #f97316, #ec4899);
  --ffe-shadow-item:     0 1px 4px rgba(249,115,22,0.1);
  --ffe-shadow-hover:    0 4px 16px rgba(249,115,22,0.22);
  --ffe-sidebar-bg:      rgba(255,255,255,0.5);
  --ffe-sidebar-active:  #f97316;
  --ffe-sidebar-active-text: #fff;
  --ffe-folder-color:    #f97316;
}

/* =====================================================================
   CONTAINER
   ===================================================================== */

.frontend-file-explorer-frontend-container {
  background-color: var(--ffe-bg);
  border: 1px solid var(--ffe-border);
  border-radius: var(--ffe-radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  margin: 20px 0;
  max-width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  color: var(--ffe-text);
  overflow: hidden;
}

/* =====================================================================
   TOOLBAR
   ===================================================================== */

.frontend-file-explorer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--ffe-bg);
  border-bottom: 1px solid var(--ffe-border);
  padding: 10px 14px;
  gap: 8px;
  flex-wrap: wrap;
}

.frontend-file-explorer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.frontend-file-explorer-search {
  display: flex;
  align-items: center;
  background-color: var(--ffe-bg);
  border: 1px solid var(--ffe-border);
  border-radius: var(--ffe-radius);
  padding: 4px 8px;
  gap: 4px;
}

.frontend-file-explorer-search .material-icons {
  color: var(--ffe-text-muted);
  font-size: 18px;
}

.frontend-file-explorer-search input[type="search"] {
  border: none;
  box-shadow: none;
  font-size: 13px;
  margin: 0;
  outline: none;
  padding: 2px;
  width: 160px;
  max-width: 180px;
  background: transparent;
  color: var(--ffe-text);
}

.frontend-file-explorer-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
}

.frontend-file-explorer-btn {
  background-color: var(--ffe-bg);
  border: 1px solid var(--ffe-border);
  border-radius: 6px;
  color: var(--ffe-text-muted, var(--ffe-text));
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  text-decoration: none;
  transition: all var(--ffe-transition);
  line-height: 1;
  min-height: 32px;
}

.frontend-file-explorer-btn:hover {
  background-color: var(--ffe-bg-hover);
  border-color: var(--ffe-accent);
  color: var(--ffe-accent);
}

.frontend-file-explorer-btn.ffe-btn-primary {
  background: var(--ffe-accent);
  border-color: var(--ffe-accent);
  color: #fff;
}

.frontend-file-explorer-btn.ffe-btn-primary:hover {
  background: var(--ffe-accent-hover);
  border-color: var(--ffe-accent-hover);
  color: #fff;
}

.frontend-file-explorer-btn .material-icons { font-size: 16px; }

#frontend-file-explorer-frontend-download-zip {
  background-color: #4CAF50;
  color: #fff;
  border-color: #43A047;
}

#frontend-file-explorer-frontend-download-zip:hover { background-color: #43A047; }

#frontend-file-explorer-frontend-current-path {
  font-size: 12px;
  font-weight: 500;
  color: var(--ffe-text);
  margin-left: 2px;
  padding: 4px 10px;
  background: var(--ffe-bg-secondary);
  border: 1px solid var(--ffe-border);
  border-radius: 6px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Theme switcher (small swatches in toolbar) */
.ffe-theme-switcher {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ffe-theme-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--ffe-border);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--ffe-transition), transform var(--ffe-transition);
  padding: 0;
}

.ffe-theme-btn:hover, .ffe-theme-btn.active { border-color: var(--ffe-accent); transform: scale(1.2); }
.ffe-theme-btn[data-theme="light"] { background: #f7f7f7; }
.ffe-theme-btn[data-theme="dark"]  { background: #1e1e1e; }
.ffe-theme-btn[data-theme="mono"]  { background: linear-gradient(135deg,#fff 50%,#111 50%); }

/* =====================================================================
   LAYOUT — sidebar + main
   ===================================================================== */

.ffe-layout {
  display: flex;
  min-height: 400px;
}

.ffe-main {
  flex: 1;
  min-width: 0;
  position: relative;
}

/* =====================================================================
   SIDEBAR
   ===================================================================== */

.ffe-sidebar {
  width: var(--ffe-sidebar-width);
  flex-shrink: 0;
  background: var(--ffe-sidebar-bg);
  border-right: 1px solid var(--ffe-border);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.2s cubic-bezier(0.4,0,0.2,1);
}

.ffe-sidebar.collapsed {
  width: 48px;
}

.ffe-sidebar.collapsed .ffe-sidebar-heading,
.ffe-sidebar.collapsed .ffe-sidebar-label {
  display: none;
}

.ffe-sidebar.collapsed .ffe-sidebar-tree-item,
.ffe-sidebar.collapsed .ffe-filter-btn {
  justify-content: center;
  padding: 7px 0;
}

.ffe-sidebar.collapsed .ffe-sidebar-tree-item .material-icons,
.ffe-sidebar.collapsed .ffe-filter-btn .material-icons {
  font-size: 18px;
}

.ffe-sidebar.collapsed .ffe-sidebar-subtree {
  display: none !important;
}

.ffe-sidebar-section {
  padding: 10px 0 2px;
}

.ffe-sidebar-heading {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ffe-text-muted);
  padding: 0 10px 4px;
  margin: 0;
}

.ffe-sidebar-tree,
.ffe-sidebar-filters {
  list-style: none;
  margin: 0;
  padding: 0 0 6px;
}

.ffe-sidebar-tree li,
.ffe-sidebar-filters li { margin: 0; padding: 0; }

.ffe-sidebar-tree li ul {
  list-style: none;
  margin: 0;
  padding-left: 16px;
}

.ffe-sidebar-tree-item,
.ffe-filter-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 14px;
  font-size: 12.5px;
  color: var(--ffe-text-muted);
  cursor: pointer;
  background: none;
  border: none;
  border-left: 2.5px solid transparent;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--ffe-transition), color var(--ffe-transition), border-color var(--ffe-transition);
  line-height: 1.4;
}

.ffe-sidebar-tree-item:hover,
.ffe-filter-btn:hover {
  background: var(--ffe-bg-hover);
  color: var(--ffe-text);
}

.ffe-sidebar-tree-item.active,
.ffe-filter-btn.active {
  background: var(--ffe-accent-light);
  color: var(--ffe-accent);
  font-weight: 600;
  border-left-color: var(--ffe-accent);
}

.ffe-sidebar-tree-item .material-icons,
.ffe-filter-btn .material-icons { font-size: 16px; flex-shrink: 0; }

/* sidebar toggle button (inside toolbar) */
.ffe-sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ffe-text-muted);
  padding: 4px;
  border-radius: var(--ffe-radius);
  line-height: 0;
  transition: background var(--ffe-transition), color var(--ffe-transition);
  margin-right: 4px;
}

.ffe-sidebar-toggle:hover {
  background: var(--ffe-bg-hover);
  color: var(--ffe-text);
}

/* =====================================================================
   CONTENT / ITEM GRID
   ===================================================================== */

.frontend-file-explorer-content {
  min-height: 400px;
  padding: 16px;
  position: relative;
}

.frontend-file-explorer-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  clear: both;
}

.frontend-file-explorer-item {
  background-color: var(--ffe-bg-item);
  border: 1px solid var(--ffe-border);
  border-radius: var(--ffe-radius-card);
  box-shadow: var(--ffe-shadow-item);
  cursor: pointer;
  padding: 14px 12px 10px;
  text-align: center;
  transition: box-shadow var(--ffe-transition), border-color var(--ffe-transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.frontend-file-explorer-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  transition: background var(--ffe-transition);
}

.frontend-file-explorer-item:hover {
  box-shadow: var(--ffe-shadow-hover);
  border-color: var(--ffe-accent);
}

.frontend-file-explorer-item:hover::before {
  background: var(--ffe-accent-gradient);
}

.frontend-file-explorer-item[data-type="folder"]:hover::before {
  background: var(--ffe-folder-color, #f59e0b);
}

.frontend-file-explorer-item-icon {
  color: var(--ffe-text-muted);
  font-size: 36px;
  margin-bottom: 8px;
  text-align: center;
  line-height: 1;
}

.frontend-file-explorer-item-icon .folder-icon {
  font-size: 44px;
  color: var(--ffe-folder-color, #f59e0b);
}

/* custom folder color support */
.frontend-file-explorer-item-icon [data-folder-color] {
  color: attr(data-folder-color);
}

.frontend-file-explorer-item-preview {
  height: 110px;
  margin-bottom: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.frontend-file-explorer-item:has(.frontend-file-explorer-item-preview) .frontend-file-explorer-item-icon .material-icons {
  display: none;
}

.frontend-file-explorer-item-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.frontend-file-explorer-item-name {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 4px;
  word-break: break-word;
  color: var(--ffe-text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.frontend-file-explorer-item-meta {
  font-size: 10px;
  color: var(--ffe-text-muted);
  margin-bottom: 2px;
}

.frontend-file-explorer-item-actions {
  display: flex;
  justify-content: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--ffe-transition);
}

.frontend-file-explorer-item:hover .frontend-file-explorer-item-actions { opacity: 1; }

.frontend-file-explorer-item-actions button {
  background: none;
  border: none;
  color: var(--ffe-accent);
  cursor: pointer;
  padding: 4px;
  border-radius: 2px;
  transition: color var(--ffe-transition), background var(--ffe-transition);
}

.frontend-file-explorer-item-actions button:hover {
  color: var(--ffe-accent-hover);
  background: var(--ffe-accent-light);
}

.frontend-file-explorer-item-actions .material-icons { font-size: 18px; }

/* Protected folder lock badge */
.ffe-item-lock {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 12px !important;
  color: var(--ffe-text-muted);
}

.frontend-file-explorer-item { position: relative; }

/* =====================================================================
   EMPTY / LOADING STATES
   ===================================================================== */

.frontend-file-explorer-empty {
  align-items: center;
  color: var(--ffe-text-muted);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 280px;
}

.frontend-file-explorer-empty .material-icons {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.frontend-file-explorer-loading {
  align-items: center;
  background-color: color-mix(in srgb, var(--ffe-bg) 85%, transparent);
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: center;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
  z-index: 10;
}

.frontend-file-explorer-loading .material-icons {
  font-size: 44px;
  margin-bottom: 10px;
  animation: spin 2s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =====================================================================
   PAGINATION
   ===================================================================== */

.frontend-file-explorer-pagination {
  display: flex;
  justify-content: center;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--ffe-border);
}

.frontend-file-explorer-credit {
  margin: 0;
  padding: 0 16px 14px;
  text-align: center;
  font-size: 11px;
  color: var(--ffe-text-muted);
}

/* =====================================================================
   NOTIFICATION
   ===================================================================== */

.frontend-file-explorer-notification {
  background-color: var(--ffe-bg);
  border-left: 4px solid var(--ffe-accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  padding: 12px 16px;
  position: fixed;
  right: 20px;
  top: 20px;
  z-index: 9999;
  color: var(--ffe-text);
  animation: slideIn 0.25s ease-out;
  border-radius: 0 var(--ffe-radius) var(--ffe-radius) 0;
  max-width: 320px;
}

.frontend-file-explorer-notification.success { border-left-color: #46b450; }
.frontend-file-explorer-notification.error   { border-left-color: #dc3232; }

@keyframes slideIn {
  from { transform: translateX(calc(100% + 20px)); }
  to   { transform: translateX(0); }
}

/* =====================================================================
   PREVIEW MODAL
   ===================================================================== */

.ffe-preview-dialog {
  padding: 0;
  border: none;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.12);
  max-width: 92vw;
  max-height: 92vh;
  width: 860px;
  overflow: hidden;
  background: var(--ffe-bg);
  color: var(--ffe-text);
}
.ffe-preview-dialog[open] {
  display: flex;
  flex-direction: column;
}

.ffe-preview-dialog::backdrop {
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
}

.ffe-preview-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--ffe-border);
  background: var(--ffe-bg-secondary);
  flex-shrink: 0;
}

.ffe-preview-file-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--ffe-accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ffe-preview-file-icon .material-icons {
  font-size: 20px;
  color: var(--ffe-accent);
}

.ffe-preview-info {
  flex: 1;
  min-width: 0;
}

.ffe-preview-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ffe-text);
}

.ffe-preview-ext {
  display: block;
  font-size: 11px;
  color: var(--ffe-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 1px;
}

.ffe-preview-dl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--ffe-accent);
  color: #fff;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background var(--ffe-transition), transform 0.1s;
  white-space: nowrap;
  flex-shrink: 0;
}

.ffe-preview-dl:hover { background: var(--ffe-accent-hover); color: #fff; transform: translateY(-1px); }
.ffe-preview-dl:active { transform: translateY(0); }
.ffe-preview-dl .material-icons { font-size: 15px; }

.ffe-preview-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ffe-text-muted);
  padding: 6px;
  border-radius: 8px;
  line-height: 0;
  transition: color var(--ffe-transition), background var(--ffe-transition);
  flex-shrink: 0;
}

.ffe-preview-close:hover {
  color: var(--ffe-text);
  background: var(--ffe-bg-hover);
}

.ffe-preview-close .material-icons { font-size: 20px; }

.ffe-preview-body {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  flex: 1;
  min-height: 0;
  background: var(--ffe-bg-item);
  position: relative;
}

.ffe-preview-body img {
  max-width: 100%;
  max-height: calc(92vh - 70px);
  object-fit: contain;
  display: block;
}

.ffe-preview-body iframe {
  width: 100%;
  height: calc(92vh - 70px);
  border: none;
  display: block;
}

.ffe-preview-body video {
  max-width: 100%;
  max-height: calc(92vh - 70px);
  display: block;
  outline: none;
}

.ffe-preview-body audio {
  display: block;
  width: 340px;
  max-width: 90%;
  margin: 40px auto;
}

.ffe-preview-unsupported {
  text-align: center;
  padding: 60px 30px;
  color: var(--ffe-text-muted);
}

.ffe-preview-unsupported .material-icons {
  font-size: 56px;
  display: block;
  margin-bottom: 14px;
  opacity: 0.5;
}

.ffe-preview-unsupported p {
  font-size: 13px;
  margin: 0;
}

/* =====================================================================
   SHARE LINK BADGE (Pro feature — appears in item actions)
   ===================================================================== */

.ffe-share-badge {
  font-size: 10px;
  background: var(--ffe-accent-light);
  color: var(--ffe-accent);
  border-radius: 2px;
  padding: 1px 4px;
  vertical-align: middle;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */

/* =====================================================================
   VIEW TOGGLE BUTTON
   ===================================================================== */

.ffe-view-toggle {
  display: inline-flex;
  border: 1px solid var(--ffe-border);
  border-radius: 6px;
  overflow: hidden;
}

.ffe-view-btn {
  background: var(--ffe-bg);
  border: none;
  color: var(--ffe-text-muted);
  cursor: pointer;
  padding: 5px 8px;
  line-height: 0;
  transition: background var(--ffe-transition), color var(--ffe-transition);
}

.ffe-view-btn:hover {
  background: var(--ffe-bg-hover);
  color: var(--ffe-text);
}

.ffe-view-btn.active {
  background: var(--ffe-accent-light);
  color: var(--ffe-accent);
}

.ffe-view-btn .material-icons { font-size: 17px; }

/* =====================================================================
   LIST VIEW
   ===================================================================== */

.frontend-file-explorer-items.ffe-list-view {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.frontend-file-explorer-items.ffe-list-view .frontend-file-explorer-item {
  flex-direction: row;
  text-align: left;
  padding: 8px 12px;
  gap: 10px;
  align-items: center;
  border-radius: 6px;
}

.frontend-file-explorer-items.ffe-list-view .frontend-file-explorer-item::before {
  display: none;
}

.frontend-file-explorer-items.ffe-list-view .frontend-file-explorer-item-icon {
  font-size: 22px;
  margin-bottom: 0;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.frontend-file-explorer-items.ffe-list-view .frontend-file-explorer-item-icon .folder-icon {
  font-size: 22px;
}

.frontend-file-explorer-items.ffe-list-view .frontend-file-explorer-item-preview {
  display: flex;
  height: 36px;
  width: 36px;
  min-width: 36px;
  margin-bottom: 0;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.frontend-file-explorer-items.ffe-list-view .frontend-file-explorer-item-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.frontend-file-explorer-items.ffe-list-view .frontend-file-explorer-item-name {
  flex: 1;
  font-size: 13px;
  margin-bottom: 0;
  -webkit-line-clamp: 1;
  white-space: nowrap;
}

.frontend-file-explorer-items.ffe-list-view .frontend-file-explorer-item-meta {
  font-size: 11px;
  margin-bottom: 0;
  min-width: 60px;
  text-align: right;
}

.frontend-file-explorer-items.ffe-list-view .frontend-file-explorer-item-actions {
  opacity: 1;
  transform: none;
  flex-shrink: 0;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */

@media (max-width: 782px) {
  .frontend-file-explorer-frontend-container { --ffe-sidebar-width: 180px; }
  .frontend-file-explorer-items {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }
}

@media (max-width: 540px) {
  .frontend-file-explorer-frontend-container { --ffe-sidebar-width: 48px; }
  .ffe-sidebar { --ffe-sidebar-width: 48px; }
  .frontend-file-explorer-items {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
  }
  .frontend-file-explorer-item { padding: 10px 8px 8px; }
  .frontend-file-explorer-item-icon { font-size: 30px; }
  .frontend-file-explorer-item-preview { height: 60px; }
  .frontend-file-explorer-item-name { font-size: 11px; }
  .ffe-preview-dialog { max-width: 100vw; max-height: 100vh; width: 100%; border-radius: 0; }
}

/* =====================================================================
   PASSWORD MODAL
   ===================================================================== */

.ffe-password-modal {
  border: none;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.12);
  background: var(--ffe-bg);
  color: var(--ffe-text);
  width: min(360px, 92vw);
  overflow: hidden;
}

.ffe-password-modal::backdrop {
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}

.ffe-password-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--ffe-border);
  background: var(--ffe-bg-secondary);
}

.ffe-password-modal-header .material-icons {
  font-size: 20px;
  color: var(--ffe-accent);
  flex-shrink: 0;
}

.ffe-password-modal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ffe-text);
  margin: 0;
}

.ffe-password-modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ffe-password-label {
  font-size: 13px;
  color: var(--ffe-text-muted);
  margin: 0;
}

.ffe-password-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--ffe-border);
  border-radius: var(--ffe-radius);
  background: var(--ffe-bg-secondary);
  color: var(--ffe-text);
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  transition: border-color var(--ffe-transition);
}

.ffe-password-input:focus {
  border-color: var(--ffe-accent);
}

.ffe-password-error {
  font-size: 12px;
  color: var(--ffe-danger, #ef4444);
  margin: 0;
  display: none;
}

.ffe-password-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 0 18px 18px;
}

/* =====================================================================
   SIDEBAR — MOBILE OVERLAY MODE
   ===================================================================== */

/* backdrop that closes sidebar on tap-outside */
.ffe-sidebar-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 10;
}

@media (max-width: 540px) {
  .ffe-layout {
    position: relative;
    overflow: hidden;
  }

  /* sidebar becomes a full-height overlay panel */
  .ffe-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 11;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
    width: 220px !important;
    box-shadow: 4px 0 20px rgba(0,0,0,0.18);
  }

  /* open state toggled by JS */
  .ffe-sidebar.mobile-open {
    transform: translateX(0);
  }

  /* hide the collapsed icon-only state on mobile — full or hidden */
  .ffe-sidebar.collapsed {
    width: 220px !important;
  }

  .ffe-sidebar-overlay.active {
    display: block;
  }

  /* bigger touch targets for sidebar items on mobile */
  .ffe-sidebar-tree-item,
  .ffe-filter-btn {
    padding: 10px 14px;
    font-size: 14px;
    min-height: 44px;
  }

  .ffe-sidebar-tree-item .material-icons,
  .ffe-filter-btn .material-icons {
    font-size: 20px;
  }
}

/* Icon packs — swapped-in SVG glyphs inside .material-icons spans */
.material-icons.ffe-icon-packed {
  font-family: inherit;
  font-size: inherit;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.material-icons.ffe-icon-packed .ffe-pack-svg {
  width: 1em;
  height: 1em;
  display: block;
  color: inherit;
}

/* Sidebar alignment: some themes force justify-content:center on buttons —
   keep tree/filter rows flush-left like the admin sidebar. */
.ffe-sidebar-tree-item,
.ffe-filter-btn {
  justify-content: flex-start;
  text-align: left;
}
