/* Canvas Creator V2 - Compact Layout
   Liquid Glass theme with sticky preview
*/

/* ═══════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════ */

.canvas-creator-v2 {
  --cv2-bg: #f8fafc;
  --cv2-surface: rgba(255, 255, 255, 0.95);
  --cv2-border: #e2e8f0;
  --cv2-border-subtle: #f1f5f9;
  --cv2-text: #1e293b;
  --cv2-text-muted: #64748b;
  --cv2-accent: #3b82f6;
  --cv2-radius: 0.75rem;
}

.dark .canvas-creator-v2 {
  --cv2-bg: #111827;
  --cv2-surface: rgba(31, 41, 55, 0.95);
  --cv2-border: #374151;
  --cv2-border-subtle: #1f2937;
  --cv2-text: #f9fafb;
  --cv2-text-muted: #9ca3af;
}

.cv2-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 2rem;
  min-height: calc(100vh - 180px);
  align-items: start;
}

/* ═══════════════════════════════════════════════════════════
   TOOLS PANEL (LEFT)
   ═══════════════════════════════════════════════════════════ */

.cv2-tools {
  background: var(--cv2-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--cv2-radius);
  border: 1px solid var(--cv2-border-subtle);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Unified card header style */
.cv2-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--cv2-border-subtle);
  background: var(--cv2-bg);
}

.cv2-card-header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cv2-text-muted);
}

.cv2-card-header-title svg {
  color: var(--cv2-accent);
}

.cv2-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.cv2-toggle-track {
  width: 2rem;
  height: 1rem;
  background: var(--cv2-border);
  border-radius: 0.5rem;
  position: relative;
  transition: background 0.2s;
}

.cv2-toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.75rem;
  height: 0.75rem;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.peer:checked ~ .cv2-toggle-track::after {
  transform: translateX(1rem);
}

.cv2-toggle-label {
  font-size: 0.6875rem;
  color: var(--cv2-text-muted);
}

/* ═══════════════════════════════════════════════════════════
   COLLAPSIBLE SECTIONS
   ═══════════════════════════════════════════════════════════ */

.cv2-section {
  border-bottom: 1px solid var(--cv2-border-subtle);
}

.cv2-section:last-of-type {
  border-bottom: none;
}

.cv2-section-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cv2-text-muted);
  background: var(--cv2-bg);
  transition: background 0.15s;
  list-style: none;
}

.cv2-section-trigger::-webkit-details-marker {
  display: none;
}

.cv2-section-trigger:hover {
  background: var(--cv2-border-subtle);
}

.cv2-section-trigger svg:first-child {
  color: var(--cv2-accent);
}

.cv2-chevron {
  width: 1rem;
  height: 1rem;
  margin-left: auto;
  transition: transform 0.2s;
}

.cv2-section[open] .cv2-chevron {
  transform: rotate(180deg);
}

.cv2-section-content {
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

/* ═══════════════════════════════════════════════════════════
   FORM FIELDS (COMPACT)
   ═══════════════════════════════════════════════════════════ */

.cv2-row {
  display: flex;
  gap: 0.5rem;
}

.cv2-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cv2-field-grow {
  flex: 1;
}

.cv2-field-sm {
  width: 4rem;
}

.cv2-field label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--cv2-text-muted);
}

.cv2-input {
  padding: 0.5rem 0.625rem;
  background: var(--cv2-bg);
  border: 1px solid var(--cv2-border);
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  color: var(--cv2-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cv2-input:focus {
  outline: none;
  border-color: var(--cv2-accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.cv2-input::placeholder {
  color: var(--cv2-text-muted);
  opacity: 0.6;
}

/* ═══════════════════════════════════════════════════════════
   COLOR PRESETS (COMPACT GRID)
   ═══════════════════════════════════════════════════════════ */

.cv2-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.375rem;
}

.cv2-preset {
  position: relative;
  aspect-ratio: 1;
  border-radius: 0.375rem;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}

.cv2-preset:hover {
  transform: scale(1.1);
  border-color: var(--cv2-accent);
}

.cv2-preset span:first-child {
  position: absolute;
  inset: 0;
}

.cv2-preset span:last-child {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
}

/* ═══════════════════════════════════════════════════════════
   COLOR PICKERS (INLINE)
   ═══════════════════════════════════════════════════════════ */

.cv2-color-row {
  display: flex;
  gap: 0.75rem;
}

.cv2-color-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cv2-color-field label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--cv2-text-muted);
}

.cv2-color-input {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem;
  background: var(--cv2-bg);
  border: 1px solid var(--cv2-border);
  border-radius: 0.375rem;
}

.cv2-color-picker {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  flex-shrink: 0;
}

.cv2-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.cv2-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 0.25rem;
}

.cv2-color-text {
  flex: 1;
  min-width: 0;
  padding: 0.25rem 0.375rem;
  background: transparent;
  border: none;
  font-size: 0.6875rem;
  font-family: ui-monospace, monospace;
  color: var(--cv2-text);
}

.cv2-color-text:focus {
  outline: none;
}

/* ═══════════════════════════════════════════════════════════
   GRADIENT TOGGLE
   ═══════════════════════════════════════════════════════════ */

.cv2-gradient-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--cv2-text-muted);
  cursor: pointer;
  flex-wrap: wrap;
}

.cv2-mini-toggle {
  width: 1.5rem;
  height: 0.875rem;
  background: var(--cv2-border);
  border-radius: 0.5rem;
  position: relative;
  transition: background 0.2s;
}

.cv2-mini-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.625rem;
  height: 0.625rem;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.peer:checked ~ .cv2-mini-toggle::after {
  transform: translateX(0.625rem);
}

.cv2-gradient-builder {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--cv2-text-muted);
}

.cv2-gradient-stop {
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: 1px solid var(--cv2-border);
  border-radius: 0.25rem;
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════
   RICH TEXT EDITOR
   ═══════════════════════════════════════════════════════════ */

.cv2-rich-editor {
  min-height: 120px;
  border-radius: 0.375rem;
  overflow: hidden;
}

.cv2-rich-editor trix-editor {
  min-height: 100px;
  font-size: 0.8125rem;
  padding: 0.5rem;
  background: var(--cv2-bg);
  border: 1px solid var(--cv2-border);
  border-radius: 0.375rem;
}

/* ═══════════════════════════════════════════════════════════
   TOOLS FOOTER
   ═══════════════════════════════════════════════════════════ */

.cv2-tools-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--cv2-border-subtle);
  background: var(--cv2-bg);
  margin-top: auto;
}

.cv2-save-btn {
  width: 100%;
  padding: 0.625rem 1rem;
  background: linear-gradient(135deg, var(--cv2-accent), #6366f1);
  color: white;
  font-weight: 600;
  font-size: 0.8125rem;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.cv2-save-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* ═══════════════════════════════════════════════════════════
   PREVIEW AREA (RIGHT - STICKY)
   ═══════════════════════════════════════════════════════════ */

.cv2-preview-area {
  position: relative;
}

.cv2-preview-sticky {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cv2-preview-label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--cv2-text-muted);
  text-align: center;
}

/* Preview card wrapper */
.cv2-preview-card {
  background: var(--cv2-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--cv2-radius);
  border: 1px solid var(--cv2-border-subtle);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.cv2-preview-container {
  display: flex;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 30% 30%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(139, 92, 246, 0.04) 0%, transparent 50%),
    var(--cv2-bg);
}

.cv2-preview-container .liquid-glass-card {
  max-width: 380px;
  width: 100%;
  transition: transform 0.3s ease;
}

/* ═══════════════════════════════════════════════════════════
   SECTION SHORTCUTS (WITH LABELS)
   ═══════════════════════════════════════════════════════════ */

.cv2-section-shortcuts {
  background: var(--cv2-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--cv2-radius);
  border: 1px solid var(--cv2-border-subtle);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

/* Header uses unified card header style */
.cv2-shortcuts-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cv2-text-muted);
  background: var(--cv2-bg);
  border-bottom: 1px solid var(--cv2-border-subtle);
}

.cv2-shortcuts-header svg {
  color: var(--cv2-accent);
}

.cv2-shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  padding: 0.75rem;
}

.cv2-shortcut {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.625rem 0.375rem;
  background: var(--cv2-bg);
  border: 1px solid var(--cv2-border);
  border-radius: 0.5rem;
  transition: all 0.15s;
  text-decoration: none;
}

.cv2-shortcut:hover {
  border-color: var(--cv2-accent);
  background: rgba(59, 130, 246, 0.05);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.cv2-shortcut-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.cv2-shortcut-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--cv2-text-muted);
  text-align: center;
  line-height: 1.2;
}

.cv2-shortcut:hover .cv2-shortcut-label {
  color: var(--cv2-accent);
}

.cv2-shortcut-count {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.25rem;
  background: var(--cv2-accent);
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  border-radius: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .cv2-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .cv2-preview-sticky {
    position: relative;
    top: 0;
  }

  .cv2-presets {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (max-width: 480px) {
  .cv2-presets {
    grid-template-columns: repeat(4, 1fr);
  }

  .cv2-color-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .cv2-shortcuts-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ═══════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════ */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cv2-tools {
  animation: fadeInUp 0.3s ease-out;
}

.cv2-preview-sticky {
  animation: fadeInUp 0.3s ease-out 0.1s backwards;
}
