/* CSS Design Variables */
:root {
  --bg-base: #07090e;
  --bg-surface: #0e1320;
  --bg-glass: rgba(14, 19, 32, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(59, 130, 246, 0.4);
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  
  --color-primary: #3b82f6;
  --color-primary-glow: rgba(59, 130, 246, 0.25);
  --color-secondary: #8b5cf6;
  --color-accent: #06b6d4;
  --color-success: #10b981;
  --color-danger: #ef4444;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'Space Grotesk', sans-serif;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.12) 0px, transparent 50%);
}

/* App Container Layout */
.app-container {
  display: grid;
  grid-template-columns: 350px 1fr;
  height: 100vh;
  width: 100vw;
  background: radial-gradient(circle at top right, rgba(6, 182, 212, 0.03), transparent 40%);
}

/* Sidebar Styling */
.sidebar {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  overflow-y: auto;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  font-size: 32px;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 10px var(--color-primary-glow));
}

.brand-info h1 {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info p {
  font-size: 12px;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

/* Sections inside Sidebar */
.section-title {
  font-family: var(--font-mono);
  font-size: 14px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* File Upload Area */
.upload-section {
  flex-shrink: 0;
}

.drop-zone {
  border: 2px dashed var(--border-color);
  background: rgba(255, 255, 255, 0.01);
  border-radius: var(--radius-md);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.drop-zone:hover {
  border-color: var(--color-primary);
  background: rgba(59, 130, 246, 0.03);
  box-shadow: inset 0 0 15px rgba(59, 130, 246, 0.05);
}

.drop-icon {
  font-size: 32px;
  color: var(--text-muted);
  transition: var(--transition);
}

.drop-zone:hover .drop-icon {
  color: var(--color-primary);
  transform: translateY(-3px);
}

.drop-text {
  font-size: 14px;
  font-weight: 500;
}

.drop-subtext {
  font-size: 11px;
  color: var(--text-muted);
}

/* Progress bar */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  margin-top: 12px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  transition: width 0.1s linear;
}

/* Library Section */
.library-section {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* allows overflow scroll to trigger */
}

.model-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
  flex-grow: 1;
}

/* Style the Scrollbar */
.model-list::-webkit-scrollbar, .sidebar::-webkit-scrollbar {
  width: 4px;
}
.model-list::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}
.model-list::-webkit-scrollbar-thumb:hover, .sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Model Card Item */
.model-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.model-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 4px;
  background: transparent;
  transition: var(--transition);
}

.model-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-hover);
  transform: translateX(2px);
}

.model-card.active {
  background: rgba(59, 130, 246, 0.06);
  border-color: var(--color-primary);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1);
}

.model-card.active::before {
  background: var(--color-primary);
}

.model-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-muted);
  transition: var(--transition);
}

.model-card:hover .model-card-icon,
.model-card.active .model-card-icon {
  color: var(--color-primary);
  background: rgba(59, 130, 246, 0.1);
}

.model-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0; /* allows text truncation */
}

.model-card-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.model-card-info {
  flex-grow: 1;
  min-width: 0;
}

.model-card-copy,
.model-card-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  opacity: 0;
  z-index: 5;
}

.model-card:hover .model-card-copy,
.model-card:hover .model-card-delete {
  opacity: 1;
}

.model-card-copy:hover {
  color: var(--color-accent);
  background: rgba(6, 182, 212, 0.15);
  transform: scale(1.1);
}

.model-card-delete:hover {
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.15);
  transform: scale(1.1);
}

/* Loader progress styling inside model viewer */
.model-load-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* Skeleton Loading */
.skeleton-loader {
  height: 68px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, rgba(255,255,255,0.02) 25%, rgba(255,255,255,0.05) 50%, rgba(255,255,255,0.02) 75%);
  background-size: 200% 100%;
  animation: loading-skeleton 1.5s infinite;
}

@keyframes loading-skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Main Workspace */
.workspace {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* Model Viewer Canvas Panel */
.viewer-container {
  flex-grow: 1;
  position: relative;
  background-color: #05070a;
  overflow: hidden;
}

.viewer-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
  transition: transform 0.2s ease;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-color: #05070a;
}

#mainViewer {
  position: relative;
  z-index: 2;
  background: transparent !important;
}

/* AR Button override styles inside model-viewer */
.ar-btn {
  position: absolute;
  bottom: 24px;
  right: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.ar-btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: 0 4px 15px var(--color-primary-glow);
}

/* Loading Spinner inside Canvas */
.viewer-loading {
  position: absolute;
  inset: 0;
  background: rgba(7, 9, 14, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 5;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(59, 130, 246, 0.1);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

/* Empty View / Placeholder */
.no-asset-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  z-index: 4;
  text-align: center;
  padding: 32px;
}

.placeholder-icon {
  font-size: 64px;
  color: var(--text-muted);
  opacity: 0.3;
  margin-bottom: 20px;
  animation: pulse 3s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.2; }
  50% { transform: scale(1.05); opacity: 0.4; }
}

.no-asset-placeholder h2 {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.no-asset-placeholder p {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 380px;
}

/* Render Dashboard Controls */
.controls-panel {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 10;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
}

.panel-header h3 {
  font-family: var(--font-mono);
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  align-items: center;
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-item label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Ranges Styles */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
  transition: background 0.3s;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: 0 0 10px var(--color-primary-glow);
  transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--color-accent);
}

.value-tooltip {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-accent);
  min-width: 28px;
}

/* Background Selector Dots */
.bg-selectors {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.bg-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.bg-dot:hover {
  transform: scale(1.15);
}

.bg-dot.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 10px var(--color-primary-glow);
}

.custom-bg-dot {
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
}

.custom-bg-dot:hover {
  border-color: var(--color-accent);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

/* Custom Switches */
.toggle-item {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  height: 38px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.08);
  transition: .4s;
  border-radius: 12px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--color-primary);
}

input:focus + .toggle-slider {
  box-shadow: 0 0 1px var(--color-primary);
}

input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* Mobile Toggle Button */
.mobile-toggle {
  display: none;
  position: absolute;
  top: 16px;
  left: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.mobile-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--color-primary);
}

/* Sidebar Backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 140;
}

/* Responsive Styles for Mobile */
@media (max-width: 768px) {
  .app-container {
    grid-template-rows: 1fr;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    position: relative;
  }

  /* Show toggle button */
  .mobile-toggle {
    display: flex;
  }

  /* Transform Sidebar into a sliding drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    height: 100%;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 150;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.6);
    padding: 24px 20px;
  }

  /* When sidebar is active, slide it in */
  .sidebar-active .sidebar {
    transform: translateX(0);
  }

  /* Show backdrop when active */
  .sidebar-active .sidebar-backdrop {
    display: block;
  }

  .brand {
    justify-content: flex-start;
  }

  .upload-section {
    width: 100%;
  }

  .drop-zone {
    padding: 18px 12px;
  }

  .model-list {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    gap: 12px;
  }

  .model-card {
    min-width: unset;
    width: 100%;
  }

  .model-card-copy,
  .model-card-delete {
    opacity: 1;
  }

  .workspace {
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    position: relative;
    display: flex;
    flex-direction: column;
  }

  .viewer-container {
    flex-grow: 1;
    height: 100%;
    width: 100%;
  }

  /* Compact controls overlay at the bottom */
  .controls-panel {
    padding: 12px 16px 20px 16px;
    gap: 8px;
    background: rgba(14, 19, 32, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
  }

  .control-groups {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 14px;
  }

  .control-item {
    gap: 2px;
  }

  .control-item label {
    font-size: 11px;
  }

  .slider-wrapper {
    gap: 8px;
  }

  .toggle-item {
    height: auto;
    margin-top: 2px;
  }

  .ar-btn {
    bottom: 16px; /* Let model-viewer place it within viewer canvas bottom edge */
    right: 16px;
    padding: 8px 14px;
    font-size: 11px;
  }
}


