/* =============================================
   Malla_SV — Layout y Estructura de la App
   ============================================= */

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-darker);
  color: var(--text-primary);
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ── */
#app-header {
  height: var(--header-height);
  min-height: var(--header-height);
  background: linear-gradient(to right, var(--secondary-dark), var(--secondary));
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
  z-index: 100;
  position: relative;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.header-logo .logo-icon {
  font-size: 22px;
  color: var(--primary);
}
.header-logo .logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}
.header-logo .logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 2px;
}

.header-sep {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  flex-shrink: 0;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Toolbar ── */
#toolbar {
  height: var(--toolbar-height);
  min-height: var(--toolbar-height);
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 2px;
  flex-shrink: 0;
  z-index: 90;
  overflow-x: auto;
  overflow-y: hidden;
}
#toolbar::-webkit-scrollbar { height: 4px; }
#toolbar::-webkit-scrollbar-track { background: var(--bg-dark); }
#toolbar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.toolbar-sep {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  margin: 0 4px;
  flex-shrink: 0;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-label {
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 4px;
  white-space: nowrap;
}

/* ── Main area ── */
#app-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ── Left Panel ── */
#panel-left {
  width: var(--panel-width);
  min-width: var(--panel-width);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  z-index: 50;
  transition: transform var(--transition-normal);
}

/* ── Viewport ── */
#viewport {
  flex: 1;
  min-width: 0;      /* evita overflow en flex */
  min-height: 0;
  position: relative;
  background: var(--bg-darker);
  overflow: hidden;
}

#canvas-3d {
  display: block;
  width: 100% !important;
  height: 100% !important;
  position: absolute;
  top: 0; left: 0;
}

/* CSS2D overlay for annotations */
#css2d-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: hidden;
}

/* Lasso canvas overlay */
#lasso-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Drop zone overlay */
#drop-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  background: rgba(21, 27, 32, 0.9);
  border: 2px dashed var(--primary);
  z-index: 20;
  pointer-events: none;
}
#drop-overlay.active { display: flex; }
#drop-overlay i { font-size: 48px; color: var(--primary); opacity: 0.8; }
#drop-overlay p { font-size: 18px; font-weight: 500; color: var(--text-secondary); }

/* Empty viewport hint */
#viewport-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
  z-index: 5;
}
#viewport-hint.hidden { display: none; }
#viewport-hint i { font-size: 80px; color: var(--text-muted); opacity: 0.3; }
#viewport-hint h3 { font-size: 18px; font-weight: 500; color: var(--text-muted); }
#viewport-hint p { font-size: 13px; color: var(--text-muted); opacity: 0.7; }
#viewport-hint .hint-keys { display: flex; gap: 8px; margin-top: 8px; }

/* Plane cut gizmo helper text */
#tool-hint {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(38, 50, 56, 0.9);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--primary);
  padding: 8px 16px;
  border-radius: var(--border-radius);
  font-size: 12px;
  color: var(--text-secondary);
  pointer-events: none;
  z-index: 15;
  display: none;
  white-space: nowrap;
}
#tool-hint.visible { display: block; }

/* ── Right Panel ── */
#panel-right {
  width: var(--panel-width);
  min-width: var(--panel-width);
  background: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  z-index: 50;
  transition: transform var(--transition-normal);
}

/* ── Status Bar ── */
#status-bar {
  height: var(--statusbar-height);
  min-height: var(--statusbar-height);
  background: var(--bg-dark);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 16px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'Consolas', monospace;
  z-index: 100;
  overflow: hidden;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.status-item i { font-size: 10px; }
.status-item span { color: var(--text-secondary); }
.status-sep { width: 1px; height: 14px; background: var(--border-color); }
.status-spacer { flex: 1; }
.status-tool { color: var(--primary); font-weight: 500; }

/* ── Panel Sections ── */
.panel-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.panel-scroll::-webkit-scrollbar { width: 6px; }
.panel-scroll::-webkit-scrollbar-track { background: var(--bg-dark); }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
.panel-scroll::-webkit-scrollbar-thumb:hover { background: var(--primary); }

.panel-header {
  height: 44px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
}
.panel-header i { color: var(--primary); font-size: 14px; width: 16px; text-align: center; }
.panel-header span { font-size: 13px; font-weight: 600; color: var(--text-primary); flex: 1; }
.panel-header .collapse-btn { color: var(--text-muted); cursor: pointer; transition: color var(--transition-fast); padding: 4px; }
.panel-header .collapse-btn:hover { color: var(--primary); }

.panel-section {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}
.panel-section:last-child { border-bottom: none; }

.section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-title i { font-size: 11px; width: 14px; text-align: center; }

/* Collapsible panel sections */
.collapsible-section .section-title { cursor: pointer; user-select: none; }
.collapsible-section .section-title .toggle-icon { margin-left: auto; transition: transform var(--transition-fast); }
.collapsible-section.collapsed .section-title .toggle-icon { transform: rotate(-90deg); }
.collapsible-section .section-body { overflow: hidden; transition: max-height var(--transition-normal); max-height: 2000px; }
.collapsible-section.collapsed .section-body { max-height: 0; }

/* Mobile toggles */
#mobile-left-toggle, #mobile-right-toggle {
  display: none;
  position: fixed;
  width: 50px; height: 50px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  z-index: 60;
  box-shadow: var(--shadow-lg);
  font-size: 20px;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}
#mobile-left-toggle { bottom: 20px; left: 20px; }
#mobile-right-toggle { bottom: 20px; right: 20px; }
#mobile-left-toggle:hover, #mobile-right-toggle:hover { background: var(--primary-dark); }
