/* ==========================================================================
   ViewMix Living Poster & Collage Studio (One-Pager Pro)
   Professional single-surface AR designer for wall posters, collages & plaques
   ========================================================================== */

:root {
  --poster-bg: #0b0f17;
  --poster-surface: #131a26;
  --poster-surface-elevated: #1a2333;
  --poster-border: rgba(255, 255, 255, 0.08);
  --poster-border-gold: rgba(212, 175, 55, 0.35);
  --poster-gold: #d4af37;
  --poster-gold-glow: rgba(212, 175, 55, 0.25);
  --poster-gold-text: #f5e7b2;
  --poster-text: #f8fafc;
  --poster-text-muted: #94a3b8;
  --poster-accent: #38bdf8;
  --poster-danger: #ef4444;
  --poster-success: #10b981;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Assistant', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--poster-bg);
  color: var(--poster-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* Header */
.poster-header {
  height: 64px;
  background: rgba(19, 26, 38, 0.95);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--poster-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.poster-brand-side {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-poster-back {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--poster-border);
  color: var(--poster-text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 16px;
  transition: all 0.2s ease;
}

.btn-poster-back:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.poster-brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #d4af37 0%, #aa8214 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 14px var(--poster-gold-glow);
}

.poster-brand-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
  background: linear-gradient(90deg, #ffffff 0%, #f5e7b2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.poster-brand-subtitle {
  font-size: 11px;
  color: var(--poster-gold);
  font-weight: 600;
  margin-top: -2px;
}

.poster-title-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--poster-border);
  border-radius: 8px;
  padding: 6px 12px;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  min-width: 200px;
  outline: none;
  transition: all 0.2s ease;
}

.poster-title-input:focus {
  border-color: var(--poster-gold);
  background: rgba(255, 255, 255, 0.08);
}

.poster-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-poster-action {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--poster-border);
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-poster-action:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-poster-primary {
  background: linear-gradient(135deg, #d4af37 0%, #b8860b 100%);
  border-color: rgba(212, 175, 55, 0.4);
  color: #0b0f17;
  font-weight: 700;
}

.btn-poster-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 14px var(--poster-gold-glow);
}

/* Workspace Layout */
.poster-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Center Stage */
.poster-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #162030 0%, #0b0f17 100%);
  position: relative;
  overflow: hidden;
  padding: 30px;
}

/* Stage Top Floating Toolbar */
.stage-floating-toolbar {
  position: absolute;
  top: 16px;
  display: flex;
  align-items: center;
  background: rgba(19, 26, 38, 0.85);
  backdrop-filter: blur(12px);
  padding: 4px 8px;
  border-radius: 30px;
  border: 1px solid var(--poster-border);
  gap: 6px;
  z-index: 50;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.stage-tool-btn {
  background: transparent;
  border: none;
  color: var(--poster-text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.stage-tool-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.stage-tool-btn.active {
  background: var(--poster-gold);
  color: #0b0f17;
  font-weight: 700;
}

.stage-divider {
  width: 1px;
  height: 20px;
  background: var(--poster-border);
  margin: 0 4px;
}

/* Canvas Viewport & Scaling Container */
.canvas-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Room Mockup Environment (Wall / Desk) */
.room-mockup-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 1;
}

.room-mockup-layer.active {
  opacity: 1;
}

.mockup-wall {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
}

.mockup-wall::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(180deg, #47321b 0%, #291a0b 100%);
  border-top: 14px solid #634729;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
}

/* The Core Scalable Canvas */
.poster-canvas {
  position: relative;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 2px 10px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  z-index: 10;
}

/* Outer physical frame simulation */
.poster-canvas.frame-wood {
  border: 16px solid #4a3319;
  box-shadow: inset 0 0 16px rgba(0,0,0,0.4), 0 24px 70px rgba(0,0,0,0.65);
}

.poster-canvas.frame-black-gallery {
  border: 14px solid #111827;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.3), 0 24px 70px rgba(0,0,0,0.65);
}

.poster-canvas.frame-gold-gallery {
  border: 14px solid #d4af37;
  box-shadow: inset 0 0 12px rgba(0,0,0,0.35), 0 24px 70px rgba(212,175,55,0.25);
}

.poster-canvas.frame-white-gallery {
  border: 14px solid #f8fafc;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.15), 0 24px 70px rgba(0,0,0,0.5);
}

/* Canvas Items (Photos, Texts, Stickers) */
.canvas-item {
  position: absolute;
  cursor: move;
  user-select: none;
  touch-action: none;
}

.canvas-item.is-selected {
  outline: 2px solid var(--poster-gold);
  box-shadow: 0 0 0 4px var(--poster-gold-glow);
}

/* Multi-select marquee box */
.selection-marquee {
  position: absolute;
  border: 1px dashed var(--poster-accent);
  background: rgba(56, 189, 248, 0.15);
  pointer-events: none;
  z-index: 999;
}

/* Resize Handles */
.resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border: 2px solid var(--poster-gold);
  border-radius: 50%;
  display: none;
  z-index: 20;
}

.canvas-item.is-selected .resize-handle {
  display: block;
}

.resize-handle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.resize-handle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.resize-handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.resize-handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }

/* Rotate Handle */
.rotate-handle {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 16px;
  background: var(--poster-gold);
  border-radius: 50%;
  display: none;
  cursor: grab;
  z-index: 20;
}

.rotate-handle::after {
  content: '';
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 12px;
  background: var(--poster-gold);
}

.canvas-item.is-selected .rotate-handle {
  display: block;
}

/* Photo Slots & Frames inside Canvas */
.canvas-photo-slot {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e293b;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.canvas-photo-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.canvas-photo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  padding: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  width: 100%;
  height: 100%;
  background: rgba(30, 41, 59, 0.7);
}

/* Frames within Canvas */
.frame-gold-border {
  border: 4px solid #d4af37 !important;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.4) !important;
}

.frame-polaroid {
  background: #ffffff !important;
  padding: 8px 8px 30px 8px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25) !important;
  border-radius: 2px !important;
}

.frame-vintage-wood {
  border: 6px solid #4a3319 !important;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.4) !important;
}

.frame-minimal-white {
  border: 4px solid #ffffff !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2) !important;
}

.frame-shadow-float {
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45) !important;
}

.frame-circle {
  border-radius: 50% !important;
  overflow: hidden !important;
}

/* AR Badge on Canvas Items */
.item-ar-pill {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(11, 15, 23, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--poster-gold);
  border-radius: 20px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--poster-gold-text);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Text Item */
.canvas-text-item {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Sticker Item */
.canvas-sticker-item {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-sticker-item img,
.canvas-sticker-item svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Contextual Selection Action Bar */
.context-selection-bar {
  position: absolute;
  bottom: 24px;
  display: none;
  align-items: center;
  background: rgba(19, 26, 38, 0.95);
  backdrop-filter: blur(14px);
  border: 1px solid var(--poster-border);
  padding: 6px 12px;
  border-radius: 30px;
  gap: 8px;
  z-index: 60;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.context-selection-bar.visible {
  display: flex;
}

.btn-context-action {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--poster-border);
  color: #fff;
  border-radius: 20px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-context-action:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-context-danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-context-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* Sidebar Studio Panel */
.poster-sidebar {
  width: 440px;
  background: var(--poster-surface);
  border-right: 1px solid var(--poster-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

/* Sidebar Tab Nav */
.sidebar-tabs-nav {
  display: flex;
  background: rgba(11, 15, 23, 0.7);
  border-bottom: 1px solid var(--poster-border);
  overflow-x: auto;
  scrollbar-width: none;
}

.sidebar-tabs-nav::-webkit-scrollbar {
  display: none;
}

.sidebar-tab-btn {
  flex: 1;
  padding: 12px 6px;
  background: transparent;
  border: none;
  color: var(--poster-text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-width: 60px;
}

.sidebar-tab-btn:hover {
  color: #fff;
}

.sidebar-tab-btn.active {
  color: var(--poster-gold-text);
  border-bottom-color: var(--poster-gold);
  background: rgba(212, 175, 55, 0.08);
}

.sidebar-tab-btn .tab-icon {
  font-size: 17px;
}

/* Tab Panes */
.sidebar-tab-panes {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.tab-pane.active {
  display: flex;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--poster-gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Format & Dims Grid */
.format-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.format-card-option {
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid var(--poster-border);
  border-radius: 10px;
  padding: 12px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.format-card-option:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
}

.format-card-option.active {
  border-color: var(--poster-gold);
  background: rgba(212, 175, 55, 0.12);
  box-shadow: 0 4px 12px var(--poster-gold-glow);
}

.format-card-icon {
  font-size: 24px;
}

.format-card-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.format-card-dims {
  font-size: 11px;
  color: var(--poster-text-muted);
}

/* Layouts / Collage Templates Grid */
.layout-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.layout-card-option {
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid var(--poster-border);
  border-radius: 8px;
  padding: 10px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.layout-card-option:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--poster-gold);
}

.layout-card-option.active {
  border-color: var(--poster-gold);
  background: rgba(212, 175, 55, 0.15);
}

.layout-thumb-preview {
  width: 50px;
  height: 50px;
  background: #1e293b;
  border-radius: 4px;
  display: grid;
  padding: 3px;
  gap: 2px;
}

.layout-thumb-box {
  background: rgba(212, 175, 55, 0.4);
  border-radius: 2px;
}

.layout-card-name {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}

/* Media Tray & Upload */
.media-tray-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px 2px;
}

.media-tray-item {
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  background: #1e293b;
  border: 1px solid var(--poster-border);
  position: relative;
  cursor: grab;
  transition: all 0.2s ease;
}

.media-tray-item:hover {
  border-color: var(--poster-gold);
  transform: scale(1.04);
}

.media-tray-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Stickers Picker Grid */
.stickers-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
}

.sticker-option-card {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--poster-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 6px;
  transition: all 0.2s ease;
}

.sticker-option-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--poster-gold);
  transform: scale(1.08);
}

.sticker-option-card img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Color & Texture Swatches */
.swatches-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.swatch-color-btn {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: all 0.2s ease;
}

.swatch-color-btn:hover {
  transform: scale(1.15);
}

.swatch-color-btn.active {
  border-color: var(--poster-gold);
  box-shadow: 0 0 0 3px var(--poster-gold-glow);
}

/* Footer Info Bar */
.poster-footer-bar {
  background: rgba(19, 26, 38, 0.95);
  border-top: 1px solid var(--poster-border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.poster-footer-dims {
  font-size: 12px;
  color: var(--poster-text-muted);
}

.btn-export-pdf-full {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  transition: all 0.2s ease;
}

.btn-export-pdf-full:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.45);
}

/* AR Video Link Modal */
.poster-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.poster-modal-card {
  width: 90%;
  max-width: 500px;
  background: var(--poster-surface);
  border: 1px solid var(--poster-border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.poster-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--poster-border);
  padding-bottom: 12px;
}

.poster-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--poster-gold);
}

/* Toast */
.poster-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  border: 1px solid var(--poster-gold);
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.poster-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
