/* Custom TurnSheet icon button on actor sheet headers */
.window-header .bw-import-turnsheet {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.window-header .bw-import-turnsheet .bw-ts-icon {
  width: 1em;
  height: 1em;
  display: block;
  object-fit: contain;
  border: none;
  background: none;
  vertical-align: middle;
}

/* Brand logos in context menus, rendered as an <i> so they inherit the menu's
   icon-column metrics and line up with the FontAwesome rows.

   PATHS ARE RELATIVE TO THIS STYLESHEET, not to the page. This file ships inside the
   feature at module/importer/styles/, and the badges sit at module/importer/assets/,
   so "../assets/<name>.svg" is correct. It also survives a Foundry routePrefix, which
   a leading "/" would not. (An earlier version used "modules/<id>/assets/..." here,
   which resolved to .../styles/modules/<id>/assets/... and 404'd silently.) */
.bw-mp-ctx-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  background-image: url("../assets/madprops.svg");
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  vertical-align: middle;
}
.bw-bg-ctx-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  background-image: url("../assets/batlgrid.svg");
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  vertical-align: middle;
}
.bw-ts-ctx-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  background-image: url("../assets/turnsheet.svg");
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  vertical-align: middle;
}

/* Floating bag button — shown only on the viewed scene when it has a bag */
#bw-scene-props-btn {
  position: fixed;
  top: 90px;            /* near the top, aligned with the sidebar */
  right: 396px;         /* just left of the right sidebar, over the canvas */
  z-index: 70;          /* over the canvas, under app windows/dialogs */
  width: 40px;
  height: 40px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  opacity: 0.65;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
#bw-scene-props-btn:hover {
  opacity: 1;
  transform: scale(1.06);
}
#bw-scene-props-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* GM toggle pip on the floating bag button — enables player access to the scene's bag */
.bw-bag-access-toggle {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #bbb;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.bw-bag-access-toggle.on {
  background: #2e7d32;
  border-color: #66bb6a;
  color: #fff;
}
.bw-bag-access-toggle:hover { transform: scale(1.15); }

/* ------------------------------------------------------------------ */
/*  Baileywiki.com library browser                                     */
/* ------------------------------------------------------------------ */
/* Selectors target the .bw-library CLASS, not an id: each source opens its
   own window (bw-library-turnsheet, bw-library-batlgrid, …) so an id
   selector would match none of them. */
.application.bw-library .window-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bw-library .bw-lib-root {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  height: 100%;
  min-height: 0;
}
.bw-library .bw-lib-bar {
  display: flex;
  gap: 0.5em;
  align-items: center;
  flex: 0 0 auto;
}
.bw-library .bw-lib-bar input[type="search"] { flex: 1; }
.bw-library .bw-lib-notice {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.35em 0.5em;
  font-size: var(--font-size-11, 0.7rem);
  border-left: 3px solid var(--color-shadow-primary, #ff6400);
  background: rgba(0, 0, 0, 0.08);
  opacity: 0.9;
}
.bw-library .bw-lib-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25em;
  flex: 0 0 auto;
}
.bw-library .bw-lib-chip {
  padding: 0.1em 0.6em;
  font-size: var(--font-size-11, 0.7rem);
  border: 1px solid var(--color-border-light-tertiary, #7a7971);
  border-radius: 999px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.06);
  white-space: nowrap;
}
.bw-library .bw-lib-chip:hover { border-color: var(--color-shadow-primary, #ff6400); }
.bw-library .bw-lib-chip.on {
  background: var(--color-shadow-primary, #ff6400);
  border-color: var(--color-shadow-primary, #ff6400);
  color: #fff;
}
/* The scroll container. flex:1 + min-height:0 is what actually lets it
   scroll inside a flex column — max-height alone does not. */
.bw-library .bw-lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  grid-auto-rows: min-content;
  align-content: start;
  gap: 0.6em;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.15em;
}
.bw-library .bw-lib-card {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  padding: 0.35em;
  text-align: center;
  cursor: pointer;
  border: 1px solid var(--color-border-light-tertiary, #7a7971);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.06);
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.bw-library .bw-lib-card:hover {
  border-color: var(--color-shadow-primary, #ff6400);
  transform: translateY(-2px);
}
.bw-library .bw-lib-card[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}
.bw-library .bw-lib-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border: 0;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.18);
}
.bw-library .bw-lib-name {
  font-size: var(--font-size-12, 0.75rem);
  line-height: 1.15;
  word-break: break-word;
}
.bw-library .bw-lib-meta {
  font-size: var(--font-size-10, 0.65rem);
  opacity: 0.7;
  margin: 0;
}
.bw-library .bw-lib-more {
  grid-column: 1 / -1;
  padding: 0.4em;
  text-align: center;
  opacity: 0.8;
  font-size: var(--font-size-12, 0.75rem);
}
.bw-library .bw-lib-status {
  flex: 0 0 auto;
  min-height: 1.4em;
  font-size: var(--font-size-12, 0.75rem);
}
.bw-library .bw-lib-empty {
  grid-column: 1 / -1;
  padding: 2em 1em;
  text-align: center;
  opacity: 0.8;
}
.bw-library .bw-lib-error { color: var(--color-level-error, #c93b3b); }
.bw-library progress { width: 100%; }

/* ---- drill-in: a map's individual tiles / props ---- */
/* Cards need to be a positioning context so the checkbox, the new/updated badge
   and the drill-in chevron can sit in their corners. */
.bw-library .bw-lib-card { position: relative; }

/* Chevron on a map card that opens its tile list. */
.bw-library .bw-lib-drill {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 1;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #eee;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.bw-library .bw-lib-card:hover .bw-lib-drill,
.bw-library .bw-lib-card.in-scene .bw-lib-drill { opacity: 1; }
.bw-library .bw-lib-drill:hover { background: var(--color-shadow-primary, #ff6400); }

/* A map that is already imported into the target scene. */
.bw-library .bw-lib-card.in-scene { border-color: #4d8a52; }
.bw-library .bw-lib-here {
  font-size: var(--font-size-10, 0.65rem);
  color: #7bbf80;
  text-transform: lowercase;
}

/* Multi-select asset cards. */
.bw-library .bw-lib-asset { padding-top: 1.4em; }
.bw-library .bw-lib-asset.picked {
  border-color: var(--color-shadow-primary, #ff6400);
  background: rgba(255, 100, 0, 0.12);
}
.bw-library .bw-lib-check {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 12px;
  opacity: 0.85;
  pointer-events: none;
}
.bw-library .bw-lib-asset.picked .bw-lib-check {
  color: var(--color-shadow-primary, #ff6400);
  opacity: 1;
}
.bw-library .bw-lib-state {
  position: absolute;
  top: 3px;
  right: 4px;
  padding: 0 0.4em;
  font-size: var(--font-size-10, 0.65rem);
  line-height: 1.5;
  border-radius: 999px;
  color: #fff;
  pointer-events: none;
}
.bw-library .bw-lib-state.new { background: #2e7d32; }
.bw-library .bw-lib-state.changed { background: #b26a00; }

/* Footer action row + the inline "import the whole thing" escape hatch. */
.bw-library .bw-lib-actions {
  display: flex;
  justify-content: flex-end;
}
.bw-library .bw-lib-primary { flex: 0 0 auto; }
.bw-library .bw-lib-inline-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  width: auto;
  margin-inline-start: 0.5em;
  padding: 0 0.6em;
  font-size: var(--font-size-11, 0.7rem);
  line-height: 1.6;
}

/* ------------------------------------------------------------------ */
/*  Import-source chooser dialog                                        */
/* ------------------------------------------------------------------ */
/* A fixed TWO-COLUMN grid, not wrapping flex. Flex sized each button to its own
   label, so rows never lined up and the odd button out stretched full width.
   With five buttons the grid falls out exactly as intended:
     row 1  My BatlGrid Maps    | BatlGrid Gallery
     row 2  MadProps Scenescapes| MadProps Gallery
     row 3  ZIP file…           (left column, no stretch)
   Order comes from the button array in library/index.mjs — keep them in step. */
#bw-source-dialog .form-footer,
#bw-source-dialog .dialog-buttons,
.application.bw-source-dialog .form-footer,
.application.bw-source-dialog .dialog-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4em;
  align-items: stretch;
}
#bw-source-dialog .form-footer > button,
#bw-source-dialog .dialog-buttons > button,
.application.bw-source-dialog .form-footer > button,
.application.bw-source-dialog .dialog-buttons > button {
  width: 100%;
  min-width: 0;          /* let long labels shrink rather than blow out the grid */
  margin: 0;             /* Foundry's default button margin breaks grid alignment */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#bw-source-dialog .window-content > p,
.application.bw-source-dialog .window-content > p {
  margin-block-end: 0.75em;
}

/* Brand badges in place of FontAwesome glyphs.
   The .bw-*-ctx-icon classes are sized 1em for a context menu's icon column; a
   dialog button and a window header both want a slightly larger, rounded badge,
   and the button needs the icon pinned so a long label can't squash it. */
#bw-source-dialog .form-footer > button > i[class*="-ctx-icon"],
#bw-source-dialog .dialog-buttons > button > i[class*="-ctx-icon"],
.application.bw-source-dialog .form-footer > button > i[class*="-ctx-icon"],
.application.bw-source-dialog .dialog-buttons > button > i[class*="-ctx-icon"] {
  width: 1.4em;
  height: 1.4em;
  flex: 0 0 auto;
  border-radius: 4px;
  margin-inline-end: 0.15em;
  vertical-align: -0.35em;
}
.application.bw-library .window-header > i[class*="-ctx-icon"] {
  width: 1.2em;
  height: 1.2em;
  flex: 0 0 auto;
  border-radius: 3px;
}

/* "Create more at BatlGrid / MadProps" row under the chooser's body text. */
.bw-product-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5em;
  margin: 0 0 0.75em;
  font-size: var(--font-size-12, 0.75rem);
  opacity: 0.85;
}
.bw-product-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.15em 0.55em;
  border: 1px solid var(--color-border-light-tertiary, #7a7971);
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
}
.bw-product-link:hover {
  border-color: var(--color-shadow-primary, #ff6400);
  text-shadow: none;
}
.bw-product-link > i[class*="-ctx-icon"] {
  width: 1.1em;
  height: 1.1em;
  border-radius: 3px;
  flex: 0 0 auto;
}
.bw-product-link .bw-ext {
  font-size: 0.75em;
  opacity: 0.6;
}

/* Product shortcut in the library window's toolbar. */
.bw-library .bw-lib-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1.9em;
  height: 1.9em;
  border: 1px solid var(--color-border-light-tertiary, #7a7971);
  border-radius: 4px;
  text-decoration: none;
}
.bw-library .bw-lib-home:hover { border-color: var(--color-shadow-primary, #ff6400); }
.bw-library .bw-lib-home > i[class*="-ctx-icon"] {
  width: 1.2em;
  height: 1.2em;
  border-radius: 3px;
}
