/* OSI FileServer usability layer for File Browser.
   Keep this CSS-only so File Browser can be updated safely. */

:root {
  --osi-sidebar-width: 17.5rem;
  --osi-header-height: 4rem;
  --osi-radius: 18px;
  --osi-accent: #2563eb;
  --osi-accent-soft: rgba(37, 99, 235, 0.1);
  --osi-border: rgba(15, 23, 42, 0.12);
  --osi-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

html.light {
  --background: #f4f7fb;
  --surfacePrimary: #ffffff;
  --surfaceSecondary: #eef3fa;
  --divider: var(--osi-border);
  --primaryColor: var(--osi-accent);
}

html.dark {
  --background: #0f172a;
  --surfacePrimary: #162033;
  --surfaceSecondary: #1e293b;
  --divider: rgba(148, 163, 184, 0.18);
  --primaryColor: #60a5fa;
  --osi-accent-soft: rgba(96, 165, 250, 0.16);
  --osi-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

body {
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.1), transparent 28rem),
    var(--background);
}

header {
  border-bottom: 1px solid var(--divider);
  box-shadow: none;
}

header img {
  border-radius: 12px;
}

header title {
  font-weight: 800;
  letter-spacing: -0.03em;
}

main {
  margin-left: var(--osi-sidebar-width);
}

nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: var(--osi-sidebar-width);
  height: calc(100vh - var(--osi-header-height));
  padding: 1rem 0.75rem;
  background: linear-gradient(180deg, var(--surfacePrimary), rgba(255, 255, 255, 0.92));
  border-right: 1px solid var(--divider);
  box-shadow: var(--osi-shadow);
}

html.dark nav {
  background: linear-gradient(180deg, var(--surfacePrimary), rgba(22, 32, 51, 0.92));
}

nav > div {
  border-top: 0;
}

nav .action {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.65rem;
  padding: 0.65rem 0.8rem;
  border-radius: 14px;
  color: inherit;
  font-size: 0.98rem;
}

nav .action:hover,
nav .action[aria-current="page"],
nav .action.router-link-active {
  background: var(--osi-accent-soft);
  color: var(--primaryColor);
}

nav .action i {
  color: currentColor;
}

nav .action span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumbs {
  z-index: 40;
  top: var(--osi-header-height);
  height: auto;
  min-height: 3.35rem;
  padding: 0.65rem 1.1rem;
  background: rgba(244, 247, 251, 0.82);
  border-bottom: 0;
  backdrop-filter: blur(14px);
}

html.dark .breadcrumbs {
  background: rgba(15, 23, 42, 0.78);
}

.breadcrumbs span,
.breadcrumbs a {
  border-radius: 999px;
}

#listing {
  margin: 1rem;
  border: 1px solid var(--divider);
  border-radius: 22px;
  overflow: hidden;
  background: var(--surfacePrimary);
  box-shadow: var(--osi-shadow);
}

#listing.list .item {
  border-bottom: 1px solid var(--divider);
}

#listing.list .item:hover,
#listing.mosaic .item:hover {
  background: var(--osi-accent-soft);
}

/* Keep normal navigation at the top. */
nav > button:nth-of-type(2) {
  order: 10;
}

/* Put "new folder" and "new file" where users expect them: inside the file area header. */
body:has(#listing) nav > div:first-of-type {
  position: fixed;
  z-index: 80;
  top: calc(var(--osi-header-height) + 0.55rem);
  right: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem;
  background: var(--surfacePrimary);
  border: 1px solid var(--divider);
  border-radius: 999px;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.12);
}

body:has(#listing) nav > div:first-of-type .action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: auto;
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0 0.75rem;
  border-radius: 999px;
  color: var(--primaryColor);
}

body:has(#listing) nav > div:first-of-type .action span {
  display: inline;
  font-size: 0.88rem;
  font-weight: 700;
}

body:has(#listing) nav > div:first-of-type .action:hover {
  background: var(--osi-accent-soft);
}

/* Profile area: bottom-left anchor with settings/logout as a compact dropdown. */
nav > button:first-of-type {
  order: 90;
  margin-top: auto;
  background: linear-gradient(135deg, var(--osi-accent-soft), transparent);
  border: 1px solid var(--divider);
  font-weight: 800;
}

nav > button:first-of-type::after {
  margin-left: auto;
  font-family: "Material Icons";
  font-size: 1.25rem;
  content: "expand_less";
}

nav > div:nth-of-type(2),
nav > #logout {
  order: 91;
  max-height: 0;
  margin: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(0.35rem);
  transition: max-height 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}

nav:focus-within > div:nth-of-type(2),
nav:hover > div:nth-of-type(2),
nav:focus-within > #logout,
nav:hover > #logout {
  max-height: 3.2rem;
  opacity: 1;
  transform: translateY(0);
}

nav > div:nth-of-type(2) .action,
nav > #logout {
  background: var(--surfaceSecondary);
  border-radius: 12px;
}

nav > .credits {
  order: 100;
  margin: 0.4rem 0 0 0 !important;
  color: currentColor;
  opacity: 0.52;
  font-size: 0.75rem;
}

nav > div.credits {
  display: none;
}

/* Mobile and narrow windows should keep the original compact header behaviour. */
@media (max-width: 736px) {
  :root {
    --osi-sidebar-width: 0px;
  }

  main {
    margin-left: 0;
  }

  nav {
    width: 16em;
    padding: 0.5rem;
  }

  body:has(#listing) nav > div:first-of-type {
    position: static;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  body:has(#listing) nav > div:first-of-type .action span {
    display: none;
  }

  #listing {
    margin: 0.5rem;
    border-radius: 16px;
  }
}
