@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg-main: #060913;
  --bg-card: rgba(13, 20, 38, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.15);
  
  --primary: #06b6d4;      /* Cyan */
  --primary-glow: rgba(6, 182, 212, 0.3);
  --secondary: #6366f1;    /* Indigo */
  --secondary-glow: rgba(99, 102, 241, 0.3);
  --accent: #ec4899;       /* Pink */
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --glass-blur: 16px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  position: relative;
}

/* Background Glowing Orbs */
body::before, body::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  filter: blur(150px);
  z-index: -1;
  opacity: 0.3;
  pointer-events: none;
}

body::before {
  background: var(--primary);
  top: -100px;
  left: -100px;
  animation: floatOrb 12s ease-in-out infinite alternate;
}

body::after {
  background: var(--secondary);
  bottom: -150px;
  right: -100px;
  animation: floatOrb 16s ease-in-out infinite alternate-reverse;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(60px, 40px) scale(1.1); }
}

/* Application Layout */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* Left Sidebar - Control Panel */
.sidebar {
  width: 400px;
  height: 100%;
  background: var(--bg-card);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  box-shadow: 20px 0 80px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  z-index: 10;
  transition: var(--transition-smooth);
}

/* Scrollbar Customization */
.sidebar::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Header Design */
.app-header {
  padding: 30px 24px 20px;
  border-bottom: 1px solid var(--border-color);
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--primary-glow);
}

.brand-icon svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 40%, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Form Sections */
.control-sections {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-weight: 700;
  border-left: 2.5px solid var(--primary);
  padding-left: 10px;
  margin-bottom: 4px;
}

/* Input Fields Styling */
.input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.value-badge {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  background: rgba(6, 182, 212, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(6, 182, 212, 0.2);
  min-width: 50px;
  text-align: center;
}

/* Styled Dropdown */
select {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: var(--transition-smooth);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

/* Custom Range Input (Slider) */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 3px;
  outline: none;
  margin: 10px 0;
  transition: var(--transition-smooth);
}

input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 20px;
  width: 20px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
  cursor: pointer;
  margin-top: -7px;
  box-shadow: 0 0 10px var(--primary-glow), 0 4px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s ease, background-color 0.2s ease;
}

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

input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.1);
  background-color: var(--secondary);
  border-color: var(--secondary);
}

/* Material selector styling as cards */
.material-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.material-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.material-card.active {
  border-color: var(--secondary);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: 0 0 15px var(--secondary-glow);
}

.material-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.material-spec {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Result Panel - Bottom of Sidebar */
.result-panel {
  padding: 24px;
  border-top: 1px solid var(--border-color);
  background: rgba(11, 15, 25, 0.4);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.result-card {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.12), rgba(99, 102, 241, 0.12));
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.result-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.result-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 4px;
}

.result-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.result-unit {
  font-size: 1.1rem;
  color: var(--primary);
  font-weight: 600;
  margin-left: 4px;
}

/* Detailed List in Results */
.details-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.detail-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.detail-label {
  color: var(--text-secondary);
}

.detail-value {
  color: var(--text-primary);
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
}

/* 3D Viewport on Right */
.viewport-container {
  flex: 1;
  height: 100%;
  position: relative;
  background-color: #030509;
}

#canvas3d {
  width: 100%;
  height: 100%;
  display: block;
}

/* UI overlay inside Viewport */
.viewport-overlay {
  position: absolute;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.overlay-card {
  pointer-events: auto;
  background: rgba(13, 20, 38, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.control-btn {
  pointer-events: auto;
  background: rgba(13, 20, 38, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 10px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.control-btn:hover {
  border-color: var(--primary);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.25);
}

.control-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Visual controls - bottom right */
.visual-controls {
  position: absolute;
  bottom: 24px;
  right: 24px;
  display: flex;
  gap: 12px;
}

/* Legend inside 3D Viewport */
.legend-panel {
  position: absolute;
  bottom: 24px;
  left: 24px;
  background: rgba(13, 20, 38, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 700;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-color.pole1 { background-color: var(--primary); box-shadow: 0 0 8px var(--primary); }
.legend-color.pole2 { background-color: var(--secondary); box-shadow: 0 0 8px var(--secondary); }
.legend-color.pole3 { background-color: var(--accent); box-shadow: 0 0 8px var(--accent); }
.legend-color.fabric { background-color: rgba(255, 255, 255, 0.15); border: 1px dashed rgba(255, 255, 255, 0.4); }

/* Quick Mode Guide Modal or Info Banner */
.info-banner {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.1));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.info-banner svg {
  width: 16px;
  height: 16px;
  fill: var(--secondary);
  flex-shrink: 0;
  margin-top: 2px;
}

/* Animations and Responsive Styles */
@media (max-width: 900px) {
  body {
    flex-direction: column;
    overflow-y: auto;
  }
  .app-container {
    flex-direction: column;
    height: auto;
  }
  .sidebar {
    width: 100%;
    height: auto;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .viewport-container {
    width: 100%;
    height: 500px;
  }
  .viewport-overlay {
    top: 16px;
    right: 16px;
  }
  .visual-controls {
    bottom: 16px;
    right: 16px;
  }
  .legend-panel {
    bottom: 16px;
    left: 16px;
  }
}
