/* ==========================================
   MAIN APP FRAME & GLASSMORPHIC HUD LAYOUT
   ========================================== */

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

button {
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  outline: none;
  color: inherit;
  box-shadow: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--ui-font-family);
  background-color: var(--bg-color);
  color: var(--ui-text-primary);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* App Master Layout */
#app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* Header HUD Bar */
.hud-header {
  position: absolute;
  top: 20px;
  left: 24px;
  right: 400px;
  z-index: 100;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.hud-header.hud-hidden {
  opacity: 0 !important;
  transform: translateY(-30px) !important;
  pointer-events: none !important;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ui-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--ui-border);
  padding: 10px 14px 10px 18px;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
}

.hud-hide-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: var(--ui-text-muted);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 6px;
  transition: all 0.2s ease;
  pointer-events: auto;
}

.hud-hide-btn:hover {
  background: rgba(255, 75, 110, 0.25);
  border-color: rgba(255, 75, 110, 0.5);
  color: #ff4b6e;
}

.brand-icon {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #ff7b38, #ff3377);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(255, 123, 56, 0.4);
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #ffffff, #cfd8e8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--ui-text-muted);
  font-weight: 500;
}

.meta-tags {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.meta-chip {
  background: var(--ui-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--ui-border);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ui-text-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.meta-chip.highlight {
  border-color: rgba(255, 123, 56, 0.4);
  color: var(--ui-accent);
}

.dot-indicator {
  width: 8px;
  height: 8px;
  background-color: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 8px #22c55e;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

/* Main Viewport Art Stage */
#art-stage {
  flex: 1;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  perspective: 1200px;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Glassmorphic Control Deck Sidebar */
.control-sidebar {
  position: relative;
  width: 360px;
  height: calc(100vh - 40px);
  margin: 20px 20px 20px 0;
  background: var(--ui-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--ui-border);
  border-radius: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.control-sidebar.collapsed {
  position: absolute;
  top: 0;
  right: 20px;
  margin: 20px 0 0 0;
  width: 250px;
  height: 52px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ui-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease, border-color 0.3s ease;
}

.sidebar-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.control-sidebar.collapsed .sidebar-header {
  border-bottom-color: transparent;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.collapse-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  width: 26px;
  height: 26px;
  border-radius: 8px;
  color: var(--ui-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.collapse-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--ui-text-primary);
}

.chevron-icon {
  font-size: 10px;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.control-sidebar.collapsed .chevron-icon {
  transform: rotate(-180deg);
}

.control-sidebar.collapsed .sidebar-body {
  display: none !important;
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Scrollbar Styling */
.sidebar-body::-webkit-scrollbar {
  width: 6px;
}

.sidebar-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.control-group-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ui-text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Switch & Toggle Controls */
.topping-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toggle-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 8px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.toggle-card.active {
  background: rgba(255, 123, 56, 0.12);
  border-color: var(--ui-accent);
}

.toggle-info {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.toggle-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.toggle-label {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.switch {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 18px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-knob {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: .3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 20px;
}

.slider-knob:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
}

input:checked + .slider-knob {
  background-color: var(--ui-accent);
  box-shadow: 0 0 10px var(--ui-accent-glow);
}

input:checked + .slider-knob:before {
  transform: translateX(14px);
}

/* Preset Buttons & Mode Pills */
.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px;
  border-radius: 10px;
  color: var(--ui-text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.preset-btn.active {
  background: var(--ui-accent);
  border-color: var(--ui-accent);
  color: #fff;
  box-shadow: 0 4px 16px var(--ui-accent-glow);
}

/* Action Buttons (Wireframe, Audio, Stats) */
.action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.action-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--ui-text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--ui-text-primary);
  transform: translateY(-1px);
}

.action-btn.wireframe-active {
  background: rgba(0, 240, 255, 0.15);
  border-color: #00f0ff;
  color: #00f0ff;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.35);
}

.action-btn.audio-active {
  background: rgba(34, 197, 94, 0.15);
  border-color: #22c55e;
  color: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.35);
}

/* CSS Techniques Stats Drawer */
.stats-drawer {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

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

.stat-value {
  font-weight: 700;
  color: #38bdf8;
  font-family: monospace;
}

/* Footer Credits */
.sidebar-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--ui-border);
  font-size: 11px;
  color: var(--ui-text-muted);
  text-align: center;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  #app-container {
    flex-direction: column;
  }
  .control-sidebar {
    width: calc(100vw - 40px);
    height: 300px;
    margin: 20px;
  }
  .hud-header {
    right: 24px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}
