/* ============================================================
   FileBrowser — sleek modern theme, violet accent
   Light + dark via the app's own :root / :root.dark variables
   ============================================================ */

/* ---------- Light ---------- */
:root {
  --background: #f7f7fb;
  --surfacePrimary: #ffffff;
  --surfaceSecondary: #ededf4;

  --textPrimary: #5b6172;   /* muted body text (app semantics: primary = muted) */
  --textSecondary: #14161f; /* strong text */

  --borderPrimary: rgba(20, 22, 31, 0.08);
  --borderSecondary: rgba(20, 22, 31, 0.16);
  --divider: rgba(20, 22, 31, 0.07);
  --hover: rgba(124, 58, 237, 0.06);

  /* accent: remap the app's blue to violet */
  --blue: #7c3aed;
  --dark-blue: #6d28d9;
  --icon-blue: #7c3aed;

  /* calmer file-type icon palette */
  --iconPrimary: #8b5cf6;
  --icon-red: #f0616d;
  --icon-orange: #f59e0b;
  --icon-yellow: #fbbf24;
  --icon-green: #34c98e;
  --icon-violet: #a78bfa;
}

/* ---------- Dark ---------- */
:root.dark {
  --background: #0e0f14;
  --surfacePrimary: #16171f;
  --surfaceSecondary: #23242f;

  --textPrimary: rgba(235, 236, 245, 0.62);
  --textSecondary: rgba(240, 240, 250, 0.94);

  --borderPrimary: rgba(255, 255, 255, 0.06);
  --borderSecondary: rgba(255, 255, 255, 0.14);
  --divider: rgba(255, 255, 255, 0.08);
  --hover: rgba(167, 139, 250, 0.09);

  --blue: #8b5cf6;
  --dark-blue: #7c3aed;
  --icon-blue: #a78bfa;

  --iconPrimary: #a78bfa;
  --icon-red: #f2727d;
  --icon-orange: #fba94b;
  --icon-yellow: #fcd34d;
  --icon-green: #3dd598;
  --icon-violet: #b8a1fa;
}

/* ---------- Typography ---------- */
/* self-hosted via the branding img/ passthrough — no external requests */
@font-face {
  font-family: "Sora";
  src: url("/static/img/fonts/sora-var.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

body,
input,
button,
textarea,
select {
  font-family: "Sora", "Segoe UI Variable", "Segoe UI", system-ui,
    -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(139, 92, 246, 0.3);
}

/* ---------- Header (frosted) ---------- */
header {
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--divider);
  box-shadow: none;
}
:root.dark header {
  background: rgba(22, 23, 31, 0.72);
}

/* ---------- Search bar → centered pill ---------- */
/* header siblings consume flex space, so true-center absolutely (desktop only) */
@media (min-width: 900px) {
  #search {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 25em;
    height: 2.6em;
  }
  #search.active {
    left: auto;
    transform: none;
  }
}
#search #input {
  border-radius: 999px;
  border: 1px solid var(--divider);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#search #input:focus-within {
  border-color: var(--blue);
}
#search.active #input {
  border-radius: 0.6em;
}

/* ---------- Listing items ---------- */
#listing .item {
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease,
    box-shadow 0.12s ease, transform 0.12s ease;
}
#listing .item:hover {
  background: var(--hover);
  border-color: var(--borderPrimary);
}
#listing.mosaic .item {
  border: 1px solid var(--divider);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
#listing.mosaic .item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

/* ---------- Buttons ---------- */
.button {
  border-radius: 10px;
  transition: background 0.15s ease, box-shadow 0.15s ease,
    transform 0.1s ease;
}
.button--blue {
  background: linear-gradient(135deg, var(--blue), var(--dark-blue));
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}
.button--blue:hover {
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.45);
  transform: translateY(-1px);
}

/* ---------- Inputs ---------- */
.input {
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  border-color: var(--blue);
}

/* ---------- Cards / modals / share boxes ---------- */
.card {
  border-radius: 16px;
  border: 1px solid var(--divider);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.share__box {
  border-radius: 16px;
  border: 1px solid var(--divider);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
}

/* ---------- Sidebar ---------- */
/* the file sidebar is a bare <nav>; the settings tab bar is <nav id="nav"> */
@media (min-width: 737px) {
  nav:not(#nav) {
    background: var(--surfacePrimary);
    border-right: 1px solid var(--divider);
    width: 18em;
    height: calc(100% - 4em);
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 0.75em;
  }
  /* main's width is coupled to the sidebar width (16em + 3em gutters stock) */
  main {
    width: calc(100% - 21em);
  }
}
nav .action {
  border-radius: 10px;
  margin: 0 0.5em;
  width: calc(100% - 1em);
  transition: background 0.12s ease;
}
nav .action:hover {
  background: var(--hover);
}

/* ---------- Breadcrumbs ---------- */
.breadcrumbs a {
  border-radius: 8px;
}
.breadcrumbs a:hover {
  background-color: var(--hover);
}

/* ---------- Selection state ---------- */
#listing .item[aria-selected="true"] {
  background: rgba(124, 58, 237, 0.12) !important;
  color: var(--textSecondary) !important;
  box-shadow: inset 0 0 0 2px var(--blue);
  border-color: transparent;
}
#listing .item[aria-selected="true"] i {
  color: var(--blue);
}
:root.dark #listing .item[aria-selected="true"] {
  background: rgba(139, 92, 246, 0.18) !important;
}

/* ---------- Focus rings ---------- */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.button:focus-visible {
  outline-offset: 3px;
}
/* text fields already signal focus with their own violet border + soft ring
   (.input:focus / #search #input:focus-within), so the global outline above
   stacked a second concentric line on them — suppress it for fields only,
   keeping the ring for buttons, links, checkboxes and radios */
input:not([type="checkbox"]):not([type="radio"]):focus-visible,
textarea:focus-visible,
select:focus-visible,
.input:focus-visible {
  outline: none;
}

/* ---------- Login page ---------- */
#login {
  background: #0e0f14 url("/static/img/login-bg.jpg") center / cover no-repeat;
}
#login form {
  background: rgba(255, 255, 255, 0.85);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
  border: 1px solid var(--divider);
  border-radius: 20px;
  max-width: 22em;
  padding: 2.5em 2em;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}
:root.dark #login form {
  background: rgba(22, 23, 31, 0.8);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

/* ---------- Dropdown / context menu ---------- */
#dropdown {
  background: var(--surfacePrimary);
  border: 1px solid var(--divider);
  border-radius: 14px;
  padding: 0.3em;
  overflow: hidden;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18);
}
#dropdown .action {
  border-radius: 9px;
}

/* ---------- Progress bars (stock cyan → accent) ---------- */
.progress div,
.file-progress div {
  background-color: var(--blue);
}

/* ---------- Share page ---------- */
.share__box__icon i {
  color: var(--blue);
  font-size: 8em;
}
.share__box__header {
  font-weight: 500;
  padding: 1.25em 1em 0.75em;
}

/* ---------- Empty state ---------- */
.message {
  font-size: 1.4em;
  font-weight: 500;
  color: var(--textPrimary);
}
.message i {
  display: block;
  width: fit-content;
  margin: 0 auto 0.3em;
  line-height: 1;
  font-size: 2.6em;
  color: var(--blue);
}

/* ---------- Micro-animations ---------- */
@media (min-width: 737px) {
  .card.floating {
    animation: fb-modal-in 0.18s ease-out both;
  }
  @keyframes fb-modal-in {
    from {
      opacity: 0;
      transform: translate(-50%, -50%) scale(0.96);
    }
    to {
      opacity: 1;
      transform: translate(-50%, -50%) scale(1);
    }
  }
}
@media (max-width: 736px) {
  .card.floating {
    animation: fb-sheet-in 0.2s ease-out both;
  }
  @keyframes fb-sheet-in {
    from {
      opacity: 0;
      transform: translateY(16px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}
/* fade only where #dropdown is an actual pop-up (mobile);
   on desktop it permanently holds the header action buttons */
@media (max-width: 736px) {
  #dropdown {
    opacity: 0;
    transition: transform 0.14s ease, opacity 0.14s ease;
  }
  #dropdown.active {
    opacity: 1;
  }
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--borderSecondary);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--blue);
  background-clip: content-box;
}

/* ============================================================
   PART 2 — further customization
   Extends the base theme above. Every selector below was
   verified against the deployed v2.63.18 compiled bundle.
   ============================================================ */

/* ---------- Extra palette: destructive reds ---------- */
:root {
  --red: #e5484d;
  --dark-red: #c73a3f;
}
:root.dark {
  --red: #f2565b;
  --dark-red: #e5484d;
}

/* ---------- (1a) Mosaic / gallery — photo-grid feel ---------- */
/* clip the thumbnail well so the image can zoom on hover */
#listing.mosaic .item div:first-of-type {
  border-radius: 10px;
  overflow: hidden;
}
#listing.mosaic .item img {
  border-radius: 10px;
  object-fit: cover;
  transition: transform 0.35s ease;
}
#listing.mosaic .item:hover img {
  transform: scale(1.06);
}
/* gallery mode overlays the filename on the image — add a legibility scrim */
#listing.mosaic.gallery .item[data-type="image"] div:last-of-type {
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.55),
    rgba(0, 0, 0, 0) 90%
  );
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* ---------- (1b) Folder-first distinction ---------- */
#listing .item[data-dir="true"] i {
  color: var(--blue);
}
#listing .item[data-dir="true"] .name {
  font-weight: 600;
}

/* ---------- (1c) Density — crisper, consistent list rows ---------- */
#listing.list .item {
  min-height: 3em;
}
#listing.list .item .name {
  line-height: 1.35;
}

/* ---------- (1d) Staggered entrance on navigation ---------- */
/* list rows rise (no hover-transform to clash with); mosaic tiles only
   fade, so their hover-lift keeps working after the animation settles */
@keyframes fb-item-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fb-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
#listing.list .item:not(.header) {
  animation: fb-item-in 0.26s ease-out both;
}
#listing.mosaic .item {
  animation: fb-fade-in 0.3s ease-out both;
}
#listing .item:nth-child(2) { animation-delay: 0.02s; }
#listing .item:nth-child(3) { animation-delay: 0.04s; }
#listing .item:nth-child(4) { animation-delay: 0.06s; }
#listing .item:nth-child(5) { animation-delay: 0.08s; }
#listing .item:nth-child(6) { animation-delay: 0.1s; }
#listing .item:nth-child(7) { animation-delay: 0.12s; }
#listing .item:nth-child(8) { animation-delay: 0.14s; }
#listing .item:nth-child(9) { animation-delay: 0.16s; }
#listing .item:nth-child(n + 10) { animation-delay: 0.18s; }

/* ---------- (1e) Sort-header polish (list view) ---------- */
#listing.list .item.header {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72em;
  font-weight: 600;
  color: var(--textPrimary);
  border-color: transparent;
  background: transparent;
}
/* the header is an .item too — neutralize the row hover-lift on it */
#listing.list .item.header:hover {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  transform: none;
}
#listing.list .header p:hover,
#listing.list .header p:hover i,
#listing.list .header .active,
#listing.list .header .active i {
  color: var(--blue);
}

/* ---------- (2a) Media preview framing ---------- */
#previewer .preview img {
  border-radius: 10px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
  /* checkerboard shows only through transparent pixels */
  background-image: linear-gradient(
      45deg,
      rgba(128, 128, 128, 0.22) 25%,
      transparent 25%,
      transparent 75%,
      rgba(128, 128, 128, 0.22) 75%
    ),
    linear-gradient(
      45deg,
      rgba(128, 128, 128, 0.22) 25%,
      transparent 25%,
      transparent 75%,
      rgba(128, 128, 128, 0.22) 75%
    );
  background-size: 22px 22px;
  background-position: 0 0, 11px 11px;
}
#previewer .preview video {
  border-radius: 10px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
}
#previewer .preview pre {
  background: #16171f;
  color: #e8e8f2;
  padding: 1.25em 1.5em;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 0.95em;
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, "SF Mono",
    Menlo, Consolas, monospace;
}

/* ---------- (2b) Ace editor — accent + comfortable type ---------- */
/* Ace's syntax theme is separate from the app theme; these tweaks are
   theme-agnostic so they read well under any --aceEditorTheme */
.ace_editor {
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, "SF Mono",
    Menlo, Consolas, monospace !important;
  line-height: 1.55 !important;
}
.ace_cursor {
  color: var(--blue) !important;
}
.ace_marker-layer .ace_selection {
  background: rgba(139, 92, 246, 0.28) !important;
}
.ace_gutter-active-line,
.ace_active-line {
  background: rgba(139, 92, 246, 0.1) !important;
}

/* ---------- (3a) Login hero ---------- */
/* #login is already position:fixed (full viewport) — do NOT override its
   position or the form's, or the stock centering collapses. */
#login {
  overflow: hidden;
}
/* keep stock position:fixed centering; z-index only, to sit above the mesh */
#login form {
  z-index: 1;
}
#login img {
  width: 4.5em;
  height: auto;
  margin-bottom: 0.4em;
  filter: drop-shadow(0 8px 20px rgba(124, 58, 237, 0.4));
  animation: fb-float 6s ease-in-out infinite;
}
@keyframes fb-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}
#login h1 {
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* ---------- (3b) Header logo ---------- */
/* stock is 2.5em; the header is 4em tall with .5em vertical padding, so the
   content box is 3em — 2.9em scales the mark up while keeping it off the edges */
header img {
  height: 2.9em;
}

/* ---------- (3c) Empty-state accent well ---------- */
.message i {
  background: radial-gradient(
    circle,
    rgba(124, 58, 237, 0.12),
    transparent 70%
  );
  border-radius: 50%;
  padding: 0.3em;
}

/* ---------- (3d) Login notices — match the themed warning language ---------- */
/* stock #login .logout-message / .wrong are flat, square-cornered blocks; round
   them and switch to the gradient fills used by the warning/error toasts so the
   only banners on the login card stop reading as default UI */
#login .logout-message,
#login .wrong {
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  margin-bottom: 0.25em;
}
#login .logout-message {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}
#login .wrong {
  background: linear-gradient(135deg, var(--red), var(--dark-red));
}

/* ---------- (4a) Destructive actions → solid red ---------- */
/* FB's delete/confirm buttons are the FLAT red variant (transparent bg,
   red text). Fill BOTH variants: the confirm is the app's most dangerous
   click and must read as a bold red button, not just red text. The
   .button--flat.button--red selector (0,2,0) is needed to beat stock's
   `color: var(--dark-red)`. */
.button--red,
.button--flat.button--red {
  background: linear-gradient(135deg, var(--red), var(--dark-red));
  color: #fff;
  box-shadow: 0 2px 8px rgba(229, 72, 77, 0.35);
}
.button--red:hover,
.button--flat.button--red:hover {
  background: linear-gradient(135deg, var(--red), var(--dark-red));
  color: #fff;
  box-shadow: 0 4px 14px rgba(229, 72, 77, 0.45);
  transform: translateY(-1px);
}

/* ---------- (4a-2) Flat primary (blue) buttons — white text ---------- */
/* SHARE / New folder / Rename etc. are .button--flat.button--blue: my
   .button--blue gradient fills them violet, but stock .button--flat keeps
   the text at var(--dark-blue) → violet-on-violet. Force white text and
   hold the fill on hover (else .button--flat:hover turns it grey). */
.button--flat.button--blue {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--dark-blue));
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}
.button--flat.button--blue:hover {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--dark-blue));
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.45);
  transform: translateY(-1px);
}

/* ---------- (4b) Selection-mode bar ---------- */
#listing #multiple-selection {
  border-radius: 12px;
}
#listing #multiple-selection.active {
  background: linear-gradient(135deg, var(--blue), var(--dark-blue));
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35);
}
#listing #multiple-selection.active p,
#listing #multiple-selection.active i {
  color: #fff;
}

/* ---------- (4c) Overlay + upload progress polish ---------- */
.overlay {
  background: rgba(14, 15, 20, 0.5);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.file-progress {
  border-radius: 999px;
  overflow: hidden;
}

/* ---------- (4d) Toasts (Vue-Toastification) ---------- */
.Vue-Toastification__toast {
  border-radius: 12px !important;
  font-family: "Sora", "Segoe UI Variable", system-ui, sans-serif !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
}
.Vue-Toastification__toast--success {
  background: linear-gradient(135deg, #2fa66f, #22855a) !important;
}
.Vue-Toastification__toast--error {
  background: linear-gradient(135deg, var(--red), var(--dark-red)) !important;
}
.Vue-Toastification__toast--info {
  background: linear-gradient(135deg, var(--blue), var(--dark-blue)) !important;
}
.Vue-Toastification__toast--warning {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
}

/* ---------- (4e) Header action bar — inline, not floating ---------- */
/* On desktop #dropdown is NOT a pop-up: it holds the header action buttons
   inline (it only becomes a pop-up under 737px). The base theme's card
   treatment — surface fill, border and a 32px drop shadow — made it read as
   a panel hovering over the header, so flatten it here. The pop-up styling
   is left untouched for mobile, where the card look is correct. */
@media (min-width: 737px) {
  #dropdown {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
  }
  /* container is flat now, so the buttons carry the hover affordance */
  #dropdown .action:hover {
    background: var(--hover);
  }
}

/* ---------- (5a) Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- (5b) Firefox scrollbars ---------- */
html {
  scrollbar-color: var(--borderSecondary) transparent;
  scrollbar-width: thin;
}

/* ---------- (5c) Smooth theme switch (large surfaces only) ---------- */
/* deliberately excludes items/buttons/inputs so their fast hover
   transitions stay snappy */
body,
header,
nav:not(#nav),
main,
.card,
.share__box,
#login,
#dropdown {
  transition: background-color 0.35s ease, border-color 0.35s ease,
    color 0.35s ease;
}

/* ---------- (5d) Mobile — larger tap targets, prominent primary ---------- */
@media (max-width: 736px) {
  .button--blue {
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
  }
  #listing.list .item {
    min-height: 3.4em;
  }
}

/* ============================================================
   LUCIDE ICONS (global)
   FileBrowser renders every icon — toolbar, file types, dialogs —
   through one "Material Icons" ligature face, so overriding that
   face swaps the entire set at once. This font carries Lucide
   glyphs published under Material's ligature names: 142 mapped,
   including all 53 the bundle references, each verified to resolve
   to exactly one glyph.

   A Material name NOT in the font degrades safely: its component
   letters are zero-width empty glyphs, so it renders as a blank
   spot, never as stray text. To add one, drop the Lucide SVG into
   the build keyed by the Material name and rebuild the font.

   Revert = delete this block + img/fonts/lucide-material.*
   ============================================================ */
@font-face {
  font-family: "Material Icons";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("/static/img/fonts/lucide-material.woff2") format("woff2"),
    url("/static/img/fonts/lucide-material.woff") format("woff");
}
