/* SPDX-FileCopyrightText: 2026 Entelai
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Albums: tab handle + drawer. See spec § 4.
 */

/* Hide OE2's default eye-icon link in the viewer column so it never flashes
 * before entelai-albums.js swaps the cell into its role-specific content
 * (checkbox for doctor/admin, empty for patient). The JS replaces the cell's
 * children entirely, so our checkbox span lives as a *sibling* of .div-icon
 * — this rule only suppresses the OE2 wrapper, not our replacement. */
.study-table > tbody > tr > td.td-viewer-icon > .div-icon {
  display: none !important;
}

:root {
  --entelai-albums-z-tab:      2147483600;
  --entelai-albums-z-backdrop: 2147483601;
  --entelai-albums-z-drawer:   2147483602;
  --entelai-albums-bg:         var(--ao-dark-2, #1A232F);
  --entelai-albums-bg-2:       #111827;
  --entelai-albums-fg:         #FFFFFF;
  --entelai-albums-accent:     var(--ao-accent, #0DE4C4);
  --entelai-albums-w:          380px;
}

#entelai-albums-tab {
  position: fixed;
  top: 50%; left: 0;
  transform: translateY(-50%);
  width: 28px; height: 80px;
  display: flex; align-items: center; justify-content: center;
  background: var(--entelai-albums-bg);
  color: var(--entelai-albums-fg);
  border: 1px solid var(--entelai-albums-bg-2);
  border-left: none;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  z-index: var(--entelai-albums-z-tab);
  user-select: none;
  font-size: 14px;
  padding: 0;
}
#entelai-albums-tab[data-active="true"] {
  background: var(--entelai-albums-accent);
  color: #0f172a;
}
#entelai-albums-tab:focus-visible {
  outline: 2px solid var(--entelai-albums-accent);
  outline-offset: 2px;
}

#entelai-albums-drawer {
  position: fixed; top: 0; left: 0;
  width: var(--entelai-albums-w); height: 100vh;
  background: var(--entelai-albums-bg);
  color: var(--entelai-albums-fg);
  transform: translateX(-100%);
  transition: transform 200ms ease-out;
  z-index: var(--entelai-albums-z-drawer);
  display: flex; flex-direction: column;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.25);
  font-family: 'Manrope', Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#entelai-albums-drawer[data-open="true"] {
  transform: translateX(0);
}

.entelai-albums-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--entelai-albums-bg-2);
}
#entelai-albums-title {
  font-size: 18px;
  font-weight: 700;
  color: #FFFFFF;
}
.entelai-albums-header button {
  background: transparent;
  color: #E5E7EB;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
}
.entelai-albums-header button:hover {
  background: var(--entelai-albums-bg-2);
  border-radius: 4px;
}

.entelai-albums-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.entelai-albums-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  position: relative;
  transition: background 100ms ease-out;
}
.entelai-albums-row:hover { background: var(--entelai-albums-bg-2); }
.entelai-albums-row:focus-visible {
  outline: 2px solid var(--entelai-albums-accent);
  outline-offset: -2px;
  background: var(--entelai-albums-bg-2);
}
.entelai-albums-hint {
  padding: 12px 16px;
  font-size: 14px;
  color: #FFFFFF;
}

.entelai-albums-row[data-active="true"] {
  background: rgba(13, 228, 196, 0.2);
  color: #fff;
  font-weight: 700;
}
.entelai-albums-row[data-active="true"]::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--entelai-albums-accent);
}
.entelai-albums-row[data-drop-target="true"] {
  outline: 2px dashed var(--entelai-albums-accent);
  outline-offset: -4px;
}
.entelai-albums-row[data-not-target="true"] {
  opacity: 0.5;
}

.entelai-albums-section {
  padding: 12px 16px 4px;
  font-size: 12px;
  line-height: 1.3;
  text-transform: uppercase;
  color: #FFFFFF;
}

.entelai-albums-footer {
  display: flex; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--ao-dark-1, #030D19);
}
.entelai-albums-footer button {
  flex: 1;
  padding: 9px 13px;
  background: transparent;
  color: var(--entelai-albums-accent);
  border: 1px solid var(--entelai-albums-accent);
  border-radius: 80px;
  cursor: pointer;
  font: inherit;
  font-size: 16px;
  line-height: normal;
  text-transform: uppercase;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.entelai-albums-footer button:hover {
  background: var(--entelai-albums-accent);
  color: var(--ao-dark-1, #030D19);
  box-shadow: 0 0 8px 0 var(--entelai-albums-accent);
}

.entelai-albums-form,
.entelai-albums-confirm {
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.entelai-albums-form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px;
}
.entelai-albums-form input,
.entelai-albums-form select,
.entelai-albums-form textarea {
  background: var(--entelai-albums-bg-2);
  color: var(--entelai-albums-fg);
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
}
.entelai-albums-form-actions {
  display: flex; gap: 8px;
  justify-content: flex-end;
}
.entelai-albums-form-actions button {
  background: transparent;
  color: var(--entelai-albums-fg);
  border: 1px solid var(--entelai-albums-bg-2);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
}
.entelai-albums-form-actions button[type="submit"],
.entelai-albums-form-actions button[data-action="confirm"] {
  background: var(--entelai-albums-accent);
  border-color: var(--entelai-albums-accent);
  color: #0f172a;
}
.entelai-albums-confirm-help {
  color: #94a3b8;
  font-size: 12px;
}
.entelai-albums-row-label { flex: 1; }
.entelai-albums-row-actions {
  display: flex; gap: 4px;
  opacity: 0;
  transition: opacity 120ms;
}
.entelai-albums-row:hover .entelai-albums-row-actions { opacity: 1; }
.entelai-albums-row-actions button {
  background: transparent;
  color: var(--entelai-albums-fg);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  width: 24px; height: 24px;
  padding: 0;
  font: inherit;
}
.entelai-albums-row-actions button:hover {
  background: rgba(255, 255, 255, 0.06);
}

.entelai-albums-rules {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.entelai-albums-rule {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.entelai-albums-rule select,
.entelai-albums-rule input {
  flex: 0 1 auto; min-width: 0;
}
.entelai-albums-rule input[type="text"],
.entelai-albums-rule .entelai-albums-rule-range {
  flex: 1 1 120px;
  display: inline-flex; gap: 4px; align-items: center;
}
/* reportStatus value control. The single-select reuses the generic
 * `.entelai-albums-rule select` styling; the in/notIn checkbox group wraps
 * onto its own full-width line so the 5 statuses stay readable. */
.entelai-albums-status-group {
  flex: 1 1 100%;
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
}
.entelai-albums-status-check {
  display: inline-flex; gap: 4px; align-items: center;
  font-size: 12px; color: var(--entelai-albums-fg);
  white-space: nowrap; cursor: pointer;
}
.entelai-albums-status-check input { flex: 0 0 auto; }
.entelai-albums-rule button[aria-label="Quitar regla"] {
  background: transparent;
  color: var(--entelai-albums-fg);
  border: 1px solid var(--entelai-albums-bg-2);
  border-radius: 4px;
  width: 24px; height: 24px;
  padding: 0;
  cursor: pointer;
}
.entelai-albums-count-line {
  font-size: 12px;
  color: #94a3b8;
}
.entelai-albums-count-value {
  color: var(--entelai-albums-fg);
  font-weight: 600;
}

/* Hide rows that aren't in the active album. ActivationFilter sets/clears
 * the attribute. Use !important to outrank any inline display styling
 * Vue might apply during reactive re-render. */
.study-table > tbody > tr[data-album-hidden="true"] {
  display: none !important;
}

.entelai-albums-row-checkbox {
  display: none !important;
}

#entelai-selection-bar {
  display: none;
  width: 95%;
  margin: 0 auto 12px;
  align-items: center;
  gap: 24px;
  padding: 8px 12px;
  border-radius: 50px;
  background: #1A232F;
  color: #E2E8F0;
  font-family: 'Manrope', 'Inter', sans-serif;
  font-size: 14px;
  box-sizing: border-box;
}
#entelai-selection-bar[data-visible="true"] { display: flex; }
#entelai-selection-bar .esb-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
#entelai-selection-bar .esb-close {
  background: none;
  border: none;
  padding: 0;
  color: #FFFFFF;
  font-size: 22px;
  line-height: 22px;
  cursor: pointer;
}
#entelai-selection-bar .esb-more {
  background: none;
  border: none;
  padding: 0;
  color: #FFFFFF;
  cursor: pointer;
  display: inline-flex;
}
#entelai-selection-bar .esb-more svg { width: 20px; height: 20px; }
#entelai-selection-bar .esb-close:hover,
#entelai-selection-bar .esb-more:hover { color: var(--entelai-albums-accent); }

.study-table > tbody > tr.eai-row-selected > td {
  background-color: rgba(13, 228, 196, 0.2) !important;
}

/* ── Multi-select: marquee (rubber-band) rectangle ─────────────────────────
   Fixed-position overlay drawn in viewport coords while dragging from an empty
   area. pointer-events:none so it never eats the mouse events driving it; sits
   below the drawer/tab (z ~2147483600) but above the table. */
.eai-marquee {
  position: fixed;
  z-index: 2147483590;
  border: 1px solid var(--entelai-albums-accent);
  background: rgba(13, 228, 196, 0.15);
  pointer-events: none;
  box-sizing: border-box;
}
/* While a marquee drag is live, kill text selection across the page. */
body.eai-marquee-active {
  user-select: none;
  -webkit-user-select: none;
}

/* ── Albums drawer open: shift the content column clear of the drawer ───────
   The drawer is a fixed 380px panel at left:0 that otherwise overlays the left
   columns. When it opens we re-centre the three 95%-centred blocks (selection
   bar, table scroll wrapper, pagination) within the space to the RIGHT of the
   drawer — the table just gets narrower and keeps its horizontal scroll, no
   page-level overflow. Smooth 250ms; only longhand left/right margins are
   overridden so each block keeps its own top/bottom spacing. Skipped on narrow
   viewports where there isn't room to give up 380px. */
#entelai-breadcrumb,
#entelai-selection-bar,
.eai-table-scroll-wrapper,
.eai-pagination-row {
  transition: margin 250ms ease, width 250ms ease;
}
/* Logo + search bar slide clear of the drawer too (transform: no reflow, leaves
   the right-hand header controls untouched). The logo <img> is positioned, so it
   is transformed directly rather than via a margin on its wrapper. */
.nav-side-content img.custom-logo,
#ao-search-bar {
  transition: transform 250ms ease;
}
@media (min-width: 900px) {
  body.entelai-albums-drawer-open #entelai-breadcrumb,
  body.entelai-albums-drawer-open #entelai-selection-bar,
  body.entelai-albums-drawer-open .eai-table-scroll-wrapper,
  body.entelai-albums-drawer-open .eai-pagination-row {
    width: calc((100% - var(--entelai-albums-w)) * 0.95);
    margin-left: calc(var(--entelai-albums-w) + (100% - var(--entelai-albums-w)) * 0.025);
    margin-right: calc((100% - var(--entelai-albums-w)) * 0.025);
  }
  body.entelai-albums-drawer-open .nav-side-content img.custom-logo,
  body.entelai-albums-drawer-open #ao-search-bar {
    transform: translateX(var(--entelai-albums-w));
  }
}

.entelai-albums-drag-ghost {
  position: absolute;
  top: -10000px; left: -10000px;
  background: var(--entelai-albums-accent);
  color: #0f172a;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.entelai-albums-ctx {
  position: fixed;
  list-style: none;
  margin: 0; padding: 0;
  background: #1A232F;
  color: #E5E7EB;
  border: none;
  border-radius: 6px;
  min-width: 200px;
  z-index: 2147483640;
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.35);
  font-family: 'Manrope', 'Inter', sans-serif;
  font-size: 14px;
  overflow: hidden;
}
.entelai-albums-ctx li {
  padding: 11px 13px;
  cursor: pointer;
}
.entelai-albums-ctx li:hover { background: rgba(13, 228, 196, 0.12); }
.entelai-albums-ctx li.sep {
  padding: 0;
  height: 1px;
  background: #030D19;
  margin: 0;
  cursor: default;
}
.entelai-albums-ctx li.sep:hover { background: #030D19; }

.entelai-albums-banner {
  padding: 8px 16px;
  background: rgba(20, 184, 166, 0.1);
  color: var(--entelai-albums-fg);
  font-size: 13px;
  border-radius: 6px;
  margin: 8px 0;
}
.entelai-albums-banner button {
  margin-left: 8px;
  background: transparent;
  color: var(--entelai-albums-accent);
  border: 1px solid var(--entelai-albums-accent);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font: inherit;
}

@keyframes entelai-albums-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.6); }
  100% { box-shadow: 0 0 0 16px rgba(20, 184, 166, 0); }
}
.entelai-albums-tab-pulse {
  animation: entelai-albums-pulse 1.5s ease-out infinite;
}

#entelai-breadcrumb {
  display: flex; align-items: center; gap: 2px;
  margin: 0 0 12px 48px;
  font-family: Manrope, sans-serif; font-weight: 700; font-size: 24px; line-height: 1;
  color: #fff;
}
#entelai-breadcrumb .ebc-seg {
  appearance: none; -webkit-appearance: none; background: none; border: none;
  padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer;
  transition: color .12s ease;
}
#entelai-breadcrumb .ebc-seg.ebc-link:hover { color: var(--ao-accent, #0DE4C4); }
#entelai-breadcrumb .ebc-sep {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; color: #fff; flex: 0 0 auto;
}
#entelai-breadcrumb .ebc-sep svg { width: 24px; height: 24px; display: block; }
#entelai-breadcrumb .ebc-current { color: #fff; }
