/* LightDrive Nextcloud-style logged-in header for WordPress public pages */

body.ld-nc-logged-in {
  color-scheme: light;
}

/* Logged-in WP faux app header background */
body.ld-nc-logged-in::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  z-index: 2147483643;
  background: #ffffff;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  pointer-events: none;
}

body.admin-bar.ld-nc-logged-in::before {
  top: 32px;
}

/* Logged-in state: make the original Blocksy header row blend into the WP page background */
body.ld-nc-logged-in .ct-header,
body.ld-nc-logged-in .ct-header [data-row],
body.ld-nc-logged-in .ct-header [data-row="middle"],
body.ld-nc-logged-in .ct-header .ct-container,
body.ld-nc-logged-in .ct-header [data-column],
body.ld-nc-logged-in .ct-header [data-items] {
  background-color: #f4f7f6 !important;
  background-image: none !important;
  box-shadow: none !important;
}



/* Body-level Nextcloud-style app menu portal */
#ld-nc-appbar-portal.ld-nc-appbar-portal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 2147483644 !important;
  height: 56px !important;
  min-height: 56px !important;
  display: flex !important;
  align-items: center !important;
  padding-left: 27px !important;
  background: transparent !important;
  pointer-events: auto !important;
}

body.admin-bar #ld-nc-appbar-portal.ld-nc-appbar-portal {
  top: 32px !important;
}

/* App menu row */
.ld-nc-appbar {
  --ld-app-menu-entry-font-size: 12px;

  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  height: 56px;
  min-height: 56px;
  gap: 0;
  margin: 0;
  overflow: visible;
}

/* Logo */
.ld-nc-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 56px;
  margin: 0 25px 0 0;
  padding: 0;
  color: #000;
  text-decoration: none;
  white-space: nowrap;
  overflow: visible;
}

.ld-nc-logo-link:hover,
.ld-nc-logo-link:focus-visible {
  background: transparent;
  color: #000;
}
#ld-nc-appbar-portal .ld-nc-logo-link {
  width: 50px;
  height: 56px;
  margin: 0 25px 0 0 !important;
}
.ld-nc-logo-image {
  display: block;
  width: 45px;
  height: 45px;
  object-fit: contain;
}

/* App links */
.ld-nc-app-link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 56px;
  margin: 0 2px;
  padding: 0;
  color: #000;
  text-decoration: none;
  white-space: nowrap;
  overflow: visible;
  cursor: pointer;
}

.ld-nc-app-link:hover,
.ld-nc-app-link:focus-visible {
  background: transparent;
  color: #000;
}

.ld-nc-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ld-nc-icon svg {
  display: block;
  fill: currentColor;
}

.ld-nc-app-link .ld-nc-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  color: #000;
  transform: translateY(3px);
  transition: transform 160ms ease;
}

.ld-nc-app-link .ld-nc-icon svg {
  width: 20px;
  height: 20px;
}

.ld-nc-app-link > span:last-child {
  display: block;
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translateX(-50%) translateY(-3px);
  color: #000;
  font-size: var(--ld-app-menu-entry-font-size);
  line-height: 1;
  font-weight: 400;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    visibility 160ms ease,
    transform 160ms ease;
}

/* Hovering the app row reveals all labels and shifts icons up */
.ld-nc-appbar:hover .ld-nc-app-link .ld-nc-icon,
.ld-nc-appbar:focus-within .ld-nc-app-link .ld-nc-icon {
  transform: translateY(-5px);
}

.ld-nc-appbar:hover .ld-nc-app-link > span:last-child,
.ld-nc-appbar:focus-within .ld-nc-app-link > span:last-child {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Stronger label for the specific hovered/focused app */
.ld-nc-app-link:hover > span:last-child,
.ld-nc-app-link:focus-visible > span:last-child {
  font-weight: 700;
}

/* Body-level logged-in avatar button */
#ld-nc-avatar-portal-button.ld-nc-avatar-button {
  position: fixed !important;
  top: 10px !important;
  right: 18px !important;
  z-index: 2147483646 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 36px !important;
  height: 36px !important;
  border: 1px solid rgba(15, 23, 42, 0.12) !important;
  border-radius: 999px !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: #eee9ff !important;
  color: #7b5ed7 !important;
  font-size: 16px !important;
  font-weight: 500 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  pointer-events: auto !important;
}

#ld-nc-avatar-portal-button img {
  display: block !important;
  width: 36px !important;
  height: 36px !important;
  object-fit: cover !important;
}

body.admin-bar #ld-nc-avatar-portal-button.ld-nc-avatar-button {
  top: 42px !important;
}

/* Body-level avatar menu portal */
#ld-nc-user-portal-panel.ld-nc-user-portal-panel {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: fixed !important;
  top: 56px !important;
  right: 8px !important;
  z-index: 2147483647 !important;

  width: 286px;
  max-width: calc(100vw - 32px);
  min-height: auto;
  padding: 16px 10px 14px;

  background: #ffffff;
  color: #222;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;

  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.12),
    0 10px 24px rgba(0, 0, 0, 0.16);

  text-align: left;
  pointer-events: auto;
  overflow: visible !important;
  box-sizing: border-box;

  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.3;
}

body.admin-bar #ld-nc-user-portal-panel.ld-nc-user-portal-panel {
  top: 88px !important;
}

/* Small pointer triangle above the avatar menu */
#ld-nc-user-portal-panel.ld-nc-user-portal-panel::before {
  content: "";
  position: absolute;
  top: -7px;
  right: 22px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  border-left: 1px solid rgba(15, 23, 42, 0.08);
  transform: rotate(45deg);
  z-index: -1;
}

/* Avatar menu account line */
#ld-nc-user-portal-panel .ld-nc-user-head {
  display: block;
  padding: 3px 10px 13px;
  margin: 0;
  border-bottom: none;
}

#ld-nc-user-portal-panel .ld-nc-user-name {
  color: #222;
  font-size: 14.5px;
  line-height: 1.35;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Avatar menu links */
#ld-nc-user-portal-panel .ld-nc-menu-link {
  display: flex;
  align-items: center;
  gap: 17px;

  min-height: 37px;
  padding: 0 10px;

  color: #222;
  text-decoration: none;
  border-radius: 0;

  font-size: 15px;
  line-height: 37px;
  font-weight: 600;

  white-space: nowrap;
  box-sizing: border-box;
}

#ld-nc-user-portal-panel .ld-nc-menu-link:hover,
#ld-nc-user-portal-panel .ld-nc-menu-link:focus-visible {
  background: #f2f2f2;
  color: #111;
  border-radius: 8px;
}

#ld-nc-user-portal-panel .ld-nc-menu-link .ld-nc-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #111;
}

#ld-nc-user-portal-panel .ld-nc-menu-link .ld-nc-icon svg {
  width: 17px;
  height: 17px;
  display: block;
  fill: currentColor;
}

#ld-nc-user-portal-panel .ld-nc-logout {
  margin-top: 4px;
  border-top: none;
  border-radius: 0;
}

/* Mobile */
@media (max-width: 760px) {
  .ld-nc-logo-link {
    margin-right: 8px;
  }

  .ld-nc-app-link {
    width: 40px;
    margin: 0;
  }

  .ld-nc-appbar .ld-nc-app-link > span:last-child {
    display: none;
  }

  #ld-nc-avatar-portal-button.ld-nc-avatar-button {
    right: 18px !important;
  }

  #ld-nc-user-portal-panel.ld-nc-user-portal-panel {
    right: 8px !important;
    width: calc(100vw - 16px);
    max-width: 286px;
  }

  #ld-nc-user-portal-panel.ld-nc-user-portal-panel::before {
    right: 22px;
  }
}

@media (max-width: 480px) {
  .ld-nc-logo-link {
    width: 46px;
    margin-right: 4px;
  }

  .ld-nc-logo-image {
    width: 42px;
    height: 42px;
  }

  .ld-nc-app-link {
    width: 34px;
  }

  .ld-nc-app-link .ld-nc-icon svg {
    width: 18px;
    height: 18px;
  }
}
