/* ============================================================
   NexaGrid — Template Customizer
   Flat, clean, MeetERP-style off-canvas drawer
   ============================================================ */

/* ================= Floating Trigger ================= */
.customizer-trigger {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  transform-origin: right center;
  z-index: 100005;
  width: 48px;
  height: 48px;
  border-radius: 12px 0 0 12px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: -10px 0 22px -6px rgb(var(--accent-rgb) / 0.5);
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.25s, box-shadow 0.25s, opacity 0.25s;
}

.customizer-trigger:hover {
  transform: translateY(-50%) scale(1.08);
  background: var(--accent-hover);
  box-shadow: -14px 0 28px -6px rgb(var(--accent-rgb) / 0.6);
}

.customizer-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft), -10px 0 22px -6px rgb(var(--accent-rgb) / 0.5);
}

.customizer-trigger svg {
  width: 22px;
  height: 22px;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.customizer-trigger:hover svg {
  transform: translateX(-1px);
}

.customizer-trigger.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(12px) scale(0.9);
}

.cz-open .customizer-trigger {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(14px);
}

/* ================= Backdrop ================= */
.customizer-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 0.45);
  opacity: 0;
  pointer-events: none;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 99998;
}

.customizer-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ================= Drawer ================= */
.customizer-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -24px 0 48px -12px rgb(15 23 42 / 0.18);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.customizer-drawer.open {
  transform: translateX(0);
}

@media (max-width: 767px) {
  .customizer-drawer {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }
}

/* ================= Drawer Header ================= */
.customizer-head {
  flex-shrink: 0;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.customizer-title h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.customizer-title p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

.customizer-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.customizer-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.customizer-icon-btn:hover {
  background: var(--surface-inset);
  color: var(--ink);
}

.customizer-icon-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}

.customizer-icon-btn svg {
  width: 18px;
  height: 18px;
}

.customizer-icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ================= Drawer Body ================= */
.customizer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.customizer-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.customizer-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.customizer-section-title::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

/* ================= Group ================= */
.customizer-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.customizer-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

/* ================= Swatches (Primary Color) ================= */
.cz-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.cz-swatch {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  flex-shrink: 0;
  overflow: hidden;
}

.cz-swatch::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
}

.cz-swatch:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgb(15 23 42 / 0.15);
}

.cz-swatch.active {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--canvas), 0 4px 12px rgb(15 23 42 / 0.15);
}

.cz-swatch.active::before {
  border-color: var(--accent);
}

/* Color swatch backgrounds */
.cz-swatch[data-color="blue"] { color: #3186fb; }
.cz-swatch[data-color="teal"] { color: #14b8a6; }
.cz-swatch[data-color="orange"] { color: #f97316; }
.cz-swatch[data-color="pink"] { color: #f43f5e; }
.cz-swatch[data-color="purple"] { color: #a855f7; }

/* Custom swatch - no color fill, shows plus icon */
.cz-swatch[data-color="custom"] {
  color: transparent;
}
.cz-swatch[data-color="custom"]::before {
  background: transparent;
}

.cz-swatch-custom {
  position: relative;
  background: var(--surface-inset);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cz-swatch-custom input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border-radius: var(--radius-md);
}

.cz-swatch-custom::before {
  background: transparent;
}

.cz-swatch-plus {
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

/* ================= Option Cards ================= */
.cz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cz-option {
  position: relative;
  flex: 1 1 0;
  min-width: 84px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.cz-option:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.cz-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
  color: var(--accent);
}

.cz-option:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.cz-option.active::after {
  content: '✓';
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  color: var(--accent);
  margin-left: 2px;
}

.cz-option-name {
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  text-align: center;
}

/* ================= Bottom Toast ================= */
#cz-toast-root {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100001;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  width: min(420px, calc(100vw - 40px));
}

.cz-toast {
  pointer-events: auto;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--canvas) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 48px rgb(15 23 42 / 0.16), 0 2px 8px rgb(15 23 42 / 0.06);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  animation: cz-toast-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.cz-toast .cz-toast-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cz-toast .cz-toast-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cz-toast .cz-toast-icon svg { width: 18px; height: 18px; }

.cz-toast .cz-toast-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}

.cz-toast .cz-toast-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}

.cz-toast .cz-toast-close:hover {
  background: var(--surface-inset);
  color: var(--ink);
}

.cz-toast.success .cz-toast-icon { background: var(--success-soft); color: var(--success); }
.cz-toast.error .cz-toast-icon { background: var(--danger-soft); color: var(--danger); }
.cz-toast.info .cz-toast-icon { background: var(--accent-soft); color: var(--accent); }
.cz-toast.warning .cz-toast-icon { background: var(--warning-soft); color: var(--warning); }

/* ================= Centered Confirm Dialog ================= */
.cz-confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100002;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.cz-confirm-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.cz-confirm-dialog {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 32px 72px -16px rgb(15 23 42 / 0.28);
  border: 1px solid var(--border);
  max-width: 420px;
  width: 100%;
  transform: translateY(20px) scale(0.96);
  opacity: 0;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s;
}

.cz-confirm-backdrop.visible .cz-confirm-dialog {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.cz-confirm-head {
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.cz-confirm-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.cz-confirm-subtitle {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

.cz-confirm-body {
  padding: 18px 20px;
}

.cz-confirm-body p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
}

.cz-confirm-foot {
  padding: 14px 20px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border);
}

.cz-confirm-foot .btn-flat {
  min-width: 96px;
}

/* ================= Body State Classes (Live Preview) ================= */

/* Theme */
html[data-theme="dark"] {
  /* handled by existing html.dark in variables.css */
}

/* Skin: Bordered */
html[data-skin="bordered"] .widget-card,
html[data-skin="bordered"] .ast-card,
html[data-skin="bordered"] .set-card,
html[data-skin="bordered"] .set-mod-card,
html[data-skin="bordered"] .set-import-card,
html[data-skin="bordered"] .auth-card,
html[data-skin="bordered"] .profile-panel,
html[data-skin="bordered"] .cd-table-wrap,
html[data-skin="bordered"] .cd-card,
html[data-skin="bordered"] .perf-banner,
html[data-skin="bordered"] .kpi-card,
html[data-skin="bordered"] .overview-kpis .kpi-card {
  border: 1px solid var(--border);
  box-shadow: none;
}

html[data-skin="bordered"] .input-flat,
html[data-skin="bordered"] select.input-flat,
html[data-skin="bordered"] .csel-trigger {
  box-shadow: inset 0 0 0 1px var(--border-strong);
  background: var(--canvas);
}

html[data-skin="bordered"] #app-sidebar {
  border-right: 1px solid var(--border);
}

html[data-skin="bordered"] #app-header {
  border-bottom: 1px solid var(--border);
}

html[data-skin="bordered"] .widget-table th,
html[data-skin="bordered"] .widget-table td {
  border-color: var(--border);
}

html[data-skin="bordered"] .boards-tab {
  border: 1px solid var(--border);
  background: var(--canvas);
}

html[data-skin="bordered"] .boards-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Header Type: Static */
html[data-header="static"] #app-main {
  overflow-y: auto;
}

html[data-header="static"] #app-content {
  overflow-y: visible;
  flex: 0 1 auto;
  min-height: auto;
}

html[data-header="static"] .page-breadcrumbs {
  position: static;
}

/* Content Width */
html[data-content="compact"] .page-shell {
  max-width: 1440px;
  margin-inline: auto;
  width: 100%;
}

html[data-content="wide"] .page-shell {
  max-width: 100%;
}

/* UI Density */
html[data-density="compact"] .page-shell {
  gap: 14px;
  padding-top: 2px;
}

html[data-density="compact"] .widget-card {
  padding: 18px 20px;
}

html[data-density="compact"] .widget-heading {
  margin-bottom: 14px;
}

html[data-density="compact"] .stat-row {
  padding: 6px 0;
}

html[data-density="compact"] .stat-row + .stat-row {
  padding-top: 6px;
}

html[data-density="compact"] .widget-table th,
html[data-density="compact"] .widget-table td {
  padding: 10px 12px;
}

html[data-density="compact"] .input-flat {
  height: 38px;
  padding: 0 14px;
}

html[data-density="compact"] .btn-flat {
  height: 38px;
  padding: 0 18px;
}

html[data-density="compact"] .btn-flat.sm {
  height: 32px;
  padding: 0 14px;
}

html[data-density="compact"] .cd-tile {
  padding: 10px 0;
}

html[data-density="compact"] .cd-sec-head {
  margin-bottom: 14px;
}

html[data-density="compact"] .cd-anchors a {
  height: 30px;
  padding: 0 11px;
}

html[data-density="compact"] .cd-sec-num {
  width: 30px;
  height: 30px;
}

html[data-density="compact"] .kpi-card {
  padding: 14px 16px;
}

html[data-density="compact"] .ast-card {
  padding: 14px;
}

html[data-density="compact"] .set-card {
  padding: 14px;
}

html[data-density="compact"] .profile-panel {
  padding: 14px;
}

/* ================= Animations ================= */
@keyframes cz-toast-in {
  from { transform: translateY(20px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ================= Scrollbar ================= */
.customizer-body::-webkit-scrollbar {
  width: 6px;
}

.customizer-body::-webkit-scrollbar-track {
  background: transparent;
}

.customizer-body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.customizer-body::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ================= Fix: Ensure customizer buttons are clickable ================= */
.customizer-drawer {
  pointer-events: auto;
}

.customizer-drawer .cz-swatch,
.customizer-drawer .cz-option,
.customizer-drawer .cz-swatch-custom,
.customizer-drawer .customizer-icon-btn,
.customizer-drawer .cz-swatch-custom input[type="color"] {
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* Ensure backdrop doesn't block drawer */
.customizer-backdrop {
  pointer-events: none;
}

.customizer-backdrop.visible {
  pointer-events: auto;
}