/* ==========================================================================
   3D Scanner Web Studio - Dark Modern Design System
   ========================================================================== */

:root {
  --bg-dark: #0b0d10;
  --bg-surface: #14171d;
  --bg-surface-2: #1e222a;
  --bg-surface-hover: #262b35;
  --bg-glass: rgba(20, 23, 29, 0.75);
  
  --primary: #6c7cff;
  --primary-hover: #8290ff;
  --primary-glow: rgba(108, 124, 255, 0.25);
  
  --accent-cyan: #00d2ff;
  --accent-purple: #9d4edd;
  
  --text-main: #f5f7fa;
  --text-muted: #8e95a5;
  --text-dark: #585f6f;
  
  --border-light: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(108, 124, 255, 0.5);
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.2);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-surface-2);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dark);
}

/* Container & Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header & Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--primary-glow);
  font-size: 1.2rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-item {
  padding: 0.5rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: pointer;
}

.nav-item:hover, .nav-item.active {
  color: var(--text-main);
  background: var(--bg-surface-2);
}

.nav-item.active {
  color: var(--primary);
  background: rgba(108, 124, 255, 0.12);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.badge-balance {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

.badge-balance span {
  color: var(--text-muted);
  font-weight: 400;
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Views display management */
.view-panel {
  display: none;
  animation: fadeIn 0.3s ease forwards;
}

.view-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero Section */
.hero {
  background: linear-gradient(145deg, rgba(20, 23, 29, 0.9), rgba(15, 17, 22, 0.95));
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  margin-bottom: 2.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.hero::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  pointer-events: none;
}

.hero-content {
  max-width: 650px;
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  background: rgba(108, 124, 255, 0.15);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #ffffff 40%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 124, 255, 0.4);
}

.btn-secondary {
  background: var(--bg-surface-2);
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* Stats Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Section Headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Upload Page Styles */
.upload-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.form-group {
  margin-bottom: 2rem;
}

.form-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.form-input {
  width: 100%;
  padding: 0.85rem 1.2rem;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Multi-View Grid */
.views-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.view-slot {
  background: var(--bg-surface-2);
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-md);
  height: 240px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  cursor: pointer;
  overflow: hidden;
  transition: var(--transition);
}

.view-slot:hover, .view-slot.drag-over {
  border-color: var(--primary);
  background: rgba(108, 124, 255, 0.05);
}

.view-slot.has-file {
  border-style: solid;
  border-color: var(--border-light);
}

.view-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  z-index: 2;
}

.view-badge.required {
  border-left: 3px solid var(--primary);
}

.view-icon {
  font-size: 2.5rem;
  color: var(--text-dark);
  margin-bottom: 0.75rem;
  transition: var(--transition);
}

.view-slot:hover .view-icon {
  color: var(--primary);
  transform: scale(1.1);
}

.view-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.view-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.view-remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  background: rgba(239, 68, 68, 0.85);
  border: none;
  border-radius: var(--radius-full);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
}

.view-slot.has-file .view-preview {
  display: block;
}

.view-slot.has-file .view-remove-btn {
  display: flex;
}

.view-slot.has-file .view-placeholder {
  display: none;
}

/* Guidance Callout */
.guidance-callout {
  background: rgba(108, 124, 255, 0.08);
  border-left: 4px solid var(--primary);
  padding: 1.25rem 1.5rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-bottom: 2rem;
}

.guidance-title {
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.guidance-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Processing View */
.processing-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 3.5rem 2rem;
  max-width: 700px;
  margin: 2rem auto;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
}

.progress-orb {
  width: 120px;
  height: 120px;
  margin: 0 auto 2rem;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-orb-svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.progress-orb-bg {
  fill: none;
  stroke: var(--bg-surface-2);
  stroke-width: 8;
}

.progress-orb-circle {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339;
  stroke-dashoffset: 339;
  transition: stroke-dashoffset 0.4s ease;
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.progress-orb-text {
  position: absolute;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
}

.pipeline-steps {
  margin: 2.5rem 0;
  text-align: left;
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  position: relative;
}

.pipeline-step::before {
  content: '';
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  border: 2px solid var(--text-dark);
  background: var(--bg-surface);
  display: inline-block;
  flex-shrink: 0;
}

.pipeline-step.active {
  color: var(--text-main);
  font-weight: 600;
}

.pipeline-step.active::before {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.pipeline-step.completed {
  color: var(--text-muted);
}

.pipeline-step.completed::before {
  border-color: var(--success);
  background: var(--success);
}

/* Library Grid */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.model-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.model-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.model-thumb {
  height: 200px;
  background: var(--bg-surface-2);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.model-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.model-card:hover .model-thumb img {
  transform: scale(1.05);
}

.model-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--text-dark);
}

.model-status-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.model-body {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.model-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
}

.model-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}

/* 3D Studio Viewer Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal-overlay.active {
  display: flex;
}

.viewer-window {
  width: 90vw;
  height: 85vh;
  max-width: 1300px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

.viewer-header {
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-glass);
  z-index: 2;
}

.viewer-canvas-container {
  flex: 1;
  position: relative;
  background: radial-gradient(circle at center, #1b2029 0%, #0b0d10 85%);
  outline: none;
}

#three-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.viewer-controls-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  z-index: 10;
}

.viewer-controls-bar .btn {
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 2000;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 0.25s ease forwards;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

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

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

/* Responsive adjustments */
@media (max-width: 768px) {
  .navbar {
    padding: 1rem;
  }
  .nav-links {
    display: none; /* Can be expanded to mobile drawer */
  }
  .main-content {
    padding: 1rem;
  }
  .hero {
    padding: 2rem 1.5rem;
  }
  .hero h1 {
    font-size: 1.8rem;
  }
  .viewer-window {
    width: 96vw;
    height: 90vh;
  }
}
