/* ======================================================================
   portal-ux.css — Dropdown + Modal UX layer
   All classes use "ux-" prefix to avoid collisions with portal CSS.
   Dropdowns use position:fixed + JS coords to escape overflow:auto.
   ====================================================================== */

/* ── ••• Trigger button ─────────────────────────────────────────── */
.ux-trigger {
  background: none;
  border: 1px solid transparent;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm, 8px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #8a929e);
  font-size: 18px;
  letter-spacing: 1px;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  padding: 0;
  vertical-align: middle;
  font-family: inherit;
}
.ux-trigger:hover,
.ux-trigger.ux-active {
  background: var(--hover-bg, #e8edf5);
  border-color: var(--border, #e6e8ec);
  color: var(--text, #16191f);
}

/* ── Dropdown (position:fixed — escapes overflow:auto) ──────────── */
.ux-dd {
  display: none;
  position: fixed;
  background: #ffffff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.10), 0 4px 6px -4px rgba(0,0,0,0.10);
  z-index: 8000;
  min-width: 172px;
  padding: 4px 0;
  text-align: left;
}
.ux-dd.ux-open {
  display: block;
  animation: ux-dd-in 0.12s ease-out;
}
@keyframes ux-dd-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ux-dd-item {
  width: 100%;
  display: block;
  padding: 8px 12px;
  background: none;
  border: none;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #16191f);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s;
  white-space: nowrap;
  line-height: 1.4;
  font-family: inherit;
}
.ux-dd-item:hover:not(:disabled) {
  background: var(--hover-bg, #e8edf5);
  text-decoration: none;
}
.ux-dd-item.ux-danger       { color: var(--red, #c0432f); }
.ux-dd-item.ux-danger:hover:not(:disabled) { background: var(--red-bg, #fff7f7); }
.ux-dd-item:disabled        { color: var(--text-faint, #c4c9d1); cursor: not-allowed; }

.ux-dd-sep {
  height: 1px;
  background: var(--border, #e2e8f0);
  margin: 4px 0;
}

/* Tooltip on disabled items — appears to the left of dropdown */
.ux-tip-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.ux-tip {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  width: 210px;
  background: #0f172a;
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  z-index: 8100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  transition: opacity 0.14s;
  white-space: normal;
}
.ux-tip::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 100%;
  margin-top: -5px;
  border: 5px solid transparent;
  border-left-color: #0f172a;
}
.ux-tip-wrap:hover .ux-tip {
  visibility: visible;
  opacity: 1;
}

/* ── Modal overlay ──────────────────────────────────────────────── */
.ux-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.30);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 9000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.ux-modal.ux-open {
  display: flex;
}

/* ── Modal dialog box ───────────────────────────────────────────── */
.ux-dlg {
  background: #ffffff;
  border-radius: 10px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 24px 60px rgba(13,21,38,0.30);
  overflow: hidden;
  animation: ux-dlg-in 0.2s ease-out;
}
.ux-dlg.ux-dlg-sm { max-width: 400px; }
.ux-dlg.ux-dlg-md { max-width: 520px; }

@keyframes ux-dlg-in {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.ux-dlg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.ux-dlg-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text, #16191f);
  margin: 0;
  line-height: 1.3;
}
.ux-dlg-subtitle {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

.ux-dlg-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
  font-family: inherit;
}
.ux-dlg-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.ux-dlg-body {
  padding: 24px;
}

.ux-dlg-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid var(--border, #e2e8f0);
}

/* ── Alert banners inside modal ─────────────────────────────────── */
.ux-alert {
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 20px;
}
.ux-alert-info    { background: #f0fdfa; border: 1px solid #ccfbf1; color: #0f766e; }
.ux-alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.ux-alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* ── Form fields inside modal ───────────────────────────────────── */
.ux-field { margin-bottom: 16px; }
.ux-field:last-child { margin-bottom: 0; }

.ux-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #0f172a;
  margin-bottom: 6px;
}
.ux-label.ux-label-danger { color: #dc2626; }

/* Input + suffix (e.g. GiB) */
.ux-input-row {
  align-items: center;
  display: flex;
  border: 1px solid var(--border-med, #cbd5e1);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.ux-input-row:focus-within {
  border-color: var(--brand, #2563eb);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.ux-input-row input {
  flex: 1 1 auto;
  min-width: 0;
  border: none !important;
  border-radius: 0 !important;
  outline: none;
  box-shadow: none !important;
  padding: 10px 12px;
  font-size: 14px;
  color: #0f172a;
  background: transparent;
  width: 100%;
}
.ux-input-row input:focus {
  outline: none;
  border: none !important;
  box-shadow: none !important;
}
.ux-input-addon {
  background: #f1f5f9;
  padding: 10px 14px;
  font-size: 13px;
  color: #64748b;
  border-left: 1px solid var(--border-med, #cbd5e1);
  white-space: nowrap;
  display: flex;
  align-items: center;
  font-weight: 600;
  flex-shrink: 0;
}

.ux-hint {
  font-size: 12px;
  color: #64748b;
  margin-top: 6px;
  line-height: 1.45;
}

/* ── Table cell alignment override for pages using this UX ─────── */
.ux-table tbody td {
  vertical-align: middle;
}
.ux-table thead th:last-child,
.ux-table tbody td:last-child {
  text-align: right;
}

/* Actions cell */
.ux-act-cell {
  text-align: right !important;
  padding-right: 14px !important;
  vertical-align: middle !important;
  white-space: nowrap;
}

/* ── Copy / Move modal path-builder components ────────────────────
   op- prefix keeps these scoped and avoids collisions.
────────────────────────────────────────────────────────────────── */
.op-source-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  background: var(--surface2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
}
.op-source-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint, #94a3b8);
  white-space: nowrap;
  flex-shrink: 0;
}
.op-source-file {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.op-source-file-name {
  font-family: monospace;
  font-size: 13px;
  color: var(--text, #0f172a);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.op-col-labels {
  display: flex;
  gap: 0;
  margin-bottom: 4px;
}
.op-col-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint, #94a3b8);
}
/* The "/" separator inside the ux-input-row path builder */
.op-dest-sep {
  display: flex;
  align-items: center;
  padding: 0 9px;
  font-family: monospace;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-faint, #94a3b8);
  background: var(--surface2, #f8fafc);
  border-left: 1px solid var(--border-med, #cbd5e1);
  border-right: 1px solid var(--border-med, #cbd5e1);
  align-self: stretch;
  flex-shrink: 0;
  user-select: none;
}
.op-dest-folder-input,
.op-dest-file-input {
  flex: 1 1 0;
  min-width: 0;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 10px 12px;
  font-family: monospace;
  font-size: 13px;
  color: var(--text, #0f172a);
  width: 100%;
}
.op-dest-folder-input { flex: 1.3 1 0; }
.op-dest-file-input   { flex: 1 1 0; }
.op-path-preview {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1px;
  padding: 9px 13px;
  background: var(--surface2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  margin-top: 10px;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.6;
  min-height: 38px;
}
.op-path-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint, #94a3b8);
  margin-right: 8px;
  font-family: inherit;
  align-self: center;
}
.op-path-bucket { color: var(--text-faint, #94a3b8); }
.op-path-sep    { color: var(--text-faint, #94a3b8); padding: 0 1px; }
.op-path-folder { color: var(--text-muted, #64748b); }
.op-path-file   { color: var(--text, #0f172a); font-weight: 700; }
.op-field-error {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #dc2626;
  margin-top: 5px;
}
.op-copy-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 12px;
  background: rgba(34, 197, 94, 0.06);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 7px;
  margin-top: 14px;
  font-size: 13px;
  color: #166534;
  line-height: 1.45;
}

/* ── Row selection checkboxes ───────────────────────────────────── */
.ux-select-cell {
  width: 36px;
  padding-left: 16px !important;
  padding-right: 0 !important;
  text-align: left !important;
}
.ux-select-cell input[type="checkbox"],
#select-all-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--brand, #2563eb);
}
.ux-table tbody tr.ux-row-selected {
  background: rgba(37, 99, 235, 0.05);
}

/* ── Bulk action bar — floating, shown once 1+ rows are selected ─── */
.ux-bulkbar {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  z-index: 7000;
  opacity: 0;
  transition: opacity 0.16s ease-out, transform 0.16s ease-out;
}
.ux-bulkbar.ux-bulkbar-visible {
  display: block;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.ux-bulkbar-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #0f172a;
  color: #fff;
  border-radius: 999px;
  padding: 8px 10px 8px 18px;
  box-shadow: 0 20px 35px -10px rgba(15, 23, 42, 0.45), 0 8px 12px -6px rgba(15, 23, 42, 0.3);
  white-space: nowrap;
}
.ux-bulkbar-count {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  margin-right: 6px;
}
.ux-bulkbar-count strong { color: #fff; font-weight: 700; }
.ux-bulkbar-clear {
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 999px;
  font-family: inherit;
  transition: color 0.12s, background 0.12s;
}
.ux-bulkbar-clear:hover { color: #fff; background: rgba(255,255,255,0.08); }
.ux-bulkbar-sep {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.14);
  margin: 0 6px;
  flex-shrink: 0;
}
.ux-bulkbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid transparent;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.ux-bulkbar-btn svg { flex-shrink: 0; }
.ux-bulkbar-btn:hover:not(:disabled) { background: rgba(255,255,255,0.14); }
.ux-bulkbar-btn:disabled {
  color: rgba(255,255,255,0.32);
  cursor: not-allowed;
}
.ux-bulkbar-btn.ux-bulkbar-danger { color: #fca5a5; }
.ux-bulkbar-btn.ux-bulkbar-danger:hover:not(:disabled) { background: rgba(220,38,38,0.22); color: #fecaca; }

/* Disabled-button tooltip reused from .ux-tip, flipped to sit above the bar.
   Only shown when the sibling button is actually disabled — otherwise the
   generic .ux-tip-wrap:hover rule would surface it on every hover. */
.ux-bulkbar .ux-tip-wrap { display: inline-flex; width: auto; }
.ux-bulkbar .ux-tip-wrap:hover .ux-bulkbar-btn:not(:disabled) ~ .ux-tip {
  visibility: hidden;
  opacity: 0;
}
.ux-bulkbar .ux-tip {
  right: auto;
  left: 50%;
  top: auto;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: 200px;
}
.ux-bulkbar .ux-tip::after {
  top: 100%;
  left: 50%;
  margin-top: 0;
  margin-left: -5px;
  border-left-color: transparent;
  border-top-color: #0f172a;
}

/* Selected-file preview list inside bulk modals */
.ux-bulk-file-list {
  max-height: 130px;
  overflow-y: auto;
  background: var(--surface2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-family: monospace;
  color: var(--text-muted, #64748b);
  line-height: 1.7;
  margin-bottom: 16px;
}
.ux-bulk-file-list div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
