/* ChildDraw v2 - Ultra Playful Canvas Editor Styles */

body.editor-mode {
  background-color: #F4F7FE;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(253, 203, 110, 0.25) 0%, transparent 20%),
    radial-gradient(circle at 90% 90%, rgba(108, 92, 231, 0.15) 0%, transparent 25%);
  overflow: hidden;
  height: 100vh;
  margin: 0;
}

/* Editor Header Bar */
.editor-topbar {
  height: 70px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid rgba(108, 92, 231, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.08);
}

.editor-title-box {
  display: flex;
  align-items: center;
  gap: 14px;
}

.editor-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dark);
  font-family: 'Fredoka', cursive;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Editor Layout Grid */
.editor-container {
  display: grid;
  grid-template-columns: 90px 1fr;
  height: calc(100vh - 70px);
  position: relative;
}

/* Left Sidebar Toolbar */
.editor-sidebar {
  background: white;
  border-right: 2px solid #F1F5F9;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 10px;
  z-index: 10;
  box-shadow: 4px 0 20px rgba(0,0,0,0.03);
  overflow-y: auto;
}

.tool-btn {
  width: 58px;
  height: 54px;
  border-radius: 16px;
  border: 2px solid #F1F5F9;
  background: #F8FAFC;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-dark);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  flex-shrink: 0;
}

.tool-btn span.label {
  font-size: 10px;
  font-weight: 800;
  font-family: 'Fredoka', cursive;
  margin-top: 2px;
}

.tool-btn:hover {
  background: #EFEDFD;
  color: var(--primary);
  transform: scale(1.08);
}

.tool-btn.active {
  background: var(--primary-gradient);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(108, 92, 231, 0.4);
  transform: scale(1.1);
}

.tool-btn .pro-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent-yellow);
  color: #D63031;
  font-family: 'Fredoka', cursive;
  font-size: 9px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 10px rgba(253, 203, 110, 0.5);
  border: 1px solid white;
}

/* Canvas Workspace */
.canvas-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 20px;
  user-select: none;
}

.canvas-viewport {
  position: relative;
  width: 100%;
  max-width: 1200px;
  aspect-ratio: 4 / 3;
  background: white;
  border-radius: 28px;
  box-shadow: 0 20px 50px rgba(108, 92, 231, 0.15);
  overflow: hidden;
  border: 4px solid white;
  transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1);
  transform-origin: center center;
}

#colorCanvas, #outlineCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#outlineCanvas {
  pointer-events: auto;
  mix-blend-mode: multiply;
}

/* Bottom Horizontal Color Palette */
.bottom-palette-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  box-shadow: 0 15px 40px rgba(108, 92, 231, 0.2);
  border: 3px solid #EFEDFD;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 50;
  max-width: 92%;
  overflow-x: auto;
  scrollbar-width: none;
}

.color-swatch {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid white;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.color-swatch.active {
  transform: scale(1.3);
  box-shadow: 0 0 0 4px var(--primary), 0 6px 15px rgba(0, 0, 0, 0.2);
}

.custom-color-picker {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  cursor: pointer;
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
}

/* Floating Zoom Controls */
.zoom-controls {
  position: absolute;
  top: 24px;
  right: 24px;
  background: white;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
  border: 2px solid #EFEDFD;
  display: flex;
  align-items: center;
  padding: 6px 12px;
  gap: 10px;
  z-index: 50;
}

.zoom-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #F8FAFC;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  font-family: 'Fredoka', cursive;
  color: var(--primary);
  transition: all 0.2s ease;
}

.zoom-btn:hover {
  background: var(--primary-gradient);
  color: white;
}

/* Eye-Safe Night Mode Styles */
body.night-mode {
  background-color: #0F172A !important;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(251, 146, 60, 0.12) 0%, transparent 30%),
    radial-gradient(circle at 90% 90%, rgba(139, 92, 246, 0.2) 0%, transparent 30%) !important;
}

body.night-mode .editor-topbar {
  background: rgba(15, 23, 42, 0.95) !important;
  border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}

body.night-mode .editor-title {
  color: #F8FAFC !important;
}

body.night-mode .editor-sidebar {
  background: #1E293B !important;
  border-right-color: #334155 !important;
}

body.night-mode .tool-btn {
  background: #334155 !important;
  border-color: #475569 !important;
  color: #F8FAFC !important;
}

body.night-mode .tool-btn:hover {
  background: #4C1D95 !important;
  color: #F472B6 !important;
}

body.night-mode .bottom-palette-bar {
  background: rgba(30, 41, 59, 0.95) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

body.night-mode .zoom-controls {
  background: #1E293B !important;
  border-color: #334155 !important;
  color: #F8FAFC !important;
}

body.night-mode .zoom-btn {
  background: #334155 !important;
  color: #A78BFA !important;
}

body.night-mode .canvas-viewport {
  filter: sepia(0.15) brightness(0.95);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
}

/* ==========================================
   MOBILE PORTRAIT RESPONSIVE REDESIGN (<768px)
   ========================================== */
@media (max-width: 768px) {
  /* Ultra-Compact Top Bar */
  .editor-topbar {
    height: 52px;
    padding: 0 8px;
    gap: 4px;
    flex-wrap: nowrap !important;
  }

  .editor-title-box {
    gap: 4px;
    min-width: 0;
    flex-shrink: 0;
  }

  .editor-title {
    display: none !important;
  }

  .editor-actions {
    gap: 4px;
    flex-shrink: 0;
    flex-wrap: nowrap !important;
  }

  .editor-actions .btn {
    padding: 4px 8px !important;
    font-size: 12px !important;
    height: 34px !important;
    min-height: 34px !important;
    border-radius: 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .editor-topbar .btn-text {
    display: none !important;
  }

  .editor-topbar .btn-save-text {
    font-size: 11px !important;
  }

  /* Editor Container Grid -> Vertical Flex Layout */
  .editor-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 54px);
    overflow: hidden;
  }

  /* Move Sidebar to Horizontal Scrollable Bottom Bar */
  .editor-sidebar {
    width: 100%;
    height: 60px;
    flex-direction: row;
    justify-content: flex-start;
    padding: 6px 10px;
    gap: 8px;
    border-right: none;
    border-top: 2px solid #E2E8F0;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    order: 2;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
    flex-shrink: 0;
  }

  .tool-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 12px;
    font-size: 16px;
  }

  .tool-btn span.label {
    font-size: 8px;
    margin-top: 1px;
  }

  /* Canvas Area gets 100% of remaining screen area */
  .canvas-area {
    order: 1;
    flex: 1;
    height: 100%;
    width: 100%;
    padding: 10px 8px 70px 8px; /* Leave space for bottom palette overlay */
  }

  .canvas-viewport {
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  }

  /* Bottom Palette Bar floating right above the mobile toolbar dock */
  .bottom-palette-bar {
    position: fixed;
    bottom: 66px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    gap: 8px;
    border-radius: var(--radius-pill);
    max-width: 96%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  }

  .color-swatch {
    width: 36px;
    height: 36px;
    border-width: 3px;
  }

  .custom-color-picker {
    width: 36px;
    height: 36px;
  }

  .zoom-controls {
    top: 8px;
    right: 8px;
    padding: 3px 6px;
    gap: 4px;
  }

  .zoom-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
}
