/* ============================================
   DASHBOARD GENERATOR STYLES
   High Quality Professional UI
   ============================================ */

/* ==========================================
   CSS VARIABLES
   ========================================== */

:root {
  --db-primary: #3b82f6;
  --db-primary-dark: #2563eb;
  --db-primary-light: #60a5fa;
  --db-sidebar-width: 300px;
  --db-properties-width: 280px;
  --db-header-height: 64px;
  --db-bg: #f1f5f9;
  --db-surface: #ffffff;
  --db-border: #e2e8f0;
  --db-text: #1e293b;
  --db-text-muted: #64748b;
  --db-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --db-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* ==========================================
   BASE STYLES (Reset handled by base.css)
   ========================================== */

body {
  font-family:
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--db-text);
  background: var(--db-bg);
  overflow: hidden;
}

/* ==========================================
   MAIN LAYOUT - 3 COLUMN GRID
   ========================================== */

.dashboard-builder {
  display: grid;
  grid-template-columns: var(--db-sidebar-width) 1fr var(--db-properties-width);
  height: 100vh;
  width: 100%;
  position: relative;
  transition: grid-template-columns 0.3s ease;
}

/* Collapsed states */
.dashboard-builder.left-collapsed {
  grid-template-columns: 0 1fr var(--db-properties-width);
}

.dashboard-builder.right-collapsed {
  grid-template-columns: var(--db-sidebar-width) 1fr 0;
}

.dashboard-builder.left-collapsed.right-collapsed {
  grid-template-columns: 0 1fr 0;
}

/* ==========================================
   SIDEBAR TOGGLE BUTTONS
   ========================================== */

.sidebar-toggle {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 48px;
  background: #ffffff;
  border: 1px solid var(--db-border);
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: all 0.3s ease;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.sidebar-toggle:hover {
  background: #f8fafc;
}

.sidebar-toggle svg {
  width: 16px;
  height: 16px;
  color: var(--db-text-muted);
  transition: transform 0.3s ease;
}

.sidebar-toggle-left {
  left: var(--db-sidebar-width);
  border-left: none;
}

.sidebar-toggle-right {
  right: var(--db-properties-width);
  border-radius: 8px 0 0 8px;
  border-right: none;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
}

/* Toggle button positions when collapsed */
.dashboard-builder.left-collapsed .sidebar-toggle-left {
  left: 0;
}

.dashboard-builder.left-collapsed .sidebar-toggle-left svg {
  transform: rotate(180deg);
}

.dashboard-builder.right-collapsed .sidebar-toggle-right {
  right: 0;
}

.dashboard-builder.right-collapsed .sidebar-toggle-right svg {
  transform: rotate(180deg);
}

/* ==========================================
   LEFT SIDEBAR
   ========================================== */

.builder-sidebar {
  background: var(--db-surface);
  border-right: 1px solid var(--db-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

.dashboard-builder.left-collapsed .builder-sidebar {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  padding: 20px;
  background: var(--db-primary);
  color: white;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.sidebar-title svg {
  width: 22px;
  height: 22px;
}

.sidebar-subtitle {
  font-size: 13px;
  opacity: 0.9;
}

/* Sidebar Scrollable Content */
.builder-sidebar {
  overflow-y: auto;
}

.builder-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--db-border);
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--db-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* Layout Options */
.layout-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.layout-btn {
  padding: 10px 8px;
  border: 2px solid var(--db-border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.layout-btn:hover {
  border-color: var(--db-primary);
}

.layout-btn.active {
  border-color: var(--db-primary);
  background: rgba(59, 130, 246, 0.05);
}

.layout-preview {
  width: 48px;
  height: 36px;
  border: 1px solid var(--db-border);
  border-radius: 4px;
  display: grid;
  gap: 2px;
  padding: 3px;
  background: white;
}

.preview-sidebar {
  background: var(--db-primary);
  opacity: 0.6;
  border-radius: 2px;
}

.preview-topbar {
  background: var(--db-primary);
  opacity: 0.6;
  border-radius: 2px;
  height: 6px;
}

.preview-main,
.preview-content,
.preview-top {
  background: #e2e8f0;
  border-radius: 2px;
}

.layout-btn span {
  font-size: 10px;
  color: var(--db-text-muted);
  font-weight: 500;
}

/* Component Categories */
.component-category {
  margin-bottom: 16px;
}

.component-category:last-child {
  margin-bottom: 0;
}

.category-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--db-text);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-title svg {
  width: 16px;
  height: 16px;
  color: var(--db-text-muted);
}

/* Atomic Design Categories */
.atomic-category {
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.atomic-category[data-atomic='atom'] {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.06) 0%, rgba(59, 130, 246, 0.02) 100%);
  border: 1px solid rgba(59, 130, 246, 0.15);
}

.atomic-category[data-atomic='molecule'] {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.06) 0%, rgba(16, 185, 129, 0.02) 100%);
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.atomic-category[data-atomic='organism'] {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.06) 0%, rgba(139, 92, 246, 0.02) 100%);
  border: 1px solid rgba(139, 92, 246, 0.15);
  padding-bottom: 8px;
}

.atomic-title {
  margin-bottom: 10px;
}

.atomic-category[data-atomic='atom'] .atomic-title {
  color: #2563eb;
}

.atomic-category[data-atomic='molecule'] .atomic-title {
  color: #059669;
}

.atomic-category[data-atomic='organism'] .atomic-title {
  color: #7c3aed;
}

.atomic-badge {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
}

.atomic-category[data-atomic='atom'] .atomic-badge {
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
}

.atomic-category[data-atomic='molecule'] .atomic-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

.atomic-category[data-atomic='organism'] .atomic-badge {
  background: rgba(139, 92, 246, 0.15);
  color: #7c3aed;
}

.atomic-list {
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}

.atomic-list::-webkit-scrollbar {
  width: 4px;
}

.atomic-list::-webkit-scrollbar-track {
  background: transparent;
}

.atomic-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.atomic-category .component-item {
  padding: 8px 10px;
  font-size: 12px;
}

.atomic-category .component-icon {
  width: 26px;
  height: 26px;
  min-width: 26px;
}

.component-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.component-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--db-border);
  border-radius: 8px;
  background: white;
  cursor: grab;
  transition: all 0.15s ease;
}

.component-item:hover {
  border-color: var(--db-primary);
  background: rgba(59, 130, 246, 0.03);
  transform: translateX(2px);
}

.component-item:active {
  cursor: grabbing;
}

.component-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border-radius: 6px;
  color: var(--db-text-muted);
}

.component-icon svg {
  width: 16px;
  height: 16px;
}

.component-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--db-text);
}

/* Theme Selector */
.theme-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 2px solid var(--db-border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 12px;
  font-weight: 500;
  color: var(--db-text);
}

.theme-option:hover {
  border-color: var(--db-primary);
}

.theme-option.active {
  border-color: var(--db-primary);
  background: rgba(59, 130, 246, 0.05);
}

.theme-color {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Customize Groups */
.customize-group {
  margin-bottom: 12px;
}

.customize-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--db-text);
  margin-bottom: 6px;
}

.customize-select {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--db-border);
  border-radius: 6px;
  background: white;
  color: var(--db-text);
  cursor: pointer;
}

.customize-select:focus {
  outline: none;
  border-color: var(--db-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Color Inputs */
.color-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #f8fafc;
  border-radius: 6px;
}

.color-row span {
  font-size: 12px;
  color: var(--db-text-muted);
}

.color-row input[type='color'] {
  width: 32px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--db-border);
  border-radius: 4px;
  cursor: pointer;
  background: none;
}

.color-row input[type='color']::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-row input[type='color']::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.reset-colors-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  font-size: 12px;
  color: var(--db-text-muted);
  background: white;
  border: 1px solid var(--db-border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.reset-colors-btn:hover {
  background: #f8fafc;
  color: var(--db-text);
}

/* Export Format Selector */
.export-format-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.format-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--db-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.format-option:hover {
  background: #f8fafc;
}

.format-option:has(input:checked) {
  border-color: var(--db-primary);
  background: rgba(59, 130, 246, 0.05);
}

.format-option input[type='radio'] {
  width: 16px;
  height: 16px;
  accent-color: var(--db-primary);
}

.format-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.format-label strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--db-text);
}

.format-label small {
  font-size: 11px;
  color: var(--db-text-muted);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn svg {
  width: 18px;
  height: 18px;
}

.action-btn.primary {
  background: var(--db-primary);
  color: white;
}

.action-btn.primary:hover {
  background: var(--db-primary-dark);
}

.action-btn.secondary {
  background: #f1f5f9;
  color: var(--db-text);
  border: 1px solid var(--db-border);
}

.action-btn.secondary:hover {
  background: #e2e8f0;
}

/* ==========================================
   MAIN CANVAS AREA
   ========================================== */

.builder-canvas {
  display: flex;
  flex-direction: column;
  background: var(--db-bg);
  overflow: hidden;
  min-height: 0;
}

.canvas-header {
  background: var(--db-surface);
  border-bottom: 1px solid var(--db-border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--db-header-height);
  flex-shrink: 0;
}

.canvas-title h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--db-text);
  margin-bottom: 2px;
}

.canvas-title p {
  font-size: 12px;
  color: var(--db-text-muted);
}

.canvas-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.device-preview-toggles {
  display: flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 4px;
}

.device-preview-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--db-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.device-preview-btn:hover {
  color: var(--db-text);
}

.device-preview-btn.active {
  background: var(--db-primary);
  color: white;
}

.device-preview-btn svg {
  width: 20px;
  height: 20px;
}

.canvas-control {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--db-border);
  border-radius: 8px;
  background: white;
  color: var(--db-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.canvas-control:hover {
  border-color: var(--db-primary);
  color: var(--db-primary);
}

.canvas-control svg {
  width: 18px;
  height: 18px;
}

.canvas-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #f1f5f9;
  border-radius: 8px;
}

.zoom-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--db-text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
}

.zoom-btn:hover {
  background: white;
}

.zoom-slider {
  width: 80px;
  height: 4px;
  appearance: none;
  background: #cbd5e1;
  border-radius: 2px;
  cursor: pointer;
}

.zoom-slider::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--db-primary);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.zoom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.zoom-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--db-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.zoom-level {
  font-size: 13px;
  font-weight: 500;
  color: var(--db-text);
  min-width: 45px;
  text-align: center;
}

/* Canvas Workspace */
.canvas-workspace {
  flex: 1;
  overflow: auto;
  padding: 24px;
  background: var(--db-bg);
  min-height: 0;
  max-height: calc(100vh - 160px);
}

#dashboardCanvas {
  min-height: 800px;
  width: 100%;
  background: white;
  border-radius: 12px;
  box-shadow: var(--db-shadow);
}

.dashboard-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 24px;
  min-height: 400px;
  align-content: flex-start;
}

/* Device Preview Modes */
.canvas-workspace.device-tablet {
  display: flex;
  justify-content: center;
  padding: 24px;
}

.canvas-workspace.device-tablet #dashboardCanvas {
  max-width: 768px;
  width: 100%;
  min-height: 600px;
}

.canvas-workspace.device-mobile {
  display: flex;
  justify-content: center;
  padding: 24px;
}

.canvas-workspace.device-mobile #dashboardCanvas {
  max-width: 375px;
  width: 100%;
  min-height: 700px;
}

/* Empty Canvas State */
.empty-canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  padding: 48px;
}

.empty-canvas-content {
  text-align: center;
  max-width: 500px;
}

.empty-canvas-content svg {
  width: 80px;
  height: 80px;
  color: #cbd5e1;
  margin-bottom: 20px;
}

.empty-canvas-content h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--db-text);
  margin-bottom: 8px;
}

.empty-canvas-content p {
  font-size: 14px;
  color: var(--db-text-muted);
  margin-bottom: 24px;
}

.quick-start {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.quick-start-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 2px solid var(--db-border);
  border-radius: 10px;
  background: white;
  font-size: 14px;
  font-weight: 500;
  color: var(--db-text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.quick-start-btn:hover {
  border-color: var(--db-primary);
  background: rgba(59, 130, 246, 0.03);
}

.quick-start-btn svg {
  width: 18px;
  height: 18px;
  color: var(--db-primary);
}

/* ==========================================
   RIGHT PROPERTIES PANEL
   ========================================== */

.properties-panel {
  background: var(--db-surface);
  border-left: 1px solid var(--db-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

.dashboard-builder.right-collapsed .properties-panel {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.properties-panel .panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--db-border);
  flex-shrink: 0;
}

.properties-panel .panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--db-text);
}

.panel-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.no-selection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--db-text-muted);
}

.no-selection svg {
  width: 48px;
  height: 48px;
  color: #cbd5e1;
  margin-bottom: 12px;
}

.no-selection p {
  font-size: 13px;
}

/* ==========================================
   COMPONENT WRAPPER & CONTROLS
   ========================================== */

.dashboard-component-wrapper {
  position: relative;
  cursor: grab;
}

.dashboard-component-wrapper:active {
  cursor: grabbing;
}

.dashboard-component-wrapper.selected {
  outline: 2px solid var(--db-primary);
  outline-offset: 4px;
  border-radius: 8px;
}

.dashboard-component-wrapper:hover .component-controls {
  opacity: 1;
  visibility: visible;
}

.component-controls {
  position: absolute;
  top: -8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.15s ease;
  z-index: 100;
}

.component-control {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: white;
  color: #64748b;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.15s ease;
}

.component-control:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.component-control svg {
  width: 14px;
  height: 14px;
}

/* ==========================================
   DASHBOARD LAYOUT TEMPLATES
   ========================================== */

/* Sidebar Left Layout */
.db-layout-sidebar-left {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 500px;
  background: #f8fafc;
}

.db-sidebar {
  background: #1e293b;
  color: white;
  padding: 20px;
}

.db-sidebar-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.db-sidebar-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.db-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.db-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s ease;
}

.db-nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.db-nav-item.active {
  background: var(--db-primary);
  color: white;
}

.db-nav-item svg {
  width: 18px;
  height: 18px;
}

.db-main {
  padding: 0;
  overflow: auto;
  min-width: 0;
}

/* Topbar Layout */
.db-layout-topbar {
  display: flex;
  flex-direction: column;
  min-height: 500px;
  background: #f8fafc;
}

.db-topbar {
  background: #1e293b;
  color: white;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.db-topbar-brand {
  font-size: 18px;
  font-weight: 700;
}

.db-topbar-nav {
  display: flex;
  gap: 8px;
}

.db-topbar-link {
  padding: 8px 16px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s ease;
}

.db-topbar-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.db-topbar-link.active {
  background: var(--db-primary);
  color: white;
}

.db-main-topbar {
  flex: 1;
  padding: 0;
  overflow: auto;
  min-width: 0;
}

/* Sidebar + Top Layout */
.db-layout-sidebar-top {
  display: flex;
  flex-direction: column;
  min-height: 500px;
  background: #f8fafc;
}

.db-header-bar {
  background: white;
  border-bottom: 1px solid var(--db-border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.db-header-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--db-text);
}

.db-header-actions {
  display: flex;
  gap: 8px;
}

.db-header-btn {
  padding: 8px 16px;
  border: 1px solid var(--db-border);
  border-radius: 6px;
  background: white;
  font-size: 13px;
  color: var(--db-text);
  cursor: pointer;
}

.db-header-btn:hover {
  background: #f8fafc;
}

.db-sidebar-content-wrapper {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  flex: 1;
}

.db-sidebar-mini {
  background: #1e293b;
  padding: 12px;
}

.db-sidebar-nav-mini {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.db-nav-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.7);
  transition: all 0.15s ease;
}

.db-nav-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.db-nav-icon.active {
  background: var(--db-primary);
  color: white;
}

.db-nav-icon svg {
  width: 20px;
  height: 20px;
}

.db-main-sidebar-top {
  padding: 0;
  overflow: auto;
  min-width: 0;
}

/* ==========================================
   SCROLLBAR STYLES
   ========================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 1400px) {
  :root {
    --db-sidebar-width: 280px;
    --db-properties-width: 260px;
  }
}

@media (max-width: 1200px) {
  .dashboard-builder {
    grid-template-columns: var(--db-sidebar-width) 1fr 0;
  }

  .dashboard-builder.left-collapsed {
    grid-template-columns: 0 1fr 0;
  }

  .properties-panel {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
  }

  .sidebar-toggle-right {
    display: none;
  }
}

@media (max-width: 768px) {
  .dashboard-builder {
    grid-template-columns: 0 1fr 0;
  }

  .builder-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 1001;
    transform: translateX(-100%);
    opacity: 1;
    pointer-events: auto;
  }

  .dashboard-builder:not(.left-collapsed) .builder-sidebar {
    transform: translateX(0);
    box-shadow: var(--db-shadow-lg);
  }

  .dashboard-builder.left-collapsed .builder-sidebar {
    transform: translateX(-100%);
  }

  .sidebar-toggle-left {
    left: 0;
    z-index: 1002;
  }

  .dashboard-builder:not(.left-collapsed) .sidebar-toggle-left {
    left: 280px;
  }

  .sidebar-toggle-right {
    display: none;
  }
}

/* ==========================================
   LAYOUT PREVIEW STYLES
   ========================================== */

.layout-preview {
  display: grid;
  gap: 2px;
  padding: 4px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}

/* Sidebar Left Layout */
.layout-btn[data-layout='sidebar-left'] .layout-preview {
  grid-template-columns: 12px 1fr;
}

/* Topbar Layout */
.layout-btn[data-layout='topbar'] .layout-preview {
  grid-template-rows: 8px 1fr;
}

/* Sidebar Top Layout */
.layout-btn[data-layout='sidebar-top'] .layout-preview {
  grid-template-columns: 10px 1fr;
  grid-template-rows: 6px 1fr;
}

.layout-btn[data-layout='sidebar-top'] .preview-sidebar {
  grid-row: span 2;
}

.layout-btn[data-layout='sidebar-top'] .preview-top {
  grid-column: 2;
}

.layout-btn[data-layout='sidebar-top'] .preview-main {
  grid-column: 2;
}

/* ==========================================
   DRAG & DROP FEEDBACK
   ========================================== */

.canvas-workspace.drag-over {
  background: rgba(59, 130, 246, 0.05);
}

.canvas-workspace.drag-over #dashboardCanvas {
  outline: 2px dashed var(--db-primary);
  outline-offset: 4px;
}

.dashboard-component-wrapper.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

/* ==========================================
   PROPERTIES PANEL CONTENT
   ========================================== */

.properties-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--db-border);
  margin-bottom: 16px;
}

.properties-header h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--db-text);
  margin: 0;
}

.properties-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--db-text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.properties-close:hover {
  background: #f1f5f9;
  color: var(--db-text);
}

.properties-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.property-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.property-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--db-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.property-value {
  font-size: 14px;
  color: var(--db-text);
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 6px;
}

.property-id {
  font-family: monospace;
  font-size: 12px;
  word-break: break-all;
}

.property-divider {
  height: 1px;
  background: var(--db-border);
  margin: 8px 0;
}

.property-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.property-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.property-btn svg {
  width: 16px;
  height: 16px;
}

.property-btn-primary {
  background: var(--db-primary);
  color: white;
}

.property-btn-primary:hover {
  background: var(--db-primary-dark);
}

.property-btn-danger {
  background: #fee2e2;
  color: #dc2626;
}

.property-btn-danger:hover {
  background: #fecaca;
}

/* ==========================================
   GRID COLUMN SELECTOR
   ========================================== */

.grid-column-selector {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.grid-column-visual {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
  padding: 8px;
  background: #f1f5f9;
  border-radius: 8px;
}

.grid-col-block {
  height: 24px;
  background: #e2e8f0;
  border-radius: 3px;
  transition: background 0.15s ease;
}

.grid-col-block.active {
  background: var(--db-primary);
}

.grid-column-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.property-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--db-border);
  border-radius: 8px;
  background: white;
  color: var(--db-text);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.property-select:focus {
  outline: none;
  border-color: var(--db-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.grid-quick-buttons {
  display: flex;
  gap: 8px;
}

.grid-quick-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--db-border);
  border-radius: 6px;
  background: white;
  color: var(--db-text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.grid-quick-btn:hover {
  border-color: var(--db-primary);
  background: rgba(59, 130, 246, 0.05);
}

.grid-quick-btn.active {
  border-color: var(--db-primary);
  background: var(--db-primary);
  color: white;
}

/* ==========================================
   EMPTY CANVAS STATE
   ========================================== */

.empty-canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 500px;
  padding: 48px;
  background: white;
  border-radius: 12px;
}

.empty-canvas-content {
  text-align: center;
  max-width: 480px;
}

.empty-canvas-content svg {
  width: 100px;
  height: 100px;
  color: #cbd5e1;
  margin-bottom: 24px;
}

.empty-canvas-content h3 {
  font-size: 22px;
  font-weight: 600;
  color: var(--db-text);
  margin: 0 0 8px 0;
}

.empty-canvas-content p {
  font-size: 15px;
  color: var(--db-text-muted);
  margin: 0 0 28px 0;
  line-height: 1.6;
}

.quick-start {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.quick-start-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 2px solid var(--db-border);
  border-radius: 10px;
  background: white;
  font-size: 14px;
  font-weight: 500;
  color: var(--db-text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.quick-start-btn:hover {
  border-color: var(--db-primary);
  background: rgba(59, 130, 246, 0.03);
  transform: translateY(-2px);
}

.quick-start-btn svg {
  width: 20px;
  height: 20px;
  color: var(--db-primary);
}

/* ==========================================
   COMPONENT WRAPPER STYLES
   ========================================== */

.dashboard-component-wrapper {
  position: relative;
  cursor: grab;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.dashboard-component-wrapper > * {
  width: 100%;
}

.dashboard-component-wrapper:active {
  cursor: grabbing;
}

.dashboard-component-wrapper:hover {
  z-index: 10;
}

.dashboard-component-wrapper.selected {
  outline: 2px solid var(--db-primary);
  outline-offset: 4px;
  border-radius: 8px;
}

/* Grid column classes for wrapper - uses CSS Grid */
.dashboard-component-wrapper.grid-col-1 {
  grid-column: span 1;
}
.dashboard-component-wrapper.grid-col-2 {
  grid-column: span 2;
}
.dashboard-component-wrapper.grid-col-3 {
  grid-column: span 3;
}
.dashboard-component-wrapper.grid-col-4 {
  grid-column: span 4;
}
.dashboard-component-wrapper.grid-col-5 {
  grid-column: span 5;
}
.dashboard-component-wrapper.grid-col-6 {
  grid-column: span 6;
}
.dashboard-component-wrapper.grid-col-7 {
  grid-column: span 7;
}
.dashboard-component-wrapper.grid-col-8 {
  grid-column: span 8;
}
.dashboard-component-wrapper.grid-col-9 {
  grid-column: span 9;
}
.dashboard-component-wrapper.grid-col-10 {
  grid-column: span 10;
}
.dashboard-component-wrapper.grid-col-11 {
  grid-column: span 11;
}
.dashboard-component-wrapper.grid-col-12 {
  grid-column: span 12;
}

.dashboard-component-wrapper:hover .component-controls {
  opacity: 1;
  visibility: visible;
}

.component-controls {
  position: absolute;
  top: -12px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.15s ease;
  z-index: 100;
}

.component-control {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: white;
  color: #64748b;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.15s ease;
}

.component-control:hover {
  background: #f1f5f9;
  color: #1e293b;
  transform: scale(1.1);
}

.component-control[data-action='delete']:hover {
  background: #fee2e2;
  color: #dc2626;
}

.component-control svg {
  width: 14px;
  height: 14px;
}

/* ==========================================
   NO SELECTION STATE
   ========================================== */

.no-selection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  text-align: center;
  color: var(--db-text-muted);
  padding: 24px;
}

.no-selection svg {
  width: 64px;
  height: 64px;
  color: #cbd5e1;
  margin-bottom: 16px;
}

.no-selection p {
  font-size: 14px;
  margin: 0;
  line-height: 1.5;
}

/* ==========================================
   NOTIFICATION STYLES
   ========================================== */

.db-notification {
  position: fixed;
  bottom: 80px;
  right: 20px;
  padding: 12px 20px;
  max-width: 320px;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  animation: slideInRight 0.3s ease-out;
}

.db-notification-success {
  background: #10b981;
  color: white;
}

.db-notification-error {
  background: #ef4444;
  color: white;
}

.db-notification-info {
  background: #3b82f6;
  color: white;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* ==========================================
   FOOTER NAVIGATION
   ========================================== */

.generator-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1e293b;
  border-top: 1px solid #334155;
  z-index: 1000;
  padding: 0.5rem 1rem;
}

.footer-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  max-width: 600px;
  margin: 0 auto;
}

.footer-nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.footer-nav-link:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.05);
}

.footer-nav-link.active {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
}

.footer-nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Adjust app container to account for footer */
.db-app-container {
  padding-bottom: 50px;
}

@media (max-width: 640px) {
  .footer-nav {
    gap: 0.5rem;
  }

  .footer-nav-link {
    padding: 0.5rem;
    font-size: 0.75rem;
  }

  .footer-nav-link span {
    display: none;
  }

  .footer-nav-link svg {
    width: 22px;
    height: 22px;
  }
}

/* ==========================================
   COMPONENT PREVIEW TOOLTIP
   ========================================== */

.component-preview-tooltip {
  position: fixed;
  z-index: 10001;
  width: 280px;
  background: white;
  border-radius: 12px;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.95) translateY(5px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.component-preview-tooltip.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.preview-tooltip-header {
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.preview-tooltip-content {
  padding: 12px;
  background: #f1f5f9;
  max-height: 200px;
  overflow: hidden;
}

.preview-tooltip-content .preview-scale {
  transform: scale(0.35);
  transform-origin: top left;
  width: 285%;
  pointer-events: none;
}

.preview-tooltip-content .preview-scale * {
  pointer-events: none !important;
}

/* ==========================================
   CODE PREVIEW MODAL
   ========================================== */

.code-preview-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10002;
  display: none;
  align-items: center;
  justify-content: center;
}

.code-preview-modal.active {
  display: flex;
}

.code-preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.code-preview-container {
  position: relative;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  background: #1e293b;
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.code-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #0f172a;
  border-bottom: 1px solid #334155;
}

.code-preview-header h3 {
  color: white;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.code-preview-tabs {
  display: flex;
  gap: 4px;
  background: #1e293b;
  padding: 4px;
  border-radius: 8px;
}

.code-tab {
  padding: 8px 16px;
  background: transparent;
  color: #94a3b8;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.code-tab:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.code-tab.active {
  background: #3b82f6;
  color: white;
}

.code-preview-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.code-preview-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.code-preview-body {
  flex: 1;
  overflow: auto;
  padding: 0;
}

.code-preview-content {
  margin: 0;
  padding: 20px;
  background: #1e293b;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-all;
}

.code-preview-content code {
  display: block;
  color: #e2e8f0;
}

.code-preview-footer {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  background: #0f172a;
  border-top: 1px solid #334155;
  justify-content: flex-end;
}

.code-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: #334155;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.code-action-btn:hover {
  background: #475569;
}

.code-action-btn.primary {
  background: #3b82f6;
}

.code-action-btn.primary:hover {
  background: #2563eb;
}

.code-action-btn svg {
  width: 18px;
  height: 18px;
}

/* ==========================================
   GRID DESIGN MODE
   ========================================== */

/* Mode Tabs */
.canvas-mode-tabs {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-tab:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.mode-tab.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

.mode-tab svg {
  width: 16px;
  height: 16px;
}

/* Grid Templates Section */
.grid-design-section {
  display: block;
}

.grid-template-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.grid-template-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.grid-template-btn:hover {
  background: #f1f5f9;
  border-color: #3b82f6;
}

.grid-template-btn.active {
  background: #eff6ff;
  border-color: #3b82f6;
}

.grid-template-btn span {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
}

/* Template Visual Preview */
.template-visual {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.template-row {
  display: flex;
  gap: 2px;
  height: 12px;
}

.template-row.full-height {
  height: 28px;
}

.template-visual [class^='t-col-'] {
  background: #cbd5e1;
  border-radius: 2px;
  flex-shrink: 0;
}

.t-col-12 {
  flex: 0 0 100%;
}
.t-col-9 {
  flex: 0 0 calc(75% - 1px);
}
.t-col-6 {
  flex: 0 0 calc(50% - 1px);
}
.t-col-4 {
  flex: 0 0 calc(33.33% - 1.33px);
}
.t-col-3 {
  flex: 0 0 calc(25% - 1.5px);
}

/* Grid Row Controls */
.grid-row-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 12px;
}

.grid-row-controls label {
  font-size: 13px;
  font-weight: 500;
  color: #475569;
}

.grid-row-controls label span {
  font-weight: 600;
  color: #1e293b;
}

.row-control-btns {
  display: flex;
  gap: 4px;
}

.row-control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
}

.row-control-btn:hover {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

.clear-areas-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #dc2626;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.clear-areas-btn:hover {
  background: #fee2e2;
  border-color: #f87171;
}

/* Sidebar Section Visibility Toggle */
.component-library-section {
  display: none;
}

.grid-design-section {
  display: block;
}

body.component-mode .component-library-section {
  display: block;
}

body.component-mode .grid-design-section {
  display: none;
}

/* Grid Overlay in Canvas */
.grid-overlay {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--grid-gap, 24px);
  padding: var(--grid-padding, 24px);
  min-height: 400px;
  background: #f8fafc;
}

.grid-cell {
  background: #e2e8f0;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 500;
  cursor: crosshair;
  transition: all 0.15s ease;
  user-select: none;
}

.grid-cell:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #3b82f6;
}

.grid-cell.selecting {
  background: rgba(59, 130, 246, 0.2);
  border-color: #3b82f6;
  border-style: solid;
}

.grid-cell.in-selection {
  background: rgba(59, 130, 246, 0.15);
  border-color: #60a5fa;
}

.grid-cell.occupied {
  pointer-events: none;
  opacity: 0.3;
}

/* Column Headers */
.grid-column-headers {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--grid-gap, 24px);
  padding: 8px var(--grid-padding, 24px);
  background: #1e293b;
  border-radius: 8px 8px 0 0;
}

.column-header {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
}

/* Defined Areas */
.grid-area-defined {
  position: absolute;
  background: rgba(59, 130, 246, 0.1);
  border: 2px solid #3b82f6;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
}

.grid-area-defined:hover {
  background: rgba(59, 130, 246, 0.2);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.grid-area-label {
  font-size: 12px;
  font-weight: 600;
  color: #1e40af;
  background: white;
  padding: 4px 10px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.grid-area-delete {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 24px;
  height: 24px;
  background: #ef4444;
  border: 2px solid white;
  border-radius: 50%;
  color: white;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.grid-area-defined:hover .grid-area-delete {
  display: flex;
}

/* Area Colors */
.grid-area-defined[data-color='blue'] {
  background: rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
}
.grid-area-defined[data-color='green'] {
  background: rgba(34, 197, 94, 0.1);
  border-color: #22c55e;
}
.grid-area-defined[data-color='purple'] {
  background: rgba(168, 85, 247, 0.1);
  border-color: #a855f7;
}
.grid-area-defined[data-color='orange'] {
  background: rgba(249, 115, 22, 0.1);
  border-color: #f97316;
}
.grid-area-defined[data-color='pink'] {
  background: rgba(236, 72, 153, 0.1);
  border-color: #ec4899;
}
.grid-area-defined[data-color='cyan'] {
  background: rgba(6, 182, 212, 0.1);
  border-color: #06b6d4;
}

/* Component Mode - Area Drop Zones */
body.component-mode .grid-area-defined {
  cursor: default;
}

body.component-mode .grid-area-defined.drop-target {
  background: rgba(34, 197, 94, 0.15);
  border-color: #22c55e;
  border-style: dashed;
}

body.component-mode .grid-area-defined.drop-target::after {
  content: 'Drop component here';
  font-size: 12px;
  color: #16a34a;
  font-weight: 500;
}

/* Grid Design Layout Preview */
.grid-design-layout {
  display: flex;
  min-height: 500px;
  background: #f1f5f9;
  border-radius: 8px;
  overflow: hidden;
}

.grid-design-layout.db-layout-topbar {
  flex-direction: column;
}

.grid-design-layout.db-layout-sidebar-top {
  flex-direction: row;
}

.grid-design-layout .db-content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Grid Design Sidebar Preview */
.grid-design-sidebar {
  width: 220px;
  min-width: 220px;
  background: #1e293b;
  color: white;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.grid-design-sidebar .db-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #334155;
}

.grid-design-sidebar .db-sidebar-header h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: #334155;
  border: none;
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-collapse-btn:hover {
  background: #475569;
  color: white;
}

.sidebar-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.sidebar-placeholder span {
  font-size: 12px;
  color: #64748b;
  text-align: center;
}

/* Collapsed Sidebar */
.grid-design-layout.sidebar-collapsed .grid-design-sidebar {
  width: 60px;
  min-width: 60px;
}

.grid-design-layout.sidebar-collapsed .db-sidebar-header h2,
.grid-design-layout.sidebar-collapsed .sidebar-placeholder span {
  display: none;
}

.grid-design-layout.sidebar-collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

/* Grid Design Topbar Preview */
.grid-design-topbar {
  background: #1e293b;
  padding: 12px 20px;
  border-bottom: 1px solid #334155;
}

.topbar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-placeholder span {
  font-size: 12px;
  color: #64748b;
}

/* Grid Design Main Area */
.grid-design-layout .db-main {
  flex: 1;
  padding: 0;
  overflow: auto;
}

.grid-design-layout .grid-design-container {
  height: 100%;
}

.grid-design-layout .grid-overlay {
  min-height: 400px;
}

/* ==========================================
   COMPONENT MODE WITH GRID AREAS
   ========================================== */

.component-grid-container {
  min-height: 400px;
}

.area-drop-zone {
  cursor: default;
}

.area-drop-zone.drag-over {
  background: rgba(34, 197, 94, 0.15) !important;
  border-color: #22c55e !important;
  border-style: solid !important;
  transform: scale(1.01);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
}

.area-drop-zone.drag-over .area-empty-state {
  color: #16a34a !important;
  opacity: 1 !important;
}

.area-component-wrapper {
  position: relative;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.area-component-wrapper:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Component Layout Wrappers */
.component-layout {
  display: flex;
  min-height: 500px;
  background: #f1f5f9;
  border-radius: 8px;
  overflow: hidden;
}

.component-layout.db-layout-topbar {
  flex-direction: column;
}

.component-layout .db-main {
  flex: 1;
  padding: 0;
  overflow: auto;
}

.component-sidebar {
  width: 200px;
  min-width: 200px;
  background: #1e293b;
  color: white;
}

.component-sidebar .db-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #334155;
}

.component-sidebar .db-sidebar-header h2 {
  font-size: 14px;
  margin: 0;
}

.component-sidebar .db-sidebar-nav {
  padding: 12px;
}

.component-sidebar .db-nav-item {
  display: block;
  padding: 10px 12px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 4px;
}

.component-sidebar .db-nav-item:hover {
  background: #334155;
  color: white;
}

.component-sidebar .db-nav-item.active {
  background: #3b82f6;
  color: white;
}

.component-layout .db-topbar {
  background: #1e293b;
  padding: 12px 20px;
  color: #94a3b8;
  font-size: 13px;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: #334155;
  border: none;
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
  background: #475569;
  color: white;
}

.sidebar-toggle-btn svg {
  transition: transform 0.3s ease;
}

/* Sidebar Collapsed State */
.component-layout.sidebar-collapsed .component-sidebar {
  width: 48px;
  min-width: 48px;
}

.component-layout.sidebar-collapsed .db-sidebar-header {
  padding: 12px 10px;
  justify-content: center;
}

.component-layout.sidebar-collapsed .db-sidebar-header h2,
.component-layout.sidebar-collapsed .db-sidebar-nav {
  display: none;
}

.component-layout.sidebar-collapsed .sidebar-toggle-btn svg {
  transform: rotate(180deg);
}

/* Sidebar Header with Toggle */
.component-sidebar .db-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================
   COMPONENT REORDERING & CONTROLS
   ========================================== */

.area-component-wrapper {
  position: relative;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  cursor: default;
}

.area-component-wrapper:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.area-component-wrapper.dragging {
  opacity: 0.5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  transform: scale(1.02);
}

.area-component-wrapper.drag-over-top {
  border-top: 3px solid var(--db-primary);
  margin-top: -3px;
}

.area-component-wrapper.drag-over-bottom {
  border-bottom: 3px solid var(--db-primary);
  margin-bottom: -3px;
}

/* Component Controls */
.area-component-controls {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
}

.area-component-wrapper:hover .area-component-controls {
  opacity: 1;
}

.area-component-controls button {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.area-component-drag {
  background: #f1f5f9;
  color: #64748b;
  cursor: grab;
}

.area-component-drag:hover {
  background: #e2e8f0;
  color: #475569;
}

.area-component-drag:active {
  cursor: grabbing;
}

.area-component-settings {
  background: #f1f5f9;
  color: #64748b;
}

.area-component-settings:hover {
  background: #3b82f6;
  color: white;
}

.area-component-delete {
  background: #fef2f2;
  color: #dc2626;
  font-size: 16px;
  font-weight: bold;
}

.area-component-delete:hover {
  background: #dc2626;
  color: white;
}

/* ==========================================
   COMPONENT SETTINGS MODAL
   ========================================== */

.component-settings-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.settings-modal-content {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #e2e8f0;
}

.settings-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
}

.settings-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 20px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.settings-modal-close:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.settings-modal-body {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

.settings-section {
  margin-bottom: 24px;
}

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

.settings-section h4 {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Spacing Controls */
.spacing-controls {
  display: grid;
  gap: 16px;
}

.spacing-controls.spacing-grid {
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.spacing-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spacing-group label {
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
}

.spacing-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spacing-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #e2e8f0;
  border-radius: 3px;
  outline: none;
}

.spacing-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--db-primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
  transition: transform 0.2s;
}

.spacing-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.spacing-value {
  min-width: 48px;
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
  text-align: right;
}

/* Responsive Controls */
.responsive-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.responsive-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.responsive-checkbox input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--db-primary);
  cursor: pointer;
}

.responsive-checkbox span {
  font-size: 14px;
  color: #475569;
}

/* Modal Footer */
.settings-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.settings-btn-cancel,
.settings-btn-apply {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.settings-btn-cancel {
  background: white;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.settings-btn-cancel:hover {
  background: #f1f5f9;
  color: #475569;
}

.settings-btn-apply {
  background: var(--db-primary);
  color: white;
}

.settings-btn-apply:hover {
  background: var(--db-primary-dark);
}

/* ==========================================
   RESPONSIVE COMPONENT CLASSES
   ========================================== */

@media (max-width: 768px) {
  .area-component-wrapper[data-hide-mobile='true'] {
    display: none !important;
  }

  .area-component-wrapper[data-mobile-full='true'] {
    grid-column: 1 / -1 !important;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .area-component-wrapper[data-hide-tablet='true'] {
    display: none !important;
  }
}
