/* ============================================================
   CXone Studio Script Admin — NiCE brand styling
   Palette + type taken from NiCE Brand Guidelines 2025 (v2):
     NiCE blue #3694fc · Charcoal #21212b · White #fff · Warm white #f2f0eb
     Secondary: Emerald #00e2a0 · Teal #36ead0 · Electric blue #025afb
                Electric indigo #6100ff · Coral #ff5b8a
     Typeface: Be Vietnam Pro
   ============================================================ */

:root {
  --nice-blue: #3694fc; /* brand hero / gradients / large display only */
  --nice-blue-strong: #1f7bec;
  /* Accessible interactive blue for fills carrying white text (WCAG AA 5.27:1).
     Plain #3694fc is only 3.09:1 with white, so it's reserved for large/decorative use. */
  --nice-blue-btn: #1668d6;
  --nice-blue-btn-hover: #1257b8;
  --nice-blue-tint: #e7f1ff;
  --charcoal: #21212b;
  --charcoal-soft: #3a3a48;
  --white: #ffffff;
  --warm-white: #f2f0eb;

  --emerald: #00e2a0;
  --teal: #36ead0;
  --electric-blue: #025afb;
  --electric-indigo: #6100ff;
  --coral: #ff5b8a;

  --danger: #d92546;
  --danger-strong: #b81e3a;
  --danger-tint: #fdeaee;

  --ink: #21212b;
  --ink-muted: #63636f;
  --ink-faint: #6a6a74; /* AA 5.35:1 on white — folder paths must stay legible */
  --line: #e6e4de;
  --line-strong: #d8d6cf;

  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(33, 33, 43, 0.06), 0 1px 3px rgba(33, 33, 43, 0.05);
  --shadow-md: 0 8px 24px rgba(33, 33, 43, 0.08);
  --shadow-lg: 0 20px 50px rgba(33, 33, 43, 0.22);

  --hero-gradient: linear-gradient(
    115deg,
    #025afb 0%,
    #3694fc 34%,
    #37b6f2 62%,
    #36ead0 100%
  );

  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 15px;
  line-height: 1.5;
}

h1,
h2,
h3 {
  letter-spacing: -0.015em;
  font-weight: 600;
  margin: 0;
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--warm-white);
  padding: 1px 6px;
  border-radius: 6px;
}

[hidden] {
  display: none !important;
}

/* ── Buttons ── */

.btn {
  font-family: var(--font);
  font-weight: 500;
  font-size: 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease,
    color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  line-height: 1;
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: 3px solid rgba(54, 148, 252, 0.45);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--nice-blue-btn);
  color: var(--white);
}
.btn-primary:hover:not(:disabled) {
  background: var(--nice-blue-btn-hover);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--charcoal);
  border-color: var(--line-strong);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--warm-white);
  border-color: var(--line-strong);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}
.btn-block {
  width: 100%;
  justify-content: center;
  padding: 13px 20px;
  font-size: 15px;
}
.btn-ico {
  font-size: 15px;
  line-height: 1;
}

/* ── Splash ── */

.splash {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: var(--hero-gradient);
  z-index: 100;
}
.splash-mark svg {
  filter: drop-shadow(0 10px 24px rgba(2, 20, 60, 0.25));
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
.table-state .spinner {
  border-color: var(--line-strong);
  border-top-color: var(--nice-blue);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Login ── */

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--hero-gradient);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px 34px 34px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: rise 0.4s ease;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.login-mark {
  margin-bottom: 18px;
}
.login-mark svg {
  border-radius: 14px;
}
.login-title {
  font-size: 24px;
  margin-bottom: 6px;
}
.login-sub {
  color: var(--ink-muted);
  margin: 0 0 24px;
  font-size: 14px;
}
.field-label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  margin-bottom: 6px;
}
.text-input,
.search-input {
  font-family: var(--font);
  font-size: 15px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.text-input:focus,
.search-input:focus {
  outline: none;
  border-color: var(--nice-blue);
  box-shadow: 0 0 0 4px rgba(54, 148, 252, 0.16);
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  text-align: left;
  margin: 10px 0 0;
}
.login-form .btn-block,
#login-form .btn-block {
  margin-top: 20px;
}

/* ── Hero ── */

.hero {
  background: var(--hero-gradient);
  color: var(--white);
  padding: 22px clamp(16px, 4vw, 40px) 40px;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}
.hero-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-ident {
  display: inline-flex;
  height: 48px;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: var(--charcoal);
  box-shadow: 0 6px 16px rgba(2, 20, 60, 0.2);
  flex: 0 0 auto;
}
.brand-ident-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.brand-logo {
  height: 30px;
  width: auto;
  display: block;
  filter: drop-shadow(0 1px 3px rgba(2, 20, 60, 0.28));
}
.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.hero-actions .btn-ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.65);
  background: rgba(20, 40, 90, 0.22); /* darkens the light teal end so white text stays legible */
  text-shadow: 0 1px 2px rgba(2, 20, 60, 0.28);
}
.hero-actions .btn-ghost:hover:not(:disabled) {
  background: rgba(20, 40, 90, 0.34);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(2, 20, 60, 0.25);
}

.hero-title-row {
  max-width: 1240px;
  margin: 30px auto 0;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.title-pill {
  background: var(--white);
  border-radius: var(--radius-pill);
  padding: 14px 32px;
  box-shadow: 0 10px 30px rgba(2, 20, 60, 0.18);
}
.title-pill h1 {
  color: var(--charcoal);
  font-size: clamp(20px, 3.4vw, 30px);
}
.hero-tagline {
  color: #fff;
  font-size: 15px;
  font-weight: 400;
  margin: 0;
  max-width: 460px;
  /* Guarantees legibility over the lighter teal stops of the gradient. */
  text-shadow: 0 1px 3px rgba(2, 20, 60, 0.32);
}

/* ── Content ── */

.content {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px clamp(16px, 4vw, 40px) 60px;
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* ── Toolbar ── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  background: var(--warm-white);
  border-color: var(--line-strong);
}
.search-wrap {
  position: relative;
  flex: 1 1 320px;
  min-width: 220px;
}
.search-ico {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--ink-faint);
  pointer-events: none;
}
.search-input {
  padding-left: 40px;
  background: var(--white);
}
.filter-group {
  display: inline-flex;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  padding: 4px;
  gap: 2px;
}
.seg {
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.seg:hover {
  color: var(--charcoal);
}
.seg.is-active {
  background: var(--nice-blue-btn);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.toolbar-spacer {
  flex: 1 1 0;
}
.result-count {
  font-size: 13px;
  color: var(--ink-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* ── Action bar ── */

.action-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  background: var(--charcoal);
  color: #fff;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 12px;
  z-index: 20;
  animation: rise 0.2s ease;
}
.selection-count {
  font-weight: 600;
  font-size: 14px;
}
.action-bar-spacer {
  flex: 1 1 0;
}
.action-bar .btn-ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}
.action-bar .btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

/* ── Table ── */

.table-panel {
  overflow: hidden;
}
.table-scroll {
  overflow-x: auto;
}
.scripts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.scripts-table thead th {
  position: sticky;
  top: 0;
  background: var(--warm-white);
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  z-index: 5;
}
.scripts-table th.sortable {
  cursor: pointer;
  user-select: none;
  padding: 0; /* padding moves onto the inner button so the label is the hit + focus target */
}
.th-sort {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 13px 16px;
  text-align: left;
}
.th-sort:hover {
  color: var(--charcoal);
}
.th-sort:focus-visible {
  outline: 3px solid rgba(54, 148, 252, 0.5);
  outline-offset: -3px;
  border-radius: 8px;
}
.sort-ind {
  display: inline-block;
  min-width: 12px;
  color: var(--nice-blue-btn);
  font-size: 11px;
}
.scripts-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.scripts-table tbody tr:last-child td {
  border-bottom: none;
}
.scripts-table tbody tr {
  transition: background 0.12s ease;
}
.scripts-table tbody tr:hover {
  background: var(--warm-white);
}
.scripts-table tbody tr.is-selected {
  background: var(--nice-blue-tint);
}
.col-check {
  width: 46px;
  padding-left: 16px;
}
.col-media,
.col-status {
  width: 150px;
}
.col-date {
  width: 160px;
  white-space: nowrap;
}
.col-user {
  width: 160px;
}

.script-name {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.script-leaf {
  font-weight: 600;
  color: var(--charcoal);
  word-break: break-word;
}
.script-folder {
  font-size: 12px;
  color: var(--ink-faint);
  word-break: break-word;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}
.badge-active {
  background: rgba(0, 226, 160, 0.18);
  color: #05704f;
}
.badge-inactive {
  background: rgba(33, 33, 43, 0.08);
  color: var(--ink-muted);
}
.media-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--warm-white);
  border: 1px solid var(--line-strong);
  font-size: 12px;
  font-weight: 500;
  color: var(--charcoal-soft);
}
.cell-muted {
  color: var(--ink-muted);
  white-space: nowrap;
}

/* ── Custom checkbox ── */

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  position: relative;
}
.checkbox input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.checkbox-box {
  width: 20px;
  height: 20px;
  border-radius: 7px;
  border: 2px solid var(--line-strong);
  background: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
  flex: 0 0 auto;
}
.checkbox-box::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.12s ease;
  margin-top: -2px;
}
.checkbox input:checked + .checkbox-box {
  background: var(--nice-blue-btn);
  border-color: var(--nice-blue-btn);
}
.checkbox input:checked + .checkbox-box::after {
  transform: rotate(45deg) scale(1);
}
.checkbox input:indeterminate + .checkbox-box {
  background: var(--nice-blue-btn);
  border-color: var(--nice-blue-btn);
}
.checkbox input:indeterminate + .checkbox-box::after {
  content: "";
  width: 10px;
  height: 0;
  border: none;
  border-top: 2.5px solid #fff;
  transform: none;
  margin: 0;
}
.checkbox input:focus-visible + .checkbox-box {
  outline: 3px solid rgba(54, 148, 252, 0.45);
  outline-offset: 2px;
}

/* ── Table states ── */

.table-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--ink-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.state-emoji {
  font-size: 30px;
  margin: 0;
}
.state-hint {
  font-size: 13px;
  color: var(--ink-faint);
  margin: 0;
}

/* ── Footer ── */

.app-footer {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 20px;
  padding: 0 4px;
  font-size: 12px;
  color: var(--ink-faint);
}
.footer-warn {
  color: var(--danger-strong);
  font-weight: 500;
}

/* ── Modals ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
  animation: fade 0.15s ease;
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: rise 0.22s ease;
}
.modal-danger-bar {
  height: 6px;
  background: linear-gradient(90deg, var(--coral), var(--danger));
}
.modal-body {
  padding: 26px 28px 8px;
  overflow-y: auto;
}
.modal-title {
  font-size: 21px;
  margin-bottom: 10px;
}
.modal-text {
  color: var(--ink-muted);
  font-size: 14px;
  margin: 0 0 16px;
}
.confirm-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 12px 14px;
  background: var(--warm-white);
  border-radius: var(--radius-sm);
  max-height: 230px;
  overflow-y: auto;
  font-size: 13px;
}
.confirm-list li {
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  word-break: break-word;
  color: var(--charcoal);
}
.confirm-list li:last-child {
  border-bottom: none;
}
.confirm-ack {
  font-size: 14px;
  color: var(--charcoal);
  margin-bottom: 8px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 28px 24px;
  border-top: 1px solid var(--line);
  background: var(--white);
}

/* ── Progress / results ── */

.progress-track {
  height: 10px;
  background: var(--warm-white);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin: 4px 0 10px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--nice-blue), var(--teal));
  border-radius: var(--radius-pill);
  transition: width 0.25s ease;
}
.progress-text {
  font-size: 13px;
  color: var(--ink-muted);
  margin: 0 0 8px;
}
.results-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 6px 0 14px;
}
.summary-pill {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
}
.summary-ok {
  background: rgba(0, 226, 160, 0.18);
  color: #05704f;
}
.summary-fail {
  background: var(--danger-tint);
  color: var(--danger-strong);
}
.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  max-height: 300px;
  overflow-y: auto;
}
.results-list li {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}
.results-list li:last-child {
  border-bottom: none;
}
.result-icon {
  flex: 0 0 auto;
  font-size: 15px;
  line-height: 1.5;
}
.result-ok .result-icon {
  color: var(--emerald);
}
.result-fail .result-icon {
  color: var(--danger);
}
.result-detail {
  min-width: 0;
}
.result-path {
  color: var(--charcoal);
  font-weight: 500;
  word-break: break-word;
}
.result-reason {
  color: var(--ink-muted);
  font-size: 12px;
}

/* ── Toasts ── */

.toast-container {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 300;
  width: min(92vw, 420px);
}
.toast {
  background: var(--charcoal);
  color: #fff;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: rise 0.2s ease;
  display: flex;
  gap: 10px;
  align-items: center;
}
.toast-ok {
  background: #05704f;
}
.toast-err {
  background: var(--danger-strong);
}

/* ── Breadcrumb ── */

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 0 2px 14px;
}
.crumb-link {
  border: none;
  background: transparent;
  color: var(--nice-blue-btn);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.crumb-link:hover {
  background: var(--warm-white);
  text-decoration: underline;
}
.crumb-link:focus-visible {
  outline: 3px solid rgba(54, 148, 252, 0.45);
  outline-offset: 1px;
}
.crumb-current {
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  padding: 4px 6px;
}
.crumb-sep {
  color: var(--ink-faint);
  font-size: 14px;
}

/* ── Folder rows ── */

.folder-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--charcoal);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 8px;
}
.folder-btn:hover {
  color: var(--nice-blue-btn);
}
.folder-btn:hover .folder-name {
  text-decoration: underline;
}
.folder-btn:focus-visible {
  outline: 3px solid rgba(54, 148, 252, 0.45);
  outline-offset: 1px;
}
.folder-ico {
  font-size: 16px;
  line-height: 1;
}
.media-folder {
  background: var(--nice-blue-tint);
  border-color: #cfe2ff;
  color: #1257b8;
}

/* ── Responsive ── */

@media (max-width: 720px) {
  .hero-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .toolbar {
    gap: 10px;
  }
  .toolbar-spacer {
    display: none;
  }
  .result-count {
    width: 100%;
  }
  .col-user,
  .col-date {
    display: none;
  }
}

/* ── Reduced motion ── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
