/* ==========================================================================
   VALBATER PIXEL — LED Planner Pro (Estilos Pro-AV)
   ValBater AudioVisual · Centro Técnico Audiovisual
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;600;700&display=swap');

:root {
  --radius: 0.375rem;
  --font-sans: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Modo Claro */
  --background: oklch(96.8% 0.003 240);
  --foreground: oklch(20% 0.03 250);
  --card: oklch(100% 0 0);
  --card-foreground: oklch(20% 0.03 250);
  --popover: oklch(100% 0 0);
  --popover-foreground: oklch(20% 0.03 250);
  --primary: #189BEA;
  --primary-hover: #1280c4;
  --primary-foreground: #ffffff;
  --secondary: oklch(95% 0.02 240);
  --secondary-foreground: oklch(47% 0.16 254);
  --muted: oklch(95.2% 0.004 240);
  --muted-foreground: oklch(50% 0.03 250);
  --accent: oklch(76% 0.14 225);
  --accent-foreground: oklch(20% 0.05 250);
  --destructive: #ef4444;
  --destructive-foreground: #ffffff;
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --border: oklch(91% 0.015 240);
  --input: oklch(91% 0.015 240);
  --ring: #189BEA;

  /* SVG & Plano Colors */
  --svg-cabinet-fill: #189BEA;
  --svg-cabinet-stroke: #0B1B2B;
  --svg-text-color: #0B1B2B;
  --svg-bg: #ffffff;
}

html.dark, body.dark {
  /* Modo Oscuro ValBater Pro-AV */
  --background: oklch(16% 0.006 250);
  --foreground: oklch(95% 0.01 240);
  --card: oklch(21% 0.008 250);
  --card-foreground: oklch(95% 0.01 240);
  --popover: oklch(21% 0.03 250);
  --popover-foreground: oklch(95% 0.01 240);
  --primary: #189BEA;
  --primary-hover: #38bdf8;
  --primary-foreground: #0B1B2B;
  --secondary: oklch(27% 0.04 250);
  --secondary-foreground: oklch(85% 0.08 230);
  --muted: oklch(26% 0.01 250);
  --muted-foreground: oklch(70% 0.03 245);
  --accent: oklch(76% 0.14 225);
  --accent-foreground: oklch(15% 0.03 250);
  --destructive: #f87171;
  --destructive-foreground: #ffffff;
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.15);
  --border: rgba(255, 255, 255, 0.12);
  --input: rgba(255, 255, 255, 0.15);
  --ring: #189BEA;

  --svg-cabinet-fill: #189BEA;
  --svg-cabinet-stroke: #060e17;
  --svg-text-color: #f1f5f9;
  --svg-bg: #151a24;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--foreground);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(24, 155, 234, 0.3);
  background-color: var(--card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.valbater-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius);
  background: var(--muted);
  color: var(--foreground);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.valbater-back:hover {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.brand-info {
  border-left: 2px solid var(--primary);
  padding-left: 0.75rem;
  line-height: 1.15;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--foreground);
}

.brand-title .brand-accent {
  color: var(--primary);
}

.brand-subtitle {
  margin-top: 0.125rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted-foreground);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Button groups */
.btn-group {
  display: inline-flex;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--muted);
  padding: 2px;
}

.btn-toggle {
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--foreground);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-toggle.active {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: var(--muted);
}

/* ==========================================================================
   MAIN LAYOUT
   ========================================================================== */
.main-content {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 0.75rem 1rem 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Card base */
.card-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.section-heading {
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--foreground);
  letter-spacing: -0.01em;
}

/* ==========================================================================
   PROJECT BAR
   ========================================================================== */
.project-bar-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: end;
}

@media (max-width: 900px) {
  .project-bar-grid {
    grid-template-columns: 1fr;
  }
}

.project-inputs-row {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1fr;
  gap: 0.5rem;
}

@media (max-width: 640px) {
  .project-inputs-row {
    grid-template-columns: 1fr 1fr;
  }
  .project-inputs-row label:first-child {
    grid-column: span 2;
  }
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted-foreground);
}

.form-input, .form-select {
  height: 2.25rem;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--input);
  background: var(--background);
  color: var(--foreground);
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus, .form-select:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px rgba(24, 155, 234, 0.25);
}

.project-actions-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

/* Generic Button Styles */
.btn {
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0 0.75rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

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

.btn-sm {
  height: 1.875rem;
  padding: 0 0.5rem;
  font-size: 0.75rem;
}

/* ==========================================================================
   2-COLUMN WORKSPACE (SIDEBAR + MAIN CANVAS)
   ========================================================================== */
.workspace-grid {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

@media (max-width: 1080px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

.sidebar-column {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.main-column {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ==========================================================================
   RESULTADOS (METRIC CARDS)
   ========================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

@media (max-width: 768px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.metric-card {
  background: var(--muted);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.metric-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
}

.metric-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0.15rem 0;
}

.metric-sub {
  font-size: 0.6875rem;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   PLANO (CANVAS & TOOLBAR)
   ========================================================================== */
.plano-options-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--foreground);
}

.plano-tools-bar {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius);
  background: var(--muted);
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.plano-tools-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted-foreground);
  margin-right: 0.25rem;
}

.tools-spacer {
  margin-left: auto;
  display: flex;
  gap: 0.25rem;
}

.plano-tip {
  width: 100%;
  font-size: 0.6875rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}

/* SVG Container */
.svg-plano-wrapper {
  width: 100%;
  min-height: 380px;
  max-height: 65vh;
  background: var(--svg-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
}

.svg-plano {
  width: 100%;
  height: auto;
  max-height: 58vh;
  display: block;
}

/* Interactive SVG elements */
.cabinet-rect {
  cursor: pointer;
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.cabinet-rect:hover {
  filter: brightness(1.15);
}

.ghost-cabinet-slot {
  fill: rgba(24, 155, 234, 0.08);
  stroke: rgba(24, 155, 234, 0.4);
  stroke-dasharray: 6 4;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ghost-cabinet-slot:hover {
  fill: rgba(24, 155, 234, 0.25);
  stroke: var(--primary);
}

/* ==========================================================================
   VISTA 3D
   ========================================================================== */
.threejs-viewport {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 440px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--muted);
  overflow: hidden;
  position: relative;
  touch-action: none;
}

.viewport-hint {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* ==========================================================================
   SIDEBAR CONFIG CARDS
   ========================================================================== */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.desc-text {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  line-height: 1.35;
}

/* 16:9 Chips */
.ratio-chips-wrap {
  margin-top: 0.5rem;
}

.ratio-summary {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--foreground);
  cursor: pointer;
  margin-bottom: 0.25rem;
}

.ratio-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.ratio-chip {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--foreground);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ratio-chip:hover {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

/* Alertas */
.alert-box {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  line-height: 1.35;
  margin-top: 0.5rem;
  border-left: 4px solid var(--warning);
  background: var(--warning-bg);
  color: var(--foreground);
}

/* ==========================================================================
   MODAL DIALOGS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 580px;
  width: 100%;
  padding: 1.25rem;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1rem;
  font-weight: 800;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.site-footer {
  margin-top: 2rem;
  border-top: 1px solid rgba(24, 155, 234, 0.3);
  background: var(--card);
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

.footer-link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}
