:root {
  --primary: #10b981;        /* GREEN */
  --primary-hover: #059669;  /* DARK GREEN */
  --bg-color: #ffffff;
 --panel-bg: #ffffff;
  --border-color: rgba(0, 0, 0, 0.1);
  --text-main: #0f172a;
  --text-muted: #475569;
  --accent: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --card-bg: rgba(240, 242, 245, 0.95);
  --glass-bg: #ffffff;
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}

#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.hidden { display: none !important; }

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
 background-image: none;
background-color: #ffffff;
}

header {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}
.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  background-color: var(--primary);;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.main-container {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  transition: width 0.3s ease, margin 0.3s ease;
  margin: 0 auto;
  width: 100%;
}
.profile-box {
  position: relative;
}
.profile-icon {
  width: 38px;
  height: 38px;
  cursor: pointer;

  background: linear-gradient(135deg, #2563eb, #60a5fa);
  color: #fff;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(37,99,235,0.4);

  transition: all 0.3s ease;
}

.profile-icon svg {
  width: 18px;
  height: 18px;
}

.profile-icon:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 18px rgba(37,99,235,0.6);
}
.profile-menu {
  position: absolute;
  top: 50px;
  right: 0;
  width: 220px;

  background: #ffffff;
  border-radius: 12px;
  padding: 10px;

  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  border: 1px solid #eee;

  display: none;
  flex-direction: column;
  gap: 6px;

  animation: fadeIn 0.2s ease;
}

/* 🔥 HEADER */
.profile-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid #eee;
}

/* 🔥 AVATAR */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  color: #fff;

  display: flex;
  align-items: center;
  justify-content: center;

  font-weight: bold;
}

/* 🔥 EMAIL */
.email {
  font-size: 13px;
  color: #334155;
  word-break: break-all;
}

/* 🔥 MENU ITEMS */
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;

  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.menu-item svg {
  width: 16px;
  height: 16px;
}

.menu-item:hover {
  background: #f1f5f9;
}

.logout {
  color: #ef4444;
}

.logout:hover {
  background: #fee2e2;
}

.profile-menu div {
  padding: 10px;
  cursor: pointer;
}

.profile-menu div:hover {
  background: #f1f5f9;
}

/* Glassmorphism Panels */
.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(20px) saturate(160%);
  border-right: 1px solid var(--border-color);
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
  z-index: 5;
  overflow: hidden;
}

.panel:hover {
   box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.left-panel {
  width: 320px;
  min-width: 320px;
  padding: 16px;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow-y: auto;
}

/* Removed panel-scroll */


.right-panel {
  width: 360px;
  min-width: 360px;
  padding: 16px;
  border-right: none;
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* Form Elements */
.section {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  margin-bottom: 14px;
  padding: 8px;   /* IMPORTANT */
  transition: all 0.3s ease;
}

.section:hover {
   border-color: var(--primary);
  background: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -10px rgba(0,0,0,0.15);
}
.section-content {
  padding: 12px;
  background: #ffffff;
  border-radius: 10px;
}
.section:hover {
  border-color: #2563eb;
  box-shadow: 0 6px 14px rgba(0,0,0,0.08);
}
.toggle-icon {
  font-size: 0.7rem;
  color: #ffffff;   /* WHITE ICON */
}
.section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #ffffff;              /* WHITE TEXT */
  background: #2563eb;  
  padding: 12px 14px;
  font-weight: 600;

  display: flex;
  justify-content: space-between;
  align-items: center;

  border-radius: 10px;
  cursor: pointer;
}
/* COLLAPSIBLE SECTION */
.collapsible .section-body {
  display: none;
  margin-top: 10px;
}

.collapsible.active .section-body {
  display: block;
}

/* HEADER STYLE */
.section-header {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  padding: 10px;
  border-radius: 8px;
  background: #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ARROW ROTATE */
.section-header .arrow {
  transition: transform 0.3s ease;
}

.collapsible.active .arrow {
  transform: rotate(180deg);
}
/* Removed collapsible-header and toggle-icon */

.input-group {
  margin-bottom: 8px;
}

.input-group:last-child {
  margin-bottom: 0;
}

.row {
  display: flex;
  gap: 8px;
}

.row .input-group {
  flex: 1;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: all 0.2s;
  appearance: none;
}

select {
  cursor: pointer;
  background-image: url('data:image/svg+xml;utf8,<svg fill="%23334155" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 32px;
}

select option {
  background: var(--bg-color);
  color: var(--text-main);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
 background: #ffffff;
}

/* Export Button Redesign - Premium Look */
.export-group {
  display: flex;
  gap: 12px;
  width: 100%;
}

.btn-export {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 1px solid rgba(255, 255, 255, 0.15);
  position: relative;
  overflow: hidden;
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  user-select: none;
  background-size: 200% auto;
}

.btn-export svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.btn-export.pdf {
  background-image: linear-gradient(135deg, #ef4444 0%, #b91c1c 51%, #ef4444 100%);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.25);
}

.btn-export.step {
  background-image: linear-gradient(135deg, #10b981 0%, #059669 51%, #10b981 100%);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
}

.btn-export.bom {
  background-image: linear-gradient(135deg, #6366f1 0%, #4f46e5 51%, #6366f1 100%);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

.btn-export::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.25) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.btn-export:hover {
  transform: translateY(-4px) scale(1.02);
  background-position: right center;
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-export:hover::before {
  opacity: 1;
}

.btn-export:hover svg {
  transform: scale(1.1) rotate(-5deg);
}

.btn-export.pdf:hover {
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.btn-export.csv:hover {
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.btn-export:active {
  transform: translateY(0) scale(0.98);
  filter: brightness(0.9);
}

/* Removed button-footer */

/* 3D Canvas Area */
.canvas-container {
  flex: 1;
  position: relative;
   background: #ffffff;
  overflow: hidden;
}

#viewer {
  width: 100%;
  height: 100%;
}

/* Overlay UI on Canvas */
.canvas-overlay {
  position: absolute;
  top: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
  pointer-events: none;
}

.variant-selector {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s, transform 0.3s;
}

.variant-selector.active {
  opacity: 1;
  transform: translateY(0);
}

.variant-selector label {
  margin: 0;
  color: var(--text-main);
}

.variant-selector select {
  width: 200px;
  background: rgba(0, 0, 0, 0.4);
}

/* Metrics Dashboard (Right Panel) */
.metric-card {
    background: #ffffff;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  border-left: 3px solid var(--accent);
}

.metric-card.success {
  border-left-color: var(--success);
}

.metric-card.warning {
  border-left: 4px solid #f59e0b;
  background: #fff7ed;
  color: #92400e;  
  font-weight: 500;
}
.metric-card.warning b {
  color: #b45309;
}

.metric-card.warning span,
.metric-card.warning p {
  color: #78350f;
}

.metric-card.danger {
  border-left-color: var(--danger);
  animation: pulse-danger 2s infinite;
}

@keyframes pulse-danger {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.metric-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
}

.metric-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.specs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.spec-item {
   background: #ffffff;
  padding: 8px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.spec-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  display: block;
  margin-bottom: 2px;
}

hr {
  border: none;
  height: 1px;
  background: var(--border-color);
  margin: 10px 0;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ────────────────────────────────────────────────
   UI UTILITIES
   ──────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.fade-in { animation: fadeIn 0.5s ease forwards; }
.fade-out { animation: fadeOut 0.5s ease forwards; }
.shake { animation: shake 0.2s ease 2; }

/* ────────────────────────────────────────────────
   PREMIUM PRIMARY BUTTON (GENERATE)
   ──────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 12px;
  background-color: var(--primary);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 16px;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.fade-in {
  animation: fadeIn 0.4s ease forwards;
}

/* Tabs */
.tab-header {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
 background: #ffffff;
  padding: 4px;
  border-radius: 8px;
}

.tab-button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.tab-button.active {
  background: var(--panel-bg);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
}

.sim-tab-content {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.sim-tab-content canvas {
  flex: 1;
}

/* Visibility Toggles Container */
.visibility-toggles {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  font-size: 0.85rem;
  z-index: 10;
  width: max-content;
  max-width: 90%;
}

.visibility-toggles label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-color);
  margin: 0;
}

/* Custom Cell Selector Trigger */
.cell-selector-trigger {
  width: 100%;
   background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}

.cell-selector-trigger:hover {
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.08);
}

.cell-selector-trigger .chevron {
  font-size: 0.7rem;
  opacity: 0.6;
}

/* Modal Styling */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  margin: 5vh auto;
  padding: 0;
  border: 1px solid var(--border-color);
  width: 90%;
  max-width: 600px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.2rem;
  margin: 0;
}

.close-modal {
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s;
}

.close-modal:hover {
  color: var(--danger);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.search-box {
  margin-bottom: 16px;
}

.search-box input {
  padding: 10px 16px;
  font-size: 1rem;
}

.cell-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cell-item {
   background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cell-item:hover {
  background: rgba(37, 99, 235, 0.2);
  border-color: var(--primary);
  transform: translateX(4px);
}

.cell-info h4 {
  margin: 0 0 4px 0;
  color: var(--text-main);
  font-size: 0.95rem;
}

.cell-info p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.cell-type-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.08);
  text-transform: uppercase;
}

/* Responsive Layout (Automatic formatting based on screen size) */
@media (max-width: 1024px) {
  body {
    overflow-y: auto;
    /* Allow entire page to scroll on small devices */
    height: auto;
  }

  .main-container {
    flex-direction: column;
    overflow-y: visible;
  }

  .left-panel,
  .right-panel {
    width: 100% !important;
    min-width: 100% !important;
    height: auto;
    border-right: none;
    border-left: none;
    border-bottom: 1px solid var(--border-color);
    box-shadow: none;
  }

  .canvas-container {
    width: 100%;
    min-height: 400px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
  }

  #viewer {
    flex: 1;
    position: relative;
    height: 400px;
    /* Explicit height inside flex column to avoid collapse */
  }

  .visibility-toggles {
    position: relative;
    bottom: 0;
    left: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 15px;
    background: rgba(255, 255, 255, 0.95);
  }
}

