/* =========================================================
   PATCH 2026-08-26 | OPTIONAL MAPPING-HINTS CONTROL (Study Matrix)

   Compact trigger button beside "ZAR AI · Suggest", plus a viewport-
   anchored popover rendered outside normal layout flow (position:
   fixed, JS-positioned like emc_tooltips.js) so opening it never
   resizes or repositions the dropdown, ZAR button, feedback area, or
   rename rows below.
========================================================= */

.marss-emc .emc-group-count-suggest-buttons{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.marss-emc #emcMappingHintsBtn.emc-mapping-hints-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:.4rem;

  padding:7px 25px;

  cursor:pointer;

  border:1px solid #c4d3e9;
  border-radius:8px;
  background:#fff;
  color:#405272;

  font-size:.78rem;
  font-weight:750;

  transition:
    background-color .18s ease,
    border-color .18s ease,
    color .18s ease;
}

.marss-emc #emcMappingHintsBtn.emc-mapping-hints-btn svg{
  width:16px;
  height:16px;
  flex:0 0 16px;
}

.marss-emc #emcMappingHintsBtn.emc-mapping-hints-btn:hover{
  border-color:#92afd5;
  background:#f4f8fe;
  color:#304b74;
}

.marss-emc #emcMappingHintsBtn.emc-mapping-hints-btn:focus-visible{
  outline:3px solid rgba(91,112,179,.32);
  outline-offset:2px;
}

/* Loaded state: subtle, not alarming — this is optional evidence, not an error. */
.marss-emc #emcMappingHintsBtn.emc-mapping-hints-btn[data-loaded="true"]{
  border-color:rgba(84,180,151,.55);
  background:rgba(84,180,151,.1);
  color:#287963;
}

/* =========================================================
   POPOVER — anchored, outside normal flow

   PATCH 2026-08-26 | UNSCOPED ON PURPOSE

   emc_mapping_hints.js moves this element to document.body at bind
   time (the MARSS dock wrapper sets transform/will-change:transform
   for its slide animation, which would otherwise make it the
   containing block for position:fixed here — the same clipping bug
   already fixed for the tooltip overlay). Once moved, this subtree is
   no longer inside .marss-emc, so these rules are intentionally
   unscoped and use literal colors instead of the --emc-* custom
   properties (which are also only defined inside .marss-emc's own
   scope) — mirroring emc_tooltips.js's .emc-tooltip-overlay exactly.
   The trigger BUTTON above stays in place and keeps using .marss-emc
   + var(--emc-*) normally.
========================================================= */

.emc-mapping-hints-popover{
  position:fixed;
  z-index:99976;

  display:grid;
  gap:10px;

  width:min(420px,calc(100vw - 24px));
  max-height:min(560px,calc(100vh - 24px));
  overflow:auto;

  padding:14px 16px 16px;

  border:1px solid #d9e2f1;
  border-radius:14px;

  background:#fff;
  color:#18213a;

  font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  font-size:13px;
  line-height:1.45;

  box-shadow:0 22px 55px rgba(31,48,89,.22);
}

.emc-mapping-hints-popover[hidden]{
  display:none;
}

.emc-mapping-hints-popover-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}

.emc-mapping-hints-popover-head h3{
  margin:0;
  color:#233657;
  font-size:.95rem;
}

.emc-mapping-hints-popover-close{
  display:grid;
  place-items:center;
  flex:0 0 auto;
  width:26px;
  height:26px;

  border:1px solid #d9e2f1;
  border-radius:8px;

  background:#fff;
  color:#4f5f7e;

  font-size:12px;
  line-height:1;

  cursor:pointer;
}

.emc-mapping-hints-popover-close:hover{
  background:#f2f5fb;
}

.emc-mapping-hints-popover-close:focus-visible{
  outline:3px solid rgba(91,112,179,.32);
  outline-offset:2px;
}

.emc-mapping-hints-popover-copy{
  margin:0;
  color:#73809b;
  font-size:.76rem;
  line-height:1.5;
}

/* =========================================================
   DROP ZONE

   PATCH 2026-08-30 | SLIGHTLY MORE COMPACT

   This no longer needs to dominate the popover: a second, faster
   entry point now lives inline in the main Study Matrix panel (see
   the INLINE DROP ENTRY POINT section below and
   #emcInlineMappingHintsDropZone in emc_study_matrix_configuration.php).
   This popover surface remains fully functional as a fallback/manual
   path, just sized down a little.
========================================================= */

.emc-mapping-hints-upload-area{
  position:relative;
  display:grid;
  gap:8px;
}

.emc-mapping-hints-dropzone{
  display:grid;
  justify-items:center;
  gap:5px;

  padding:12px 10px;

  border:1.5px dashed #b9c8e3;
  border-radius:10px;

  background:#f1f5fc;
  color:#4f5f7e;

  font-size:.74rem;
  text-align:center;

  cursor:pointer;

  transition:
    border-color .15s ease,
    background-color .15s ease;
}

.emc-mapping-hints-dropzone svg{
  width:18px;
  height:18px;
  color:#73809b;
}

.emc-mapping-hints-dropzone:hover,
.emc-mapping-hints-dropzone:focus-visible{
  border-color:rgba(84,180,151,.6);
  background:rgba(84,180,151,.08);
}

.emc-mapping-hints-dropzone:focus-visible{
  outline:3px solid rgba(91,112,179,.32);
  outline-offset:2px;
}

.emc-mapping-hints-dropzone[data-dragover="true"]{
  border-color:rgb(84,180,151);
  background:rgba(84,180,151,.14);
  color:#287963;
}

/* =========================================================
   COMPACT LOADED-FILE STATE

   Shown instead of the dropzone whenever a file is already loaded —
   whichever entry point (this popover's own dropzone, the inline
   main-panel drop target, or a prior session's Replace) supplied it.
========================================================= */

.emc-mapping-hints-loaded-row{
  display:flex;
  align-items:center;
  gap:8px;

  padding:8px 10px;

  border:1px solid rgba(84,180,151,.4);
  border-radius:10px;

  background:rgba(84,180,151,.08);
}

.emc-mapping-hints-loaded-icon{
  width:18px;
  height:18px;
  flex:0 0 18px;
  color:#287963;
}

.emc-mapping-hints-loaded-filename{
  flex:1 1 auto;
  min-width:0;

  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;

  color:#287963;
  font-size:.76rem;
  font-weight:750;
}

.emc-mapping-hints-replace-btn{
  flex:0 0 auto;

  padding:4px 9px;

  border:1px solid #cbd6e8;
  border-radius:7px;

  background:#fff;
  color:#405272;

  font-size:.7rem;
  font-weight:650;

  cursor:pointer;

  transition:
    background-color .15s ease,
    border-color .15s ease;
}

.emc-mapping-hints-replace-btn:hover{
  background:#f4f8fe;
  border-color:#b7c8e3;
}

.emc-mapping-hints-replace-btn:focus-visible{
  outline:3px solid rgba(91,112,179,.32);
  outline-offset:2px;
}

.emc-mapping-hints-file-input{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  border:0;
}

.emc-mapping-hints-divider{
  display:flex;
  align-items:center;
  gap:8px;

  color:#73809b;
  font-size:.68rem;
  text-transform:uppercase;
  letter-spacing:.06em;
}

.emc-mapping-hints-divider::before,
.emc-mapping-hints-divider::after{
  content:"";
  flex:1;
  height:1px;
  background:#d9e2f1;
}

/* =========================================================
   TEXTAREA + FEEDBACK
========================================================= */

.emc-mapping-hints-textarea{
  width:100%;
  min-width:0;
  padding:9px 10px;

  border:1px solid #cbd6e8;
  border-radius:8px;

  background:#fff;
  color:#18213a;

  font-family:ui-monospace,SFMono-Regular,Consolas,monospace;
  font-size:.76rem;
  line-height:1.5;

  resize:vertical;
}

.emc-mapping-hints-textarea::placeholder{
  color:#a7b2c4;
}

.emc-mapping-hints-textarea:focus-visible{
  outline:3px solid rgba(91,112,179,.32);
  outline-offset:2px;
}

.emc-mapping-hints-feedback{
  padding:7px 9px;
  border-radius:8px;
  font-size:.72rem;
  line-height:1.4;
}

.emc-mapping-hints-feedback[hidden]{
  display:none;
}

.emc-mapping-hints-feedback[data-status="success"]{
  background:#e8f3ef;
  color:#2f6c5c;
}

.emc-mapping-hints-feedback[data-status="warning"]{
  background:#fbf2df;
  color:#8a6520;
}

.emc-mapping-hints-feedback[data-status="error"]{
  background:#fbe6ea;
  color:#c94965;
}

.emc-mapping-hints-popover-actions{
  display:flex;
  justify-content:flex-end;
}

/* =========================================================
   PATCH 2026-08-26 | CLEAR BUTTON

   Previously class="gb-btn gb-btn-secondary" — those are only styled
   inside .marss-emc's scope (emc_controls.css), so once this popover
   moved to document.body (see the note above .emc-mapping-hints-
   popover) the button rendered as a bare browser default. Given its
   own dedicated, unscoped rule here instead, matching the same light
   EMC palette/geometry already used by .emc-mapping-hints-popover-
   close and .emc-mapping-hints-clear-btn's other popover siblings.
   Restrained by design: no shadow, no glow, no translate/movement,
   no heavy weight — just background/border/color on hover and active.
========================================================= */
.emc-mapping-hints-clear-btn{
  padding:7px 13px;

  border:1px solid #cbd6e8;
  border-radius:8px;

  background:#fff;
  color:#405272;

  font:inherit;
  font-weight:650;

  cursor:pointer;

  transition:
    background-color .15s ease,
    border-color .15s ease;
}

.emc-mapping-hints-clear-btn:hover{
  background:#f4f8fe;
  border-color:#b7c8e3;
}

.emc-mapping-hints-clear-btn:active{
  background:#eaf0fa;
  border-color:#a9bedd;
}

.emc-mapping-hints-clear-btn:focus-visible{
  outline:3px solid rgba(91,112,179,.32);
  outline-offset:2px;
}

@media(max-width:560px){
  .emc-mapping-hints-popover{
    width:calc(100vw - 16px);
  }
}

/* =========================================================
   PATCH 2026-08-30 | INLINE DROP ENTRY POINT (main Study Matrix panel)

   Lives in the third "Number of groups to rename" toolbar column
   (emc_study_matrix_configuration.php, .emc-inline-mapping-hints-column),
   the SAME column that already held only #emcAliasFeedback — this is
   deliberately scoped/normal (unlike the popover above, which is
   moved to document.body and therefore unscoped with literal colors):
   it never leaves .marss-emc, so var(--emc-*) tokens are available.

   Sized to feel like an input utility attached to "ZAR AI · Suggest",
   not a second large card: capped to a compact, roughly square
   footprint (never stretching to the column's full available width),
   while #emcAliasFeedback below it keeps that column's full width for
   wrapping its own (sometimes long) messages.
========================================================= */

.marss-emc .emc-inline-mapping-hints-column{
  align-self:stretch;

  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:8px;

  min-width:0;
}

.marss-emc .emc-inline-mapping-hints-dropzone{
  flex:1 1 auto;

  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:5px;

  width:100%;
  max-width:172px;
  min-height:64px;

  padding:10px 12px;

  border:1.5px dashed #b9c8e3;
  border-radius:10px;

  background:#f1f5fc;
  color:#4f5f7e;

  text-align:center;
  cursor:pointer;

  transition:
    border-color .15s ease,
    background-color .15s ease;
}

.marss-emc .emc-inline-mapping-hints-dropzone svg{
  width:18px;
  height:18px;
  color:#73809b;
  flex:0 0 auto;
}

.marss-emc .emc-inline-mapping-hints-dropzone-text{
  display:grid;
  gap:1px;
  line-height:1.25;
}

.marss-emc .emc-inline-mapping-hints-dropzone-text strong{
  color:#334c75;
  font-size:.7rem;
  font-weight:800;
}

.marss-emc .emc-inline-mapping-hints-dropzone-text span{
  color:#73809b;
  font-size:.66rem;
}

.marss-emc .emc-inline-mapping-hints-dropzone:hover,
.marss-emc .emc-inline-mapping-hints-dropzone:focus-visible{
  border-color:rgba(84,180,151,.6);
  background:rgba(84,180,151,.08);
}

.marss-emc .emc-inline-mapping-hints-dropzone:focus-visible{
  outline:3px solid rgba(91,112,179,.32);
  outline-offset:2px;
}

.marss-emc .emc-inline-mapping-hints-dropzone[data-dragover="true"]{
  border-color:rgb(84,180,151);
  background:rgba(84,180,151,.14);
  color:#287963;
}

.marss-emc .emc-inline-mapping-hints-dropzone[data-dragover="true"] svg,
.marss-emc .emc-inline-mapping-hints-dropzone[data-dragover="true"] .emc-inline-mapping-hints-dropzone-text strong{
  color:#287963;
}
