/* ID Card Designer — styles */
:root {
  --bg: #0f1115;
  --panel: #161a22;
  --panel-2: #1e2330;
  --border: #262c3a;
  --text: #e6e8ee;
  --muted: #8b93a7;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --shadow: 0 4px 20px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "Noto Sans Arabic", "Microsoft YaHei", "PingFang SC", "Segoe UI Arabic", "Tahoma", Helvetica, Arial, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  height: 56px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 16px; font-weight: 600; margin: 0; }
.logo {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); border-radius: 6px; color: white; font-size: 16px;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }

button, .file-btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  transition: background .15s, border-color .15s;
  display: inline-flex; align-items: center; justify-content: center;
}
button:hover, .file-btn:hover { background: #262c3a; }
button.primary { background: var(--accent); border-color: var(--accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* Print button — red, card-printer friendly */
button.btn-print {
  background: #d9302a;
  border-color: #b9241e;
  color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.18);
}
button.btn-print:hover { background: #c1241f; border-color: #9d1814; }
button.btn-print:active { background: #a51f1a; border-color: #831310; }
button.btn-print:focus-visible { outline: 2px solid #ffbcb8; outline-offset: 1px; }
button.ghost { background: transparent; }
button.danger { background: var(--danger); border-color: var(--danger); color: white; }
button.danger:hover { background: #dc2626; }
button.seg { padding: 6px 14px; }
button.seg.active { background: var(--accent); border-color: var(--accent); }
button.small { padding: 6px 10px; font-size: 12px; }
.divider { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  height: calc(100vh - 56px);
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
}
.panel.right { border-right: none; border-left: 1px solid var(--border); }

.group {
  margin-bottom: 22px;
}
.group h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.field span {
  font-size: 12px;
  color: var(--muted);
}
.field input[type="text"],
.field input[type="number"],
.field textarea,
.field select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 9px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
}
.field input[type="color"] {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  height: 32px;
  padding: 2px;
  cursor: pointer;
}
.field input[type="file"] {
  font-size: 12px;
  color: var(--muted);
}

.field-row { display: flex; gap: 8px; }
.flex1 { flex: 1; }

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tool {
  padding: 10px 8px;
  font-size: 13px;
  background: var(--panel-2);
}
.tool:hover { background: var(--accent); border-color: var(--accent); }

/* Canvas area */
.canvas-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 30% 20%, rgba(59,130,246,.06), transparent 60%),
    radial-gradient(circle at 70% 80%, rgba(59,130,246,.04), transparent 60%),
    var(--bg);
  padding: 24px;
  overflow: auto;
  min-width: 0;
}
.canvas-frame {
  background: white;
  box-shadow: var(--shadow);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  /* Width/height set inline by JS to match scaled canvas. */
}
.canvas-wrap canvas { display: block; }
.hint {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}
kbd {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: monospace;
}

.muted { color: var(--muted); font-size: 12px; }

/* Layers list */
.layer-list {
  list-style: none;
  margin: 0; padding: 0;
  max-height: 240px;
  overflow-y: auto;
}
.layer-list li {
  padding: 7px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  margin-bottom: 4px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.layer-list li:hover { border-color: var(--accent); }
.layer-list li.active { border-color: var(--accent); background: rgba(59,130,246,0.12); }
.layer-list .layer-type {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a4258; }

/* Blazor-specific additions */
.badge {
  margin-left: 10px;
  padding: 3px 8px;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 4px;
  font-weight: 600;
}

#blazor-error-ui {
  background: #ef4444;
  color: white;
  bottom: 0;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
  display: none;
  left: 0;
  padding: 12px 16px;
  position: fixed;
  width: 100%;
  z-index: 1000;
  font-size: 13px;
}
#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 12px;
  top: 12px;
  font-size: 18px;
}

/* Loading screen while WASM boots */
.loading-progress {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  color: var(--muted);
  font-size: 14px;
}
.loading-progress .spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Card Comet additions ============ */

:root {
  --comet-purple: #8b5cf6;
  --comet-green:  #22c55e;
  --comet-cyan:   #22d3ee;
}

.brand h1 {
  background: linear-gradient(90deg, var(--comet-purple), var(--comet-cyan), var(--comet-green));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  font-weight: 700;
  letter-spacing: 0.3px;
  animation: comet-shift 6s linear infinite;
}
@keyframes comet-shift {
  0%   { background-position:   0% 50%; }
  100% { background-position: 200% 50%; }
}

.logo-comet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  background: radial-gradient(circle, rgba(139,92,246,0.18), transparent 70%);
  border-radius: 50%;
}

.badge-gradient {
  background: linear-gradient(90deg, rgba(139,92,246,0.18), rgba(34,197,94,0.18));
  color: #d8c8ff;
  border: 1px solid rgba(139,92,246,0.35);
}

/* Shape icons — bigger, purple, vertically aligned on the same x */
.tool.shape-square, .tool.shape-circle, .tool.shape-triangle, .tool.shape-code {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding-left: 12px;
  text-align: left;
}
/* Fixed-width slot guarantees icons sit on the same vertical baseline */
.icon-sq, .icon-cl, .icon-tr, .icon-code {
  display: inline-block;
  width: 24px; height: 24px;
  flex: 0 0 24px;
  vertical-align: middle;
}
.icon-sq, .icon-cl {
  background: var(--comet-purple);
  box-shadow: 0 0 0 2px rgba(139,92,246,0.25);
}
.icon-sq { border-radius: 3px; width: 22px; height: 22px; margin: 1px; }
.icon-cl { border-radius: 50%; }
.icon-tr {
  background: transparent;
  width: 24px; height: 24px;
  border: 0;
  /* CSS triangle inside the 24px slot using clip-path so the slot stays 24×24 */
  -webkit-clip-path: polygon(50% 6%, 96% 92%, 4% 92%);
          clip-path: polygon(50% 6%, 96% 92%, 4% 92%);
  background-color: var(--comet-purple);
  filter: drop-shadow(0 0 2px rgba(139,92,246,0.4));
}
.icon-code {
  width: 22px; height: 22px;
  margin: 1px;
  box-shadow: 0 0 0 2px rgba(139,92,246,0.25);
  border-radius: 3px;
  background:
    /* three finder corners (top-left, top-right, bottom-left) */
    linear-gradient(var(--comet-purple), var(--comet-purple)) 0 0/8px 8px no-repeat,
    linear-gradient(var(--comet-purple), var(--comet-purple)) 100% 0/8px 8px no-repeat,
    linear-gradient(var(--comet-purple), var(--comet-purple)) 0 100%/8px 8px no-repeat,
    /* inner dots for QR feel */
    radial-gradient(circle at 50% 50%, var(--comet-purple) 1.4px, transparent 1.6px) 12px 12px/4px 4px,
    radial-gradient(circle at 50% 50%, var(--comet-purple) 1.4px, transparent 1.6px) 14px 14px/4px 4px,
    /* bottom-right dot block */
    linear-gradient(var(--comet-purple), var(--comet-purple)) 100% 100%/4px 4px no-repeat,
    transparent;
}

.tool.shape-square:hover, .tool.shape-circle:hover, .tool.shape-triangle:hover, .tool.shape-code:hover {
  background: rgba(139,92,246,0.18);
  border-color: var(--comet-purple);
}

.tool.wide { grid-column: 1 / -1; }
.tool.secondary {
  background: rgba(139,92,246,0.12);
  border-color: rgba(139,92,246,0.35);
}
.tool.secondary:hover { background: rgba(139,92,246,0.25); border-color: var(--comet-purple); }

/* Strip / line tool */
.strip-tool {
  margin-top: 10px;
  padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.strip-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
  margin-bottom: 8px;
}
.strip-row input[type="color"] {
  width: 32px; height: 28px; padding: 0;
  background: transparent; border: 1px solid var(--border); border-radius: 4px;
  cursor: pointer;
}
.strip-row input[type="range"] {
  flex: 1; accent-color: var(--comet-purple);
}
.strip-row .width-val {
  width: 50px; text-align: right; color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* NSPK block */
.nspk {
  margin-top: 4px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(139,92,246,0.08), rgba(34,197,94,0.04));
  border: 1px dashed rgba(139,92,246,0.4);
  border-radius: 6px;
}
.nspk-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--comet-purple);
  margin-bottom: 8px;
  font-weight: 700;
}

/* Background-template grid */
.bg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.bg-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .12s, transform .12s;
}
.bg-tile:hover { border-color: var(--comet-purple); transform: translateY(-1px); }
.bg-tile.active { border-color: var(--comet-green); box-shadow: 0 0 0 2px rgba(34,197,94,0.25); }
.bg-tile img {
  width: 100%; aspect-ratio: 1027/648;
  object-fit: cover; display: block;
}
.bg-grid.vertical .bg-tile img {
  aspect-ratio: 648/1027;
  max-height: 180px;
  width: auto;
  margin: 0 auto;
}
.bg-grid.vertical .bg-tile { align-items: center; }
.bg-grid.vertical .bg-blank {
  aspect-ratio: 648/1027;
  max-height: 180px;
  width: auto;
  margin: 0 auto;
}
.bg-blank {
  width: 100%; aspect-ratio: 1027/648;
  display: flex; align-items: center; justify-content: center;
  background: repeating-conic-gradient(#1c2230 0% 25%, #262c3a 0% 50%) 0 0/14px 14px;
  color: var(--muted); font-size: 18px;
}
.bg-label {
  padding: 4px 6px;
  font-size: 10px;
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* Print styles (when @media print is triggered on this page accidentally) */
@media print {
  .topbar, .panel, .hint, #blazor-error-ui { display: none !important; }
  .canvas-wrap { padding: 0; background: white; }
  .canvas-frame { box-shadow: none; border-radius: 0; }
}

/* ----------------- Language toggle ----------------- */
.lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(34, 197, 94, 0.15));
    border: 1px solid rgba(168, 85, 247, 0.4);
    border-radius: 8px;
    color: var(--text, #e5e7eb);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all 0.18s ease;
}
.lang-toggle:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.3), rgba(34, 197, 94, 0.3));
    border-color: rgba(168, 85, 247, 0.7);
    transform: translateY(-1px);
}
.lang-toggle .lang-flag {
    font-size: 16px;
    line-height: 1;
}
.lang-toggle .lang-code {
    background: linear-gradient(90deg, #a855f7, #22c55e);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.lang-toggle .lang-caret {
    font-size: 11px;
    opacity: 0.7;
    margin-left: 2px;
}
.lang-picker {
    position: relative;
    display: inline-block;
}
.lang-menu-backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 90;
}
.lang-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: rgba(20, 22, 30, 0.98);
    border: 1px solid rgba(168, 85, 247, 0.5);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 100;
}
.lang-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text, #e5e7eb);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.lang-menu-item:hover {
    background: rgba(168, 85, 247, 0.18);
    border-color: rgba(168, 85, 247, 0.45);
}
.lang-menu-item.active {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(34, 197, 94, 0.25));
    border-color: rgba(168, 85, 247, 0.6);
}
.lang-menu-item .lang-flag {
    font-size: 16px;
    line-height: 1;
}
.lang-menu-item .lang-name {
    flex: 1;
}

/* Particle card-silhouette logo (canvas) */
.comet-logo {
  position: fixed;
  right: 24px;
  bottom: 72px;
  width: 224px;
  height: 224px;
  pointer-events: none;
  z-index: 30;
  display: block;
  background: transparent;
}
@media (max-width: 640px) {
  .comet-logo { width: 160px; height: 160px; right: 12px; bottom: 90px; }
}

/* Sensitive input with eye toggle */
.input-with-eye { position: relative; display: flex; }
.input-with-eye input { flex: 1; padding-right: 36px; letter-spacing: 0.04em; }
.input-with-eye .eye-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; padding: 4px 8px;
  color: #94a3b8; cursor: pointer; font-size: 14px; line-height: 1;
}
.input-with-eye .eye-btn:hover { color: #e5e7eb; background: rgba(255,255,255,0.04); border-radius: 4px; }
.field-sensitive input[type="password"] { font-family: ui-monospace, Menlo, monospace; }

/* Print dialog */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8, 12, 24, 0.55);
  backdrop-filter: blur(2px);
  z-index: 100;
}
.print-dialog {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 32px));
  background: #1a1f2e;
  color: #e5e7eb;
  border: 1px solid #2a3142;
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
  z-index: 101;
  overflow: hidden;
}
.print-dialog-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #2a3142;
}
.print-dialog-title { font-weight: 600; font-size: 14px; }
.icon-btn {
  background: transparent; border: 0; color: #94a3b8;
  font-size: 22px; line-height: 1; cursor: pointer; padding: 2px 8px;
}
.icon-btn:hover { color: #fff; }
.print-dialog-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.print-dialog .field { display: flex; flex-direction: column; gap: 6px; }
.print-dialog .field-label { font-size: 12px; color: #94a3b8; }
.print-dialog select {
  background: #0f1320; color: #e5e7eb;
  border: 1px solid #2a3142; border-radius: 6px;
  padding: 8px 10px; font-size: 13px;
}
.print-dialog .field-hint {
  font-size: 11.5px; color: #94a3b8; line-height: 1.4;
  background: rgba(255,255,255,0.03);
  border-left: 2px solid #d9302a; padding: 8px 10px; border-radius: 0 6px 6px 0;
}
.print-dialog .field-check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.print-dialog-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px; border-top: 1px solid #2a3142; background: #131724;
}

/* Beta-mode disclaimer — floats below the card mockup, no frame */
.canvas-wrap .app-disclaimer {
  margin-top: 56px;
  width: 100%;
  max-width: 640px;
  padding: 0 16px;
  text-align: center;
  font-size: 10.5px;
  line-height: 1.45;
  color: #9aa3b5;
  background: transparent;
  border: 0;
  letter-spacing: 0.01em;
  opacity: 0.85;
}

/* ============ Purple accents pass ============ */

/* Section headers in left/right panels glow purple-ish */
.group h2 {
  color: #b9a8ff;
  text-shadow: 0 0 8px rgba(139, 92, 246, 0.18);
}

/* Field micro-labels (small captions above inputs) */
.group label > span,
.strip-row > label,
.bg-label,
.print-dialog .field-label {
  color: #b9a8ff;
}

/* Input focus ring → purple */
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--comet-purple);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.25);
}

/* Range sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: linear-gradient(90deg, var(--comet-purple), #6d4ed8);
  border-radius: 4px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--comet-purple);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(139, 92, 246, 0.55);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--comet-purple);
  cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.45);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--comet-purple);
}

/* Generic .tool hover (text/image buttons) → keep blue for primary, but
   nudge the border with a soft purple glow on focus. */
.tool:focus-visible {
  outline: none;
  border-color: var(--comet-purple);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3);
}

/* Brand h1 already has a comet gradient — make sure underline is purple */
.brand h1::after {
  border-bottom-color: var(--comet-purple);
}

/* Checkbox accent (modern browsers) */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--comet-purple);
}
