/* ==============================================
   NanaStitcher — Dark Glassmorphism UI
   ============================================== */

/* --- Design Tokens --- */
:root {
  --bg:          #0f172a;
  --bg-subtle:   #1e293b;
  --surface:     rgba(30, 41, 59, 0.55);
  --surface-hi:  rgba(30, 41, 59, 0.8);
  --glass-blur:  16px;
  --glass-border: rgba(99, 102, 241, 0.12);
  --glass-border-hi: rgba(99, 102, 241, 0.25);
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --text-dim:    #64748b;
  --primary:     #6366f1;
  --primary-hi:  #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --danger:      #ef4444;
  --success:     #10b981;
  --shadow:      0 8px 32px rgba(0, 0, 0, 0.3);
  --transition:  0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background-image:
    radial-gradient(ellipse at 15% 85%, rgba(99,102,241,0.06) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(99,102,241,0.04) 0%, transparent 55%);
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Glass utility --- */
.glass {
  background: var(--surface);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 14px;
}

/* --- Drop zone active state --- */
#drop-zone.drag-over {
  border-color: var(--primary) !important;
  background: rgba(178, 178, 189, 0.08);
}

/* --- Timeline canvas --- */
#timeline-canvas {
  cursor: default;
  image-rendering: auto;
}

/* --- Range input theming --- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg-subtle);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 6px var(--primary-glow);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--bg);
}

/* --- Select styling --- */
select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* --- Toast animations --- */
.toast {
  pointer-events: auto;
  animation: toast-in 0.3s ease-out;
}
.toast.toast-out {
  animation: toast-out 0.3s ease-in forwards;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}

/* --- Spin animation --- */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.animate-spin {
  animation: spin 1s linear infinite;
}

/* --- Clip item in sidebar --- */
.clip-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
}
.clip-item:hover {
  background: rgba(99, 102, 241, 0.08);
}
.clip-item.active {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

/* --- Disabled button --- */
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Number input spinner hide --- */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
}

/* =============================================
   PREVIEW CANVAS — responsive fit
   ============================================= */

.preview-canvas-fit {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  width: auto;
  height: auto;
}

/* =============================================
   TIMELINE — responsive height
   ============================================= */

.timeline-bar {
  height: 100px;
}
.timeline-scroll {
  height: calc(100% - 32px);
}
@media (min-width: 768px) {
  .timeline-bar {
    height: 140px;
  }
  .timeline-scroll {
    height: calc(100% - 36px);
  }
}

/* =============================================
   MOBILE PANELS — slide overlays
   ============================================= */

/* z-index layering for panels */
#sidebar { z-index: 25; }
#props-panel { z-index: 25; }
#panel-backdrop { z-index: 20; }

/* When sidebar is open on mobile */
#sidebar.panel-open {
  transform: translateX(0) !important;
}

/* When props panel is open on mobile */
#props-panel.panel-open {
  transform: translateX(0) !important;
}

/* On mobile, panels need solid background since they're overlaid */
@media (max-width: 767px) {
  #sidebar,
  #props-panel {
    background: var(--surface-hi);
    top: 0;
    bottom: 0;
  }
}

/* On desktop, ensure panels are in normal flow */
@media (min-width: 768px) {
  #sidebar {
    transform: none !important;
  }
  #props-panel {
    transform: none !important;
  }
}

/* =============================================
   AUDIO WAVEFORM — timeline visualization
   ============================================= */

.audio-waveform-bar {
  fill: rgba(34, 211, 238, 0.4);
}

.audio-waveform-global {
  fill: rgba(168, 85, 247, 0.3);
}

/* License key input styling */
#export-license-key {
  letter-spacing: 0.05em;
}
#export-license-key::placeholder {
  letter-spacing: normal;
  font-style: italic;
}

/* Background color picker */
#bg-color {
  -webkit-appearance: none;
  appearance: none;
  border: none;
}
#bg-color::-webkit-color-swatch-wrapper {
  padding: 1px;
}
#bg-color::-webkit-color-swatch {
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 4px;
}
#bg-color::-moz-color-swatch {
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 4px;
}

/* License status indicator */
#license-status.license-valid {
  color: var(--success);
}
#license-status.license-invalid {
  color: var(--danger);
}

/* ── Source Protection ─────────────────────────────────── */

/* Allow text selection inside form controls despite body select-none */
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}
