/* ==========================================================================
   AQUA PURE IV - D3 & D4 MASTER PLAN 3D DIGITAL TWIN SUITE
   100% MOBILE & TABLET RESPONSIVE STYLESHEET
   ========================================================================== */

:root {
  --bg-light: #f8fafc;
  --bg-panel: rgba(255, 255, 255, 0.94);
  --bg-card: #ffffff;
  --border-glass: rgba(2, 132, 199, 0.22);
  --border-active: #0284c7;
  
  --primary-blue: #0284c7;
  --primary-navy: #0f172a;
  --accent-cyan: #0284c7;
  --accent-green: #059669;
  --accent-amber: #d97706;
  --accent-purple: #7c3aed;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-light);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

#app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* Glassmorphism Panel Standard */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  box-shadow: 0 10px 30px 0 rgba(15, 23, 42, 0.1);
  border-radius: 12px;
}

/* Header Navbar */
#top-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  z-index: 100;
  height: 64px;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.brand-text h1 {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary-navy);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tag-d4 {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* Plan Switcher (D3 vs D4) */
.plan-switcher {
  display: flex;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 3px;
  border-radius: 10px;
  gap: 4px;
}

.plan-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.plan-btn:hover {
  color: var(--primary-blue);
  background: #e2e8f0;
}

.plan-btn.active {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);
}

/* Badges */
.nav-badges {
  display: flex;
  gap: 8px;
}

.badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-live {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: #16a34a;
  border-radius: 50%;
  box-shadow: 0 0 6px #16a34a;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

.status-fps {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
}

/* Buttons */
.btn {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  border: none;
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--primary-navy);
  border: 1px solid #cbd5e1;
}

.btn-secondary:hover {
  background: #e2e8f0;
  border-color: var(--primary-blue);
  color: var(--primary-blue);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.4);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Mobile Drawer Dropdown */
#mobile-menu-drawer {
  position: absolute;
  top: 64px;
  left: 0;
  width: 100vw;
  background: #ffffff;
  border-bottom: 1px solid #cbd5e1;
  padding: 16px;
  z-index: 99;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  transition: all 0.25s ease-in-out;
}

.drawer-hidden {
  display: none !important;
}

.mb-2 { margin-bottom: 8px; }
.w-full { width: 100%; }

/* Main Stage & Layout */
#main-stage {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

#canvas-container {
  flex: 1;
  position: relative;
  height: 100%;
  background: radial-gradient(circle at center, #ffffff 0%, #f1f5f9 100%);
}

#webgl-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Floating Toolbar Bottom (Model Switcher) */
#model-toolbar {
  position: absolute;
  bottom: 20px;
  left: 20px;
  padding: 12px 14px;
  z-index: 10;
  max-width: calc(100% - 420px);
}

.toolbar-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--primary-blue);
  margin-bottom: 8px;
}

.model-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.model-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.model-btn:hover {
  background: #e0f2fe;
  border-color: #38bdf8;
  color: #0369a1;
}

.model-btn.active {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
}

.btn-composite {
  border-color: #c084fc;
  background: #faf5ff;
  color: #7e22ce;
}

.btn-composite.active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #ffffff;
}

/* View Controls Overlay */
#view-controls {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 280px;
  padding: 16px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.control-header-mobile {
  display: none;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.control-title-mobile {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  color: var(--primary-blue);
}

.btn-close-controls {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
}

.control-group label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  color: var(--primary-blue);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--primary-blue);
  cursor: pointer;
}

.mono-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  color: var(--accent-green);
  min-width: 32px;
}

.toggle-grid, .camera-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.toggle-btn, .cam-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.toggle-btn:hover, .cam-btn:hover {
  background: #e2e8f0;
  color: var(--primary-blue);
}

.toggle-btn.active {
  background: #dcfce7;
  border-color: #86efac;
  color: #15803d;
  font-weight: 700;
}

/* Floating FAB Button (Mobile) */
.fab-btn {
  position: absolute;
  bottom: 90px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-blue);
  color: #ffffff;
  border: none;
  font-size: 18px;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.4);
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Tooltip */
#3d-tooltip {
  position: absolute;
  pointer-events: none;
  background: #ffffff;
  border: 2px solid var(--primary-blue);
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
  z-index: 20;
  transition: opacity 0.15s ease;
}

.tooltip-hidden {
  opacity: 0;
}

#tooltip-title {
  font-weight: 800;
  font-size: 12px;
  color: var(--primary-blue);
}

#tooltip-desc {
  font-size: 10px;
  color: var(--text-muted);
}

/* Right Telemetry Sidebar */
#sidebar-telemetry {
  width: 380px;
  height: calc(100vh - 64px);
  border-radius: 0;
  border-left: 1px solid #e2e8f0;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px;
  gap: 18px;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.04);
}

.sidebar-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary-navy);
  line-height: 1.3;
}

.sidebar-header p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.btn-close-sidebar {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 18px;
  color: var(--text-main);
  cursor: pointer;
}

.telemetry-section h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-navy);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #e2e8f0;
}

.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.spec-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 10px;
  border-radius: 8px;
}

.spec-val {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 800;
  color: var(--primary-blue);
}

.spec-lbl {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.layer-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-main);
  font-weight: 600;
}

.layer-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e0f2fe;
  color: #0369a1;
}

.inspector-box {
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  min-height: 90px;
}

.placeholder-msg {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
  padding: 10px 0;
}

.inspector-detail h4 {
  color: var(--primary-blue);
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 4px;
}

.inspector-detail p {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.inspector-kv {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 4px 0;
  border-bottom: 1px solid #e2e8f0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 10px;
}

/* Modal Popup */
#blueprint-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-hidden {
  display: none !important;
}

.modal-content {
  width: 95vw;
  max-width: 1150px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header h2 {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary-navy);
}

.modal-close {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  color: var(--text-main);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 8px;
  overflow-x: auto;
  white-space: nowrap;
}

.tab-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 6px;
}

.tab-btn.active {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
}

/* Visibility Utility Helpers */
.desktop-only { display: flex; }
.mobile-only { display: none !important; }

/* ==========================================================================
   MOBILE & TABLET RESPONSIVE MEDIA QUERIES (< 900px)
   ========================================================================== */

@media screen and (max-width: 900px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }

  #top-navbar {
    padding: 10px 14px;
  }

  .brand-sub { display: none; }
  .plan-btn-text { display: none; }

  .plan-btn {
    padding: 6px 10px;
  }

  /* Model Switcher Toolbar (Bottom Mobile Bar) */
  #model-toolbar {
    left: 10px;
    right: 10px;
    bottom: 14px;
    max-width: none;
    width: auto;
    padding: 8px 10px;
  }

  .toolbar-title { display: none; }

  .model-buttons {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .model-btn {
    flex: 0 0 auto;
    padding: 7px 10px;
    font-size: 10px;
  }

  /* View Controls Popup Panel on Mobile */
  #view-controls {
    position: fixed;
    top: auto;
    bottom: 80px;
    right: 14px;
    left: 14px;
    width: auto;
    display: none;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  }

  #view-controls.controls-open-mobile {
    display: flex !important;
  }

  .control-header-mobile {
    display: flex;
  }

  /* Telemetry Sidebar as Slide-Up Bottom Sheet on Mobile */
  #sidebar-telemetry {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 75vh;
    z-index: 150;
    border-top: 2px solid var(--primary-blue);
    border-left: none;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease-in-out;
  }

  .sidebar-hidden-mobile {
    transform: translateY(100%);
  }

  /* 2D Blueprint Modal on Mobile */
  .modal-content {
    width: 98vw;
    padding: 10px;
  }

  #svg-viewer {
    height: 360px;
  }
}
