/* =======================================================================
   WP COLORING V2 - SIDEBAR STYLES
   ======================================================================= */

.wp-coloring-shell-v2 {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background: #f5f7fa;
  border-radius: 20px;
}

.wp-coloring-content-wrapper {
  display: grid;
  grid-template-columns: 350px 1fr; /* Sidebar left, canvas right */
  gap: 24px;
  margin-top: 0;
} /* Removed margin since no top toolbar */

/* Sidebar */
.wp-coloring-sidebar-v2 {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  height: 100%; /* Match parent height */
  max-width: 100% !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Scrollable content area (colors, patterns, etc.) */
.sidebar-scrollable {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  max-height: calc(100vh - 300px); /* Limit height to viewport minus space for toolbar and fixed bottom */
}

/* Fixed bottom sections (tools, actions) */
.sidebar-fixed-bottom {
  flex-shrink: 0;
  border-top: 2px solid #e0e0e0;
  background: #f8f9fa;
  padding: 12px 16px; /* Reduced padding */
}

.sidebar-scrollable::-webkit-scrollbar {
  width: 6px;
}

.sidebar-scrollable::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.sidebar-scrollable::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 10px;
}

.sidebar-scrollable::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Sidebar Sections */
.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section:last-child {
  margin-bottom: 0;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-title .icon {
  font-size: 16px;
}

/* Color Palette Grid */
.color-palette-grid {
  display: grid;
  grid-template-columns: repeat(var(--color-columns, 6), 1fr);
  gap: 8px;
}

.color-btn {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid #e0e0e0;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  padding: 0;
}

.color-btn:hover {
  transform: scale(1.15);
  border-color: #FF9500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10;
}

.color-btn.active {
  border-color: #FF9500;
  border-width: 3px;
  transform: scale(1.2);
  box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.2),
              0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 20;
}

.color-btn.active::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 16px;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Skin Tones Section */
.skin-tones-section {
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

.skin-tones-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.skin-tone-btn {
  border: 2px solid #d0d0d0;
}

.skin-tone-btn:hover {
  border-color: #FF9500;
}

/* Premium Patterns Section */
.premium-section {
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

.premium-patterns-grid {
  display: grid;
  grid-template-columns: repeat(var(--pattern-columns, 6), 1fr);
  gap: 8px;
}

.pattern-btn {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid #e0e0e0;
  background: #fff;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s ease;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  position: relative;
}

.pattern-preview {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.pattern-btn:hover {
  transform: scale(1.15);
  border-color: #FF9500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10;
}

.pattern-btn.active {
  border-color: #FF9500;
  border-width: 3px;
  transform: scale(1.2);
  box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.2),
              0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 20;
}

.pattern-btn.active::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 16px;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.pattern-add {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pattern-add .add-icon {
  font-size: 28px;
  color: white;
  font-weight: 300;
}

/* Brush Size Section */
.brush-size-section {
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

.brush-size-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brush-size-label svg {
  flex-shrink: 0;
  color: #666;
}

.brush-size-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #e0e0e0, #666);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.brush-size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #FF9500;
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.brush-size-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #FF9500;
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Edge Detection Toggle */
.edge-detection-section {
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  display: none;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  background: #ccc;
  border-radius: 13px;
  transition: background 0.3s ease;
}

.toggle-switch::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-label input:checked + .toggle-switch {
  background: #FF9500;
}

.toggle-label input:checked + .toggle-switch::before {
  transform: translateX(22px);
}

.toggle-text {
  font-size: 13px;
  color: #666;
  font-weight: 500;
}

/* Tools Section */
.tools-section {
  margin-bottom: 12px;
}

.tools-section .section-title {
  font-size: 12px;
  margin-bottom: 8px;
}

.tools-grid {
  display: flex; /* Horizontal layout */
  gap: 8px;
  justify-content: space-between;
}

.tools-grid .tool-btn {
  flex: 1; /* Equal width */
  height: auto;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  min-height: 60px; /* Compact height */
  line-height: 15px !important;
}

.tools-grid .tool-btn svg {
  width: 24px; /* Smaller icon */
  height: 24px;
}

.tool-label {
  font-size: 10px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
}

.tools-grid .tool-btn.active .tool-label {
  color: #FF9500;
}

.actions-section .section-title {
  font-size: 12px;
  margin-bottom: 8px;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 3 columns */
  gap: 6px; /* Smaller gap */
}

.actions-grid .bottom-tool-btn {
  width: 100%;
  height: auto;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  min-height: 55px; /* Compact */
}

.actions-grid .bottom-tool-btn svg {
  width: 20px; /* Smaller icon */
  height: 20px;
}

.action-label {
  font-size: 9px;
  font-weight: 600;
  color: #666;
  text-align: center;
  line-height: 1.2;
  text-transform: uppercase;
}

.actions-grid .bottom-tool-btn:hover .action-label {
  color: #FF9500;
}

/* === MOBILE RESPONSIVE: 2-Row Horizontal Scroll Layout === */
@media (max-width: 900px) {
  /* Stack canvas above sidebar on mobile */
  .wp-coloring-content-wrapper {
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* Canvas first (top) */
  .wp-coloring-main-v2 {
    order: 1 !important;
  }
  
  /* Sidebar second (bottom) */
  .wp-coloring-sidebar-v2 {
    order: 2 !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 8px !important;
    gap: 8px !important;
  }
  
  /* === ROW 1: SCROLLABLE SECTIONS (Colors, Patterns) - Horizontal === */
  .sidebar-scrollable {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    gap: 12px !important;
    padding: 4px !important;
    -webkit-overflow-scrolling: touch;
  }
  
  .sidebar-scrollable .sidebar-section {
    flex-shrink: 0 !important;
  }
  
  /* Hide section titles */
  .sidebar-scrollable .section-title {
    display: none !important;
  }
  
  /* Colors - horizontal */
  .color-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
  }
  
  .color-grid .color-btn {
    flex-shrink: 0 !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
  
  /* Patterns - horizontal */
  .premium-patterns-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    grid-template-columns: unset !important;
  }
  
  .premium-patterns-grid .pattern-btn {
    flex-shrink: 0 !important;
    width: 44px !important;
    height: 44px !important;
  }
  
  /* Hide skin tones on mobile */
  .sidebar-section:has(.skin-tones-grid) {
    display: none !important;
  }
  
  /* === ROW 2: FIXED BOTTOM (Tools + Actions) - Horizontal === */
  .sidebar-fixed-bottom {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 12px !important;
    padding: 4px !important;
    background: transparent !important;
    border-top: none !important;
    -webkit-overflow-scrolling: touch;
  }
  
  .sidebar-fixed-bottom > * {
    flex-shrink: 0 !important;
  }
  
  /* Hide section titles */
  .sidebar-fixed-bottom .section-title {
    display: none !important;
  }
  
  /* Tools and Actions - horizontal */
  .tools-grid,
  .actions-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    grid-template-columns: unset !important;
  }
  
  .tools-grid .tool-btn {
    flex-shrink: 0 !important;
    min-width: 60px !important;
    padding: 6px !important;
    font-size: 10px !important;
  }
  
  .actions-grid .action-btn,
  .actions-grid .bottom-tool-btn {
    flex-shrink: 0 !important;
    min-width: 50px !important;
    max-width: 50px !important;
    padding: 6px 4px !important;
    font-size: 9px !important;
  }
  
  .action-btn svg,
  .bottom-tool-btn svg {
    width: 18px !important;
    height: 18px !important;
  }
  
  /* Hide brush size label */
  .brush-size-label {
    display: none !important;
  }
  
  /* Compact brush size slider */
  .brush-size-control {
    padding: 4px 0 !important;
    min-width: 120px !important;
  }
  
  /* Scrollbar styling */
  .sidebar-scrollable::-webkit-scrollbar,
  .sidebar-fixed-bottom::-webkit-scrollbar {
    height: 4px;
  }
  
  .sidebar-scrollable::-webkit-scrollbar-thumb,
  .sidebar-fixed-bottom::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
  }
}
