/* ═══════════════════════════════════════════════════════════════════════════
   OmniVision — Premium Dark UI Stylesheet
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --bg:          #0a0f1e;
  --surface:     #111827;
  --surface2:    #1a2236;
  --surface3:    #212d42;
  --border:      rgba(255,255,255,0.07);
  --border-glow: rgba(99,102,241,0.4);

  --text:        #f0f4ff;
  --text-muted:  #8899aa;
  --text-dim:    #4b5a6e;

  --accent:      #6366f1;       /* indigo */
  --accent2:     #8b5cf6;       /* violet */
  --accent-glow: rgba(99,102,241,0.35);

  --green:       #22c55e;
  --red:         #ef4444;

  --radius:      14px;
  --radius-sm:   8px;
  --shadow:      0 8px 32px rgba(0,0,0,0.5);
  --transition:  0.2s ease;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.app-header {
  height: 60px;
  background: linear-gradient(135deg, #0d1327 0%, #111827 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  flex-shrink: 0;
}
.header-inner { display: flex; align-items: center; gap: 20px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 22px; }
.logo-text {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-sub { color: var(--text-muted); font-size: 13px; }

/* ── Main Layout ──────────────────────────────────────────────────────────── */
.app-main {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 16px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* ── Action Cards ─────────────────────────────────────────────────────────── */
.action-list { display: flex; flex-direction: column; gap: 8px; }

.action-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.action-card:hover {
  border-color: rgba(99,102,241,0.4);
  background: var(--surface3);
}
.action-card.active {
  border-color: var(--accent);
  background: rgba(99,102,241,0.12);
  box-shadow: 0 0 0 1px var(--accent-glow);
}
.action-icon { font-size: 20px; flex-shrink: 0; }
.action-name { font-weight: 600; font-size: 13px; }
.action-desc { font-size: 11px; color: var(--text-muted); }

/* ── Controls ─────────────────────────────────────────────────────────────── */
.controls { display: flex; flex-direction: column; gap: 14px; }
.control-group { display: flex; flex-direction: column; gap: 6px; }
.ctrl-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* Range slider */
.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--surface3);
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: 2px solid var(--bg);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
}
.slider-val { font-size: 11px; color: var(--text-muted); text-align: right; }

/* Color swatches */
.color-row { display: flex; gap: 8px; }
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}
.color-swatch.active { border-color: white; box-shadow: 0 0 0 2px var(--accent); }

/* Radio pills */
.radio-group { display: flex; flex-wrap: wrap; gap: 6px; }
.radio-pill {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.radio-pill.active {
  background: rgba(99,102,241,0.2);
  border-color: var(--accent);
  color: #a5b4fc;
  font-weight: 600;
}

/* Color input */
.color-input {
  width: 48px; height: 36px;
  border: none; border-radius: var(--radius-sm);
  background: var(--surface3);
  cursor: pointer;
  padding: 2px;
}

/* Mini drop zone for bg image */
.mini-drop {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}
.mini-drop:hover { border-color: var(--accent); color: var(--text); }

.mini-preview {
  width: 100%;
  max-height: 80px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  margin-top: 6px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: white;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 16px var(--accent-glow);
  margin-top: auto;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99,102,241,0.5);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}
.btn-secondary:hover { border-color: var(--accent); background: var(--surface3); }

/* ── Status Bar ───────────────────────────────────────────────────────────── */
.status-bar {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  min-height: 36px;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  word-break: break-word;
}
.status-bar.success { color: var(--green); border-color: rgba(34,197,94,0.3); }
.status-bar.error { color: var(--red); border-color: rgba(239,68,68,0.3); }

/* ── Workspace ────────────────────────────────────────────────────────────── */
.workspace {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Drop zone */
.drop-zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border);
  margin: 20px;
  border-radius: var(--radius);
  transition: var(--transition);
  position: relative;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(99,102,241,0.05);
}
.drop-zone-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.drop-icon { font-size: 48px; opacity: 0.4; }
.drop-title { font-size: 18px; font-weight: 600; color: var(--text-muted); }
.drop-sub { font-size: 13px; color: var(--text-dim); }
.btn-upload {
  margin-top: 8px;
  padding: 10px 24px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: rgba(99,102,241,0.1);
  color: #a5b4fc;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
}
.btn-upload:hover { background: rgba(99,102,241,0.25); }

/* Canvas wrap */
.canvas-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px;
  gap: 10px;
}

/* Toolbar */
.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  width: fit-content;
}
.tool-btn {
  width: 34px; height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.tool-btn:hover { background: var(--surface2); color: var(--text); }
.tool-btn.active { background: rgba(99,102,241,0.2); border-color: var(--accent); color: #a5b4fc; }
.divider { width: 1px; height: 22px; background: var(--border); }

/* Canvas stack */
.canvas-stack {
  flex: 1;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: #08111f;
  display: flex;
  align-items: center;
  justify-content: center;
}
.canvas-stack canvas {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
}
#canvas-mask { cursor: crosshair; }

/* ── Result Panel ─────────────────────────────────────────────────────────── */
.result-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 16px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.result-placeholder {
  flex: 0 0 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13px;
  background: var(--surface2);
}

.result-img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: contain;
  background: repeating-conic-gradient(#1a2236 0% 25%, #111827 0% 50%) 0 0 / 16px 16px;
}

.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Gallery */
.gallery { display: flex; flex-direction: column; gap: 10px; }
.gallery-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
.gallery-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gallery-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.gallery-item img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: contain;
  background: repeating-conic-gradient(#1a2236 0% 25%, #111827 0% 50%) 0 0 / 12px 12px;
}
.gallery-item span { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Loading overlay ──────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,15,30,0.85);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 1000;
}
.spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(99,102,241,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p { color: var(--text-muted); font-size: 15px; }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
