/* ==========================================================================
   Visor 3D y estimador de impresión STL - Estilos visuales
   ========================================================================== */

:root {
  --primary-color: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: rgba(2, 132, 199, 0.15);
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;

  --bg-app: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-header: #19243d;
  --bg-input: #0f172a;
  --border-color: #1e293b;
  --border-color-focus: #0284c7;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-heading: 'Outfit', 'Inter', sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-header: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-color-focus: #0284c7;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-wrapper {
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.tool-with-sidebar {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}

.tool-main-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Dropzone de carga */
.upload-dropzone {
  background: var(--bg-card);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-dropzone:hover, .upload-dropzone.drag-over {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dropzone-icon {
  color: var(--primary-color);
}

.dropzone-content h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--text-main);
}

.dropzone-content p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.dropzone-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 10px;
}

.btn-primary-sm {
  background: var(--primary-color);
  color: #ffffff;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary-sm:hover {
  background: var(--primary-hover);
}

.demo-separator {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.btn-demo-model {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 5px 10px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-demo-model:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Área del Visor WebGL */
.viewer-workspace {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.viewer-stage {
  position: relative;
  width: 100%;
  height: 480px;
  background: #050811;
  overflow: hidden;
}

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

.stage-overlay-hint {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(11, 15, 25, 0.75);
  backdrop-filter: blur(4px);
  color: #cbd5e1;
  font-size: 0.75rem;
  padding: 5px 12px;
  border-radius: 20px;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.viewer-float-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-ctrl-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(19, 27, 46, 0.85);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-ctrl-icon:hover {
  background: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-color);
}

/* Barra de personalización */
.render-customizer-bar {
  background: var(--bg-card-header);
  border-top: 1px solid var(--border-color);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.customizer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.customizer-item label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.input-color-box {
  -webkit-appearance: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}

.input-color-box::-webkit-color-swatch-wrapper {
  padding: 0;
}

.input-color-box::-webkit-color-swatch {
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.form-select-sm {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 5px 10px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

/* Métricas y Calculadora */
.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.analysis-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--primary-color);
}

.card-head h3 {
  font-size: 1.1rem;
  color: var(--text-main);
}

.metrics-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.m-label {
  color: var(--text-muted);
}

.m-val {
  font-family: var(--font-mono);
  color: var(--text-main);
}

/* Calculadora 3D */
.calc-inputs-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.calc-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calc-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.infill-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-slider {
  flex: 1;
  accent-color: var(--primary-color);
  cursor: pointer;
}

.slider-badge {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-color);
  min-width: 44px;
}

.mini-input-num {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  outline: none;
}

.calc-results-highlight {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.res-highlight-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.res-highlight-primary {
  border-color: var(--primary-color);
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--bg-card) 100%);
}

.res-h-title {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.res-h-num {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

.res-highlight-primary .res-h-num {
  color: var(--primary-color);
}

/* FAQ & Sidebar & Modal standard */
.faq-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.faq-section h3 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  margin-bottom: 16px;
}

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card-header);
}

.faq-question {
  padding: 14px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
  user-select: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question svg {
  transition: transform 0.2s;
  color: var(--primary-color);
}

.faq-item[open] .faq-question svg {
  transform: rotate(180deg);
}

.faq-answer {
  padding: 0 16px 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.tool-sidebar {
  width: 300px;
}

.ad-sidebar-wrapper {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ad-sidebar-card {
  width: 300px;
  min-height: 600px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad-dev-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
  color: var(--text-dim);
}

.ad-size-badge {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  background: var(--bg-card-header);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.btn-modal-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 20px 18px;
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.5;
}

.modal-footer {
  padding: 12px 18px;
  background: var(--bg-card-header);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--primary-color);
  color: #ffffff;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
}

@media (max-width: 1024px) {
  .tool-with-sidebar {
    grid-template-columns: 1fr;
  }
  .tool-sidebar {
    width: 100%;
  }
  .ad-sidebar-card {
    width: 100%;
    min-height: 250px;
  }
  .analysis-grid {
    grid-template-columns: 1fr;
  }
}
