/* =========================================
   VARIABLES & GLOBALS
========================================= */
:root {
  --bg-color: #050505;
  --bg-panel: #1A1A1A;
  --primary: #FF6B9E;
  --text-dark: #FFFFFF;
  --text-muted: #A4B0BE;
  --border: #333333;
  --danger: #FF4757;
  
  --radius: 12px;
  --font-base: 'Nunito', sans-serif;
  --font-title: 'Pacifico', cursive;
  
  --canvas-width: 816px;
  --canvas-height: 1056px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-color);
  color: var(--text-dark);
  height: 100vh;
  overflow: hidden;
}

button {
  cursor: pointer;
  font-family: var(--font-base);
  border: none;
  border-radius: var(--radius);
  transition: all 0.2s ease;
  outline: none;
}

/* =========================================
   LAYOUT
========================================= */
.app-layout {
  display: flex; /* hidden initially by splash if needed, but splash is fixed */
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* =========================================
   SPLASH SCREEN
========================================= */
#splash-screen {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: radial-gradient(circle at center, #1E1E1E 0%, #050505 100%);
  z-index: 100000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 1s ease-out, visibility 1s;
}

#splash-screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.splash-title {
  font-family: var(--font-title); /* 'Pacifico' as requested */
  font-size: 5rem;
  color: var(--primary);
  text-shadow: 0 0 30px rgba(255, 107, 158, 0.6);
  animation: pulseTitle 2.5s infinite;
  text-align: center;
  padding: 0 20px;
  line-height: 1.2;
}

.splash-subtitle {
  font-family: var(--font-base);
  font-size: 1.8rem;
  font-weight: 800;
  color: white;
  margin-bottom: 20px; 
  animation: floatSubtitle 3s infinite alternate ease-in-out;
}

@keyframes pulseTitle {
  0% { transform: scale(1); text-shadow: 0 0 20px rgba(255,107,158,0.5); }
  50% { transform: scale(1.05); text-shadow: 0 0 50px rgba(255,107,158,1); }
  100% { transform: scale(1); text-shadow: 0 0 20px rgba(255,107,158,0.5); }
}

@keyframes floatSubtitle {
  0% { 
    opacity: 0.7; 
    letter-spacing: 2px; 
    text-shadow: 0 0 10px rgba(155, 114, 255, 0.3); 
    transform: translateY(0); 
  }
  100% { 
    opacity: 1; 
    letter-spacing: 3px; 
    text-shadow: 0 0 20px rgba(155, 114, 255, 0.8), 0 0 10px rgba(255, 255, 255, 0.6); 
    transform: translateY(-2px); 
  }
}

@keyframes floatSplash {
  0% { transform: translate(0, 0) scale(0.8); opacity: 0; }
  50% { opacity: 1; transform: translate(0, -60px) scale(1.5); }
  100% { transform: translate(0, -120px) scale(0.8); opacity: 0; }
}

/* =========================================
   SIDEBAR (Left Column)
========================================= */
.sidebar-panel {
  width: 280px;
  background-color: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto; /* Allow scrolling within sidebar if screen is short */
  flex-shrink: 0;
}

.tools-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.tool-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0;
  background-color: #2A2A2A;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  gap: 5px;
  border: 2px solid transparent;
}
.tool-btn span {
  display: block;
  width: 52px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
.tool-btn:hover { background-color: #3A3A3A; color: var(--text-dark); }
.tool-btn.active {
  background-color: rgba(255,107,158,0.15);
  color: var(--primary);
  border-color: var(--primary);
}
.tool-btn.tool-magic-pop {
  animation: toolMagicPop 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes toolMagicPop {
  0%   { transform: scale(1); box-shadow: none; }
  30%  { transform: scale(1.25); box-shadow: 0 0 18px 4px var(--tool-glow, rgba(255,107,158,0.5)); }
  65%  { transform: scale(0.92); }
  100% { transform: scale(1); box-shadow: none; }
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.control-section label {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

input[type=range] { width: 100%; accent-color: var(--primary); }

.brush-preview-small {
  width: 100%;
  height: 30px;
  background-color: #2A2A2A;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  margin-top: 5px;
}
.blob { background-color: var(--primary); border-radius: 50%; }

/* =========================================
   CUSTOM COLOR PICKER
========================================= */
.current-color-box {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  border: 3px solid #FFF;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  transition: transform 0.1s;
}
.current-color-box:hover { transform: scale(1.02); }

.advanced-picker {
  display: flex; /* can be hidden if we wanted a popup, but design says "expands" */
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  background: #2A2A2A;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.picker-layout {
  display: flex;
  gap: 10px;
  height: 120px;
}

.sl-box-container {
  flex: 1;
  position: relative;
  background: red; /* base hue applied via js */
  border-radius: 6px;
  overflow: hidden;
  cursor: crosshair;
}
.sl-box-container::before { /* white gradient */
  content: ''; position: absolute; top:0; left:0; width:100%; height:100%;
  background: linear-gradient(to right, #FFF, transparent);
  pointer-events: none;
}
.sl-box-container::after { /* black gradient */
  content: ''; position: absolute; top:0; left:0; width:100%; height:100%;
  background: linear-gradient(to bottom, transparent, #000);
  pointer-events: none;
}
.sl-pointer {
  position: absolute;
  width: 12px; height: 12px;
  border: 2px solid white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
  top: 0; left: 100%; /* default pure red */
}

.hue-bar-container {
  width: 25px;
  background: linear-gradient(to bottom, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
  border-radius: 6px;
  position: relative;
  cursor: pointer;
}
.hue-pointer {
  position: absolute;
  width: 100%; height: 8px;
  background: transparent;
  border: 2px solid white;
  border-radius: 4px;
  transform: translateY(-50%);
  pointer-events: none;
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
  top: 0%;
}

.color-details-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.new-color-preview {
  width: 30px; height: 30px;
  border-radius: 6px;
  background-color: #FF3B30;
  border: 1px solid var(--border);
}
.hex-container {
  flex: 1;
  display: flex;
  align-items: center;
  background: #1E1E1E;
  padding: 5px 10px;
  border-radius: 6px;
  gap: 5px;
  border: 1px solid var(--border);
}
.hex-container span { font-weight: 700; font-size: 0.8rem; color: var(--text-muted); }
.hex-input {
  background: transparent; border: none; color: white;
  font-family: monospace; font-size: 1rem; width: 60px; outline: none;
}

.icon-btn {
  background: none; border: none; font-size: 1.2rem;
  color: var(--text-muted); transition: 0.2s;
}
.icon-btn:hover { color: white; transform: scale(1.1); }

/* Reference Colors Grid */
.reference-colors-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  position: relative;
}
.ref-color {
  width: 100%; aspect-ratio: 1; border-radius: 4px; cursor: pointer;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: visible;
}
.ref-color:hover { transform: scale(1.15); box-shadow: 0 0 8px rgba(255,255,255,0.3); }
.ref-color.color-selected {
  animation: colorSelectPop 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes colorSelectPop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.45); box-shadow: 0 0 20px var(--magic-color, #fff), 0 0 40px var(--magic-color, #fff); }
  60%  { transform: scale(0.9); }
  100% { transform: scale(1.0); }
}

/* Magic Sparkle Particles */
.magic-particle {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 99999;
  animation: magicFly var(--fly-dur, 0.7s) ease-out forwards;
  transform-origin: center;
}
@keyframes magicFly {
  0%   { transform: translate(0,0) scale(1) rotate(0deg);   opacity: 1; }
  80%  { opacity: 0.7; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0) rotate(var(--tr)); opacity: 0; }
}

/* Star-shaped particle variation */
.magic-particle.star {
  width: 0; height: 0;
  background: transparent !important;
  border-radius: 0;
  box-shadow: none;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* Ripple ring on color swatch */
.magic-ripple {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 99998;
  border: 3px solid var(--ripple-color, #fff);
  animation: magicRipple 0.6s ease-out forwards;
}
@keyframes magicRipple {
  0%   { transform: translate(-50%,-50%) scale(0.3); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(3.5);   opacity: 0; }
}

/* Active color box glow burst */
.current-color-box.magic-glow {
  animation: colorBoxGlow 0.6s ease-out;
}
@keyframes colorBoxGlow {
  0%   { box-shadow: 0 4px 15px rgba(0,0,0,0.5); }
  40%  { box-shadow: 0 0 0 6px var(--glow-color, rgba(255,255,255,0.6)), 0 0 30px var(--glow-color, rgba(255,255,255,0.4)); }
  100% { box-shadow: 0 4px 15px rgba(0,0,0,0.5); }
}

/* =========================================
   MAIN PANEL (Right Column)
========================================= */
.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-width: 0; /* Prevent flex blowout pushing scrollbars offscreen */
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo { font-family: var(--font-title); color: var(--primary); font-size: 1.8rem; font-weight: 400; }
.header-nav { display: flex; align-items: center; gap: 1rem; flex: 1; margin-left: 2rem; }
.nav-btn { background: #2A2A2A; color: white; font-weight: 700; padding: 0.5rem 1rem; }
.nav-btn:hover:not(:disabled) { background: #3A3A3A; }
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.danger-text { color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); background: transparent; }
.danger-text:hover { background: rgba(255,71,87,0.1); }
.page-indicator { font-weight: 800; color: var(--text-muted); }

/* Language Selector */
.lang-select {
  margin-left: auto;
  background: #2A2A2A;
  color: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.7rem;
  font-family: var(--font-base);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
}
.lang-select:hover  { border-color: var(--primary); background: #3A3A3A; }
.lang-select:focus  { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,107,158,0.25); }
.lang-select option { background: #1A1A1A; color: #fff; }

/* Workspace & Zoom */
.workspace-area {
  flex: 1;
  position: relative;
  overflow: hidden; /* KEEP hidden: absolute buttons stay static! */
  background: radial-gradient(circle at center, #1E1E1E 0%, #050505 100%);
  display: flex;
  min-width: 0; min-height: 0; /* Prevent flex blowout */
}

.scroll-container {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: auto; /* Scrollbars appear HERE! */
  text-align: center;
  min-width: 0; min-height: 0;
}
.scroll-container::before {
  content: "";
  display: inline-block;
  height: 100%;
  vertical-align: middle;
}

.zoom-controls {
  position: absolute;
  top: 20px; right: 20px;
  background: var(--bg-panel);
  padding: 5px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
.zoom-controls .icon-btn { font-size: 1rem; background: #2A2A2A; width: 32px; height: 32px; border-radius: 4px; }
.zoom-controls .icon-btn:hover { background: #444; }

.canvas-viewport {
  display: inline-block;
  vertical-align: middle;
  text-align: left;
  position: relative;
  /* Resized by Javascript */
  width: var(--canvas-width);
  height: var(--canvas-height);
  transition: width 0.1s, height 0.1s;
}

.canvas-wrapper {
  position: absolute;
  top: 0; left: 0;
  width: var(--canvas-width);
  height: var(--canvas-height);
  background: white;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
  /* Origin top left avoids cutoff inside auto scroll */
  transform-origin: top left;
  transition: transform 0.1s ease-out;
}

.canvas-wrapper img, .canvas-wrapper canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: block; pointer-events: none; /* Pointer evs handled by wrapper or js mapping */
}
#svg-image { object-fit: cover; }
#drawing-canvas { pointer-events: auto; mix-blend-mode: multiply; }

/* Footer */
.main-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.doll-name { font-family: var(--font-title); color: #FFF; font-size: 1.5rem; }
.doll-quote { font-style: italic; color: var(--text-muted); font-size: 0.9rem; }

.ai-btn {
  padding: 0.8rem 2rem; font-size: 1.1rem; font-weight: 800; color: white;
  background: linear-gradient(135deg, #9B72FF, var(--primary));
  box-shadow: 0 4px 15px rgba(155, 114, 255, 0.4);
}
.ai-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(155, 114, 255, 0.6); }

/* =========================================
   MODALS / TOASTS
========================================= */
/* Similar to v1, omitted unneeded lines to save space but keeping essential */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.8); z-index: 999; align-items: center; justify-content: center; }
.modal.active { display: flex; }
.modal-content { background: var(--bg-panel); padding: 2.5rem; border-radius: 20px; text-align: center; border: 1px solid var(--border); }
.modal h3 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.modal-actions { display: flex; gap: 1rem; margin-top: 20px; }
.modal-btn { padding: 0.8rem 1.5rem; font-weight: 700; flex: 1; }
.modal-btn.secondary { background-color: #2A2A2A; color: white; }
.modal-btn.danger-modal { background-color: var(--danger); color: white; }

.toast-container { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { background: rgba(255,255,255, 0.9); color: black; padding: 0.8rem 1.5rem; border-radius: 30px; font-weight: 700; opacity: 0; animation: slideUpToast 1.5s ease forwards; }
@keyframes slideUpToast { 0% { opacity: 0; transform: translateY(20px); } 10% { opacity: 1; transform: translateY(0); } 90% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-10px); } }

/* AI specifics */
.ai-modal .modal-content { max-width: 600px; text-align: left; }
.ai-header { display: flex; justify-content: space-between; }
.close-btn { background: none; font-size: 2rem; color: var(--text-muted); }
.anim-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 1.5rem 0; }
.anim-option { padding: 0.8rem; border: 2px solid var(--border); border-radius: 12px; cursor: pointer; display: flex; align-items: center; gap: 10px; font-weight: 600; transition: all 0.2s; }
.anim-option:hover { border-color: #9B72FF; background-color: rgba(155,114,255,0.05); }
.anim-option.selected { border-color: #9B72FF; background-color: rgba(155,114,255,0.1); }
.hidden { display: none !important; }
.spinner { width: 50px; height: 50px; border: 5px solid rgba(155,114,255,0.2); border-top-color: #9B72FF; border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================
   COPYRIGHT PROTECTION TOAST
========================================= */
.copyright-toast {
  position: fixed;
  z-index: 999999;
  pointer-events: none;
  background: rgba(15, 15, 20, 0.95);
  border: 1px solid rgba(255, 71, 87, 0.6);
  border-left: 4px solid var(--danger, #FF4757);
  border-radius: 12px;
  padding: 12px 18px;
  width: 280px;
  color: #fff;
  font-family: var(--font-base, 'Nunito', sans-serif);
  font-size: 0.85rem;
  line-height: 1.5;
  box-shadow: 0 8px 32px rgba(255, 71, 87, 0.25), 0 2px 8px rgba(0,0,0,0.6);
  animation: copyrightIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  backdrop-filter: blur(10px);
}
.copyright-toast strong {
  display: block;
  font-size: 0.9rem;
  color: #FF6B6B;
}
.copyright-toast span {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.6);
}
.copyright-toast.copyright-fade {
  animation: copyrightOut 0.6s ease forwards;
}
@keyframes copyrightIn {
  0%   { opacity: 0; transform: scale(0.85) translateY(-6px); }
  100% { opacity: 1; transform: scale(1)    translateY(0); }
}
@keyframes copyrightOut {
  0%   { opacity: 1; transform: scale(1) translateY(0); }
  100% { opacity: 0; transform: scale(0.9) translateY(-8px); }
}

