/* P5 QACIET Spatial Flow Theme
   3D deep space perspective, luminescent neural constellation networks,
   golden amber baton persistent state, electric cyan trajectories,
   violet/magenta faculties, and lime/emerald synaptic reactivations.
*/

/* Three vertical upright bars icon for theme picker */
.theme-bars-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 20px;
  height: 20px;
  vertical-align: middle;
}
.theme-bars-icon i {
  display: inline-block;
  width: 3.5px;
  height: 15px;
  border-radius: 2px;
  box-shadow: 0 0 6px currentColor;
}
.theme-bars-icon i:nth-child(1) {
  background: #ffb443;
  color: #ffb443;
  height: 11px;
}
.theme-bars-icon i:nth-child(2) {
  background: #38bdf8;
  color: #38bdf8;
  height: 16px;
}
.theme-bars-icon i:nth-child(3) {
  background: #c084fc;
  color: #c084fc;
  height: 13px;
}

/* =========================================================================
   P5 Spatial Flow Theme Specification
   ========================================================================= */
body[data-theme="p5-spatial"] {
  --bg: #03060d;
  --panel: rgba(5, 10, 22, 0.88);
  --panel2: rgba(9, 17, 34, 0.82);
  --line: rgba(56, 189, 248, 0.28);
  --text: #f0f7ff;
  --muted: #8ea8c4;
  --accent: #ffb443; /* Baton / Golden amber */
  --accent2: #38bdf8; /* Trajectory / Cyan */
  --gold: #ffb443;
  --p5-cyan: #38bdf8;
  --p5-gold: #ffb443;
  --p5-violet: #c084fc;
  --p5-magenta: #f472b6;
  --p5-lime: #4ade80;
  --cyan-glow: rgba(56, 189, 248, 0.45);
  --ice-border: rgba(56, 189, 248, 0.35);

  background:
    radial-gradient(circle at 50% 28%, rgba(255, 180, 67, 0.09) 0%, transparent 40%),
    radial-gradient(circle at 25% 65%, rgba(192, 132, 252, 0.1) 0%, transparent 45%),
    radial-gradient(circle at 75% 70%, rgba(56, 189, 248, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 50% 95%, rgba(74, 222, 128, 0.08) 0%, transparent 40%),
    linear-gradient(180deg, #020409 0%, #040813 50%, #02050b 100%);
  color: var(--text);
}

/* Multi-layered 3D Spatial Grid & Infinity Halo */
body[data-theme="p5-spatial"] .aurora {
  display: block;
  opacity: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 900px 500px at 50% 40%, rgba(255, 180, 67, 0.08), transparent 70%),
    radial-gradient(circle 350px at 20% 30%, rgba(192, 132, 252, 0.1), transparent 70%),
    radial-gradient(circle 400px at 80% 35%, rgba(56, 189, 248, 0.12), transparent 70%);
}

/* Spatial distance depth rings & perspective grid lines */
body[data-theme="p5-spatial"] .aurora:before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-radial-gradient(circle at 50% 42%, transparent 0 50px, rgba(56, 189, 248, 0.05) 51px 52px, transparent 53px 110px, rgba(255, 180, 67, 0.04) 111px 112px, transparent 113px 180px, rgba(192, 132, 252, 0.04) 181px 182px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.03) 1px, transparent 1px) 0 0 / 80px 80px,
    linear-gradient(0deg, rgba(56, 189, 248, 0.03) 1px, transparent 1px) 0 0 / 80px 80px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, black 20%, transparent 85%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, black 20%, transparent 85%);
  opacity: 0.85;
}

body[data-theme="p5-spatial"] .aurora:after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 240px at 50% 44%, rgba(255, 180, 67, 0.14) 0%, rgba(56, 189, 248, 0.08) 45%, transparent 75%);
  filter: blur(28px);
}

/* Glowing filament nodes in the aurora stream */
body[data-theme="p5-spatial"] .aurora i:nth-child(1) { color: #ffb443; } /* Gold Baton */
body[data-theme="p5-spatial"] .aurora i:nth-child(2) { color: #38bdf8; } /* Cyan Flow */
body[data-theme="p5-spatial"] .aurora i:nth-child(3) { color: #c084fc; } /* Violet Faculty */
body[data-theme="p5-spatial"] .aurora i:nth-child(4) { color: #4ade80; } /* Lime Synapse */

/* Sidebar with glowing constellation edge */
body[data-theme="p5-spatial"] aside {
  background: linear-gradient(180deg, rgba(5, 10, 24, 0.94) 0%, rgba(3, 6, 16, 0.97) 100%);
  border-right: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 6px 0 35px rgba(0, 0, 0, 0.75), inset -1px 0 0 rgba(255, 180, 67, 0.18);
  backdrop-filter: blur(26px);
  -webkit-backdrop-filter: blur(26px);
}

body[data-theme="p5-spatial"] .brand b {
  background: linear-gradient(135deg, #ffffff 10%, #ffdf9e 45%, #ffb443 85%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 24px rgba(255, 180, 67, 0.45);
}

body[data-theme="p5-spatial"] .mark {
  background: linear-gradient(135deg, #ffb443 0%, #d97706 40%, #0284c7 100%);
  color: #03060f;
  font-weight: 800;
  border: 1px solid rgba(255, 225, 165, 0.8);
  box-shadow: 0 0 25px rgba(255, 180, 67, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

body[data-theme="p5-spatial"] .new {
  background: linear-gradient(135deg, rgba(255, 180, 67, 0.22) 0%, rgba(56, 189, 248, 0.24) 100%);
  border: 1px solid rgba(255, 180, 67, 0.55);
  color: #fff6e5;
  font-weight: 700;
  box-shadow: 0 0 24px rgba(255, 180, 67, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

body[data-theme="p5-spatial"] .new:hover {
  border-color: #ffb443;
  color: #ffffff;
  box-shadow: 0 0 32px rgba(255, 180, 67, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transform: translateY(-1px);
}

/* Studio Nav Nodes */
body[data-theme="p5-spatial"] .studio-nav button {
  background: linear-gradient(145deg, rgba(9, 18, 38, 0.7) 0%, rgba(4, 9, 20, 0.8) 100%);
  border: 1px solid rgba(56, 189, 248, 0.24);
  color: #c4d7ec;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

body[data-theme="p5-spatial"] .studio-nav button:hover {
  color: #ffffff;
  border-color: #ffb443;
  background: linear-gradient(145deg, rgba(255, 180, 67, 0.18) 0%, rgba(9, 22, 46, 0.9) 100%);
  box-shadow: 0 0 18px rgba(255, 180, 67, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* Header with glowing trajectory border */
body[data-theme="p5-spatial"] header {
  background: linear-gradient(180deg, rgba(5, 11, 25, 0.9) 0%, rgba(3, 7, 18, 0.84) 100%);
  border-bottom: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 180, 67, 0.2);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

body[data-theme="p5-spatial"] .conversation-heading #status {
  color: #ffcf7a;
}
body[data-theme="p5-spatial"] .conversation-heading #status:before {
  background: #ffb443;
  box-shadow: 0 0 12px #ffb443, 0 0 20px #ffb443;
}

/* Header action buttons */
body[data-theme="p5-spatial"] .header-actions .secondary {
  background: linear-gradient(145deg, rgba(255, 180, 67, 0.1) 0%, rgba(7, 18, 38, 0.75) 100%);
  border: 1px solid rgba(255, 180, 67, 0.32);
  color: #ffeed1;
}
body[data-theme="p5-spatial"] .header-actions .secondary:hover {
  border-color: #ffb443;
  color: #ffffff;
  box-shadow: 0 0 20px rgba(255, 180, 67, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Welcome Hero with glowing Infinity Halo & Spatial Perspective */
body[data-theme="p5-spatial"] .welcome {
  border: 1px solid rgba(255, 180, 67, 0.35);
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 180, 67, 0.16) 0%, transparent 60%),
    linear-gradient(145deg, rgba(7, 15, 32, 0.88) 0%, rgba(3, 8, 18, 0.95) 100%);
  box-shadow:
    0 25px 85px rgba(0, 0, 0, 0.85),
    0 0 45px rgba(255, 180, 67, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
}

body[data-theme="p5-spatial"] .welcome h2 {
  background: linear-gradient(135deg, #ffffff 15%, #ffe6b0 50%, #ffb443 85%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(255, 180, 67, 0.45);
}

body[data-theme="p5-spatial"] .welcome .orb {
  background: radial-gradient(circle at 40% 30%, #543405 0%, #150f04 80%);
  border: 1px solid rgba(255, 180, 67, 0.75);
  box-shadow:
    0 0 45px rgba(255, 180, 67, 0.6),
    inset 0 0 22px rgba(255, 180, 67, 0.4),
    0 12px 30px rgba(0, 0, 0, 0.7);
  color: #ffb443;
}

body[data-theme="p5-spatial"] .prompts button {
  background: linear-gradient(145deg, rgba(9, 18, 38, 0.75) 0%, rgba(4, 10, 22, 0.85) 100%);
  border: 1px solid rgba(56, 189, 248, 0.28);
  color: #d1e2f6;
}
body[data-theme="p5-spatial"] .prompts button:hover {
  border-color: #38bdf8;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Chat Messages with Glowing Synaptic Lines */
body[data-theme="p5-spatial"] .assistant .avatar {
  background: linear-gradient(135deg, #ffb443 0%, #d97706 45%, #0284c7 100%);
  color: #03060f;
  font-weight: 800;
  border: 1px solid rgba(255, 226, 168, 0.8);
  box-shadow: 0 0 24px rgba(255, 180, 67, 0.65), inset 0 1px 0 #ffffff;
}

body[data-theme="p5-spatial"] .message-body {
  border: 1px solid rgba(56, 189, 248, 0.3);
  background: linear-gradient(135deg, rgba(7, 16, 36, 0.88) 0%, rgba(3, 8, 20, 0.94) 100%);
  box-shadow:
    0 14px 40px rgba(0, 0, 0, 0.65),
    0 0 24px rgba(56, 189, 248, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

body[data-theme="p5-spatial"] .message.user .message-body {
  border-color: rgba(255, 180, 67, 0.45);
  background: linear-gradient(135deg, rgba(16, 26, 52, 0.9) 0%, rgba(6, 12, 26, 0.95) 100%);
  box-shadow:
    0 14px 40px rgba(0, 0, 0, 0.7),
    0 0 25px rgba(255, 180, 67, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* Composer / Input Field */
body[data-theme="p5-spatial"] .composer {
  border: 1px solid rgba(255, 180, 67, 0.45);
  background: linear-gradient(145deg, rgba(8, 17, 36, 0.92) 0%, rgba(3, 8, 20, 0.97) 100%);
  box-shadow:
    0 22px 65px rgba(0, 0, 0, 0.85),
    0 0 32px rgba(255, 180, 67, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
}

body[data-theme="p5-spatial"] .composer:focus-within {
  border-color: #ffb443;
  box-shadow:
    0 0 38px rgba(255, 180, 67, 0.5),
    0 22px 65px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

body[data-theme="p5-spatial"] .composer #send {
  background: linear-gradient(135deg, #ffb443 0%, #d97706 45%, #0284c7 100%);
  color: #020612;
  font-weight: 800;
  box-shadow: 0 0 24px rgba(255, 180, 67, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* Sliding Panels (Settings, Agency, Memory, etc.) */
body[data-theme="p5-spatial"] .panel {
  background: linear-gradient(180deg, rgba(6, 12, 26, 0.97) 0%, rgba(3, 7, 16, 0.99) 100%);
  border-left: 1px solid rgba(255, 180, 67, 0.35);
  box-shadow: -20px 0 80px rgba(0, 0, 0, 0.9), inset 1px 0 0 rgba(56, 189, 248, 0.15);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
}

/* Codebox with glowing nodes */
body[data-theme="p5-spatial"] .codebox {
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: linear-gradient(145deg, #020611 0%, #050d22 100%);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.7), 0 0 22px rgba(56, 189, 248, 0.15);
}
body[data-theme="p5-spatial"] .codebox header {
  background: linear-gradient(90deg, rgba(9, 22, 48, 0.8) 0%, rgba(5, 12, 28, 0.8) 100%);
  border-bottom: 1px solid rgba(56, 189, 248, 0.25);
}
body[data-theme="p5-spatial"] .codebox header span {
  color: #ffcf7a;
}

/* Context meter & progress */
body[data-theme="p5-spatial"] .context-meter progress::-webkit-progress-value {
  background: linear-gradient(90deg, #ffb443, #38bdf8);
  box-shadow: 0 0 14px #ffb443;
}

/* Pulse animation matching P5 spatial glow */
body[data-theme="p5-spatial"] .pulse {
  background: #ffb443;
  box-shadow: 0 0 12px #ffb443, 0 0 24px rgba(255, 180, 67, 0.7);
}

/* =========================================================================
   Configuration Panel Theme Preview Thumbnails
   ========================================================================= */
.theme-preview-p5-spatial .theme-preview {
  background:
    radial-gradient(circle at 60% 40%, rgba(255, 180, 67, 0.25) 0%, transparent 60%),
    radial-gradient(circle at 20% 30%, rgba(192, 132, 252, 0.3) 0%, transparent 50%),
    #03060e;
  border-color: rgba(255, 180, 67, 0.4);
}
.theme-preview-p5-spatial .theme-preview i:first-child {
  background: rgba(4, 9, 20, 0.95);
  border-right: 1px solid rgba(255, 180, 67, 0.3);
}
.theme-preview-p5-spatial .theme-preview i:nth-child(2) {
  background: rgba(255, 180, 67, 0.12);
  border: 1px solid rgba(255, 180, 67, 0.4);
  box-shadow: 0 0 10px rgba(255, 180, 67, 0.3);
}
.theme-preview-p5-spatial .theme-preview i:last-child {
  background: linear-gradient(135deg, #ffb443, #38bdf8);
  box-shadow: 0 0 8px #ffb443;
}

/* Enhanced Blue Glass Preview (Theme 1) */
.theme-preview-blueglass .theme-preview {
  background: radial-gradient(circle at 65% 20%, #164e8a 0%, #06111f 75%);
  border-color: rgba(141, 205, 255, 0.35);
}
.theme-preview-blueglass .theme-preview i:first-child {
  background: rgba(10, 38, 70, 0.85);
  border-right: 1px solid rgba(141, 205, 255, 0.3);
}
.theme-preview-blueglass .theme-preview i:nth-child(2) {
  background: rgba(67, 142, 230, 0.2);
  border: 1px solid rgba(141, 205, 255, 0.4);
  box-shadow: 0 0 10px rgba(99, 184, 255, 0.3);
}
.theme-preview-blueglass .theme-preview i:last-child {
  background: linear-gradient(135deg, #b9e4ff, #438ee6);
  box-shadow: 0 0 8px #63b8ff;
}
