/* ===================================================================
   LAMINAK — "Her" Theme
   Inspired by Spike Jonze's Her (2013) OS interface.
   Warm gradients, floating orb, frosted glass, pure minimal UI.
   =================================================================== */

/* ── Theme Variables ── */
body.theme-her {
  --bg:             #0a0e1a;
  --bg-card:        rgba(15, 22, 42, 0.65);
  --bg-input:       rgba(30, 41, 70, 0.5);
  --bg-hover:       rgba(56, 80, 140, 0.2);
  --border:         rgba(100, 140, 220, 0.12);
  --text:           #e8edf8;
  --text-muted:     rgba(180, 200, 240, 0.55);
  --accent:         #60a5fa;
  --accent-hover:   #93c5fd;
  --accent-dim:     rgba(96, 165, 250, 0.1);
  --user-bg:        rgba(96, 165, 250, 0.18);
  --assistant-bg:   rgba(15, 23, 42, 0.55);
  --success:        #34d399;
  --warning:        #fbbf24;
  --error:          #fb7185;
  --thinking-bg:    rgba(15, 23, 42, 0.5);
  --thinking-border: rgba(96, 165, 250, 0.15);
  --tool-bg:        rgba(15, 23, 42, 0.4);
  --tool-border:    rgba(96, 165, 250, 0.1);
  --bg-secondary:   rgba(15, 22, 42, 0.85);
  --glass:          rgba(15, 25, 50, 0.45);
  --glass-border:   rgba(100, 160, 240, 0.12);
  --orb-idle:       radial-gradient(circle, #60a5fa 0%, #3b82f6 40%, #1d4ed8 100%);
  --orb-thinking:   radial-gradient(circle, #a78bfa 0%, #7c3aed 40%, #5b21b6 100%);
  --orb-speaking:   radial-gradient(circle, #34d399 0%, #10b981 40%, #059669 100%);
  --orb-listening:  radial-gradient(circle, #fb923c 0%, #f97316 40%, #ea580c 100%);
  --orb-error:      radial-gradient(circle, #fb7185 0%, #f43f5e 40%, #e11d48 100%);
}

/* ── Animated Background ── */
body.theme-her {
  background: #0a0e1a;
  overflow: hidden;
}

body.theme-her::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 60% at 20% 80%, rgba(59, 130, 246, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 90% 70% at 50% 50%, rgba(30, 58, 138, 0.05) 0%, transparent 70%),
    linear-gradient(170deg, #0a0e1a 0%, #0f172a 50%, #0a0e1a 100%);
  animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0%   { opacity: 1; }
  50%  { opacity: 0.85; }
  100% { opacity: 1; }
}

/* ── Header — frosted glass ── */
body.theme-her header {
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--glass-border);
  padding: 8px 20px;
}

body.theme-her .logo-icon {
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  border-radius: 50%;
  font-size: 13px;
}

/* ── Sidebar — frosted glass drawer ── */
body.theme-her .sidebar {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border-right: 1px solid var(--glass-border);
}

/* In Her theme on desktop: sidebar is hidden by default, shown via hamburger */
@media (min-width: 769px) {
  body.theme-her .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 102;
    width: min(300px, 80vw);
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 6px 0 40px rgba(0, 0, 0, 0.5);
  }
  body.theme-her .sidebar.her-open {
    transform: translateX(0);
  }
  body.theme-her .chat-layout {
    /* Full width for chat when sidebar is a drawer */
  }
  body.theme-her .hamburger-btn {
    display: flex !important;
  }
  body.theme-her #her-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 101;
    backdrop-filter: blur(4px);
  }
  body.theme-her #her-backdrop.visible {
    display: block;
  }
}

body.theme-her .sidebar-header {
  border-bottom: 1px solid var(--glass-border);
}
body.theme-her .sidebar-footer {
  border-top: 1px solid var(--glass-border);
}
body.theme-her .proj-bar {
  border-bottom: 1px solid var(--glass-border);
}

/* ── Hamburger Button ── */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.hamburger-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--bg-hover);
}
.hamburger-btn svg {
  width: 18px;
  height: 18px;
}

/* ── The Orb ── */
.orb-container {
  display: none;
  position: relative;
  width: 100%;
  flex: 1;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

body.theme-her .orb-container {
  display: flex;
}

.orb {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--orb-idle);
  box-shadow:
    0 0 40px rgba(96, 165, 250, 0.3),
    0 0 80px rgba(96, 165, 250, 0.15),
    inset 0 0 20px rgba(255, 255, 255, 0.1);
  animation: orbFloat 4s ease-in-out infinite, orbGlow 3s ease-in-out infinite alternate;
  transition: background 0.8s ease, box-shadow 0.8s ease, width 0.4s ease, height 0.4s ease;
}

.orb::after {
  content: '';
  position: absolute;
  inset: 15%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.2), transparent 60%);
}

/* Orb ring — outer glow ring */
.orb-ring {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 1px solid rgba(96, 165, 250, 0.15);
  animation: orbRingPulse 4s ease-in-out infinite;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@keyframes orbFloat {
  0%, 100% { transform: translateY(0px); }
  50%      { transform: translateY(-12px); }
}

@keyframes orbGlow {
  0%   { box-shadow: 0 0 40px rgba(96, 165, 250, 0.3),  0 0 80px rgba(96, 165, 250, 0.1); }
  100% { box-shadow: 0 0 60px rgba(96, 165, 250, 0.45), 0 0 120px rgba(96, 165, 250, 0.2); }
}

@keyframes orbRingPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1);   opacity: 0.4; }
  50%      { transform: translate(-50%, -50%) scale(1.15); opacity: 0.1; }
}

/* ── Orb States ── */
.orb.thinking {
  background: var(--orb-thinking);
  box-shadow:
    0 0 50px rgba(167, 139, 250, 0.4),
    0 0 100px rgba(167, 139, 250, 0.15),
    inset 0 0 20px rgba(255, 255, 255, 0.1);
  animation: orbFloat 2s ease-in-out infinite, orbSpin 3s linear infinite, orbGlowThinking 2s ease-in-out infinite alternate;
  width: 90px;
  height: 90px;
}

.orb.thinking ~ .orb-ring {
  border-color: rgba(167, 139, 250, 0.2);
  animation: orbRingPulse 2s ease-in-out infinite;
}

@keyframes orbSpin {
  0%   { border-radius: 50% 45% 50% 45%; }
  25%  { border-radius: 45% 50% 45% 50%; }
  50%  { border-radius: 50% 45% 50% 45%; }
  75%  { border-radius: 45% 50% 45% 50%; }
  100% { border-radius: 50% 45% 50% 45%; }
}

@keyframes orbGlowThinking {
  0%   { box-shadow: 0 0 50px rgba(167, 139, 250, 0.35), 0 0 100px rgba(167, 139, 250, 0.1); }
  100% { box-shadow: 0 0 70px rgba(167, 139, 250, 0.5),  0 0 140px rgba(167, 139, 250, 0.2); }
}

.orb.speaking {
  background: var(--orb-speaking);
  box-shadow:
    0 0 50px rgba(52, 211, 153, 0.35),
    0 0 100px rgba(52, 211, 153, 0.12),
    inset 0 0 20px rgba(255, 255, 255, 0.1);
  animation: orbFloat 3s ease-in-out infinite, orbPulseSpeak 0.6s ease-in-out infinite alternate;
}

.orb.speaking ~ .orb-ring {
  border-color: rgba(52, 211, 153, 0.2);
}

@keyframes orbPulseSpeak {
  0%   { transform: scale(1); }
  100% { transform: scale(1.08); }
}

.orb.listening {
  background: var(--orb-listening);
  box-shadow:
    0 0 50px rgba(251, 146, 60, 0.35),
    0 0 100px rgba(251, 146, 60, 0.12),
    inset 0 0 20px rgba(255, 255, 255, 0.1);
  animation: orbFloat 3s ease-in-out infinite, orbPulseListen 1s ease-in-out infinite;
}

.orb.listening ~ .orb-ring {
  border-color: rgba(251, 146, 60, 0.2);
  animation: orbRingPulse 1.5s ease-in-out infinite;
}

@keyframes orbPulseListen {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}

.orb.error {
  background: var(--orb-error);
  box-shadow:
    0 0 50px rgba(251, 113, 133, 0.4),
    0 0 100px rgba(251, 113, 133, 0.15),
    inset 0 0 20px rgba(255, 255, 255, 0.1);
  animation: orbFloat 4s ease-in-out infinite, orbShake 0.5s ease-in-out;
}

@keyframes orbShake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-5px); }
  75%      { transform: translateX(5px); }
}

/* ── Orb label (small text below orb) ── */
.orb-label {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  opacity: 0.6;
  letter-spacing: 0.5px;
  transition: opacity 0.3s, color 0.3s;
}

/* ── Chat area — the orb replaces the static welcome ── */
body.theme-her .welcome {
  /* Hide text welcome in Her theme when orb is visible */
}

body.theme-her .welcome h3,
body.theme-her .welcome p {
  display: none;
}

/* Show suggestions below the orb */
body.theme-her .welcome .suggestions {
  position: relative;
  z-index: 1;
}

body.theme-her .welcome .welcome-greeting {
  display: block;
  color: rgba(180, 200, 240, 0.7);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.2px;
}

body.theme-her .welcome .welcome-stats {
  display: block;
}

/* ── Messages — cleaner, more spacious ── */
body.theme-her .messages {
  padding: 20px 32px;
  gap: 20px;
}

body.theme-her .msg-body {
  border-radius: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body.theme-her .msg.user .msg-body {
  background: rgba(96, 165, 250, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.15);
  border-bottom-right-radius: 4px;
}

body.theme-her .msg.assistant .msg-body {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(100, 140, 220, 0.1);
  border-bottom-left-radius: 4px;
}

body.theme-her .msg-avatar {
  border-radius: 50%;
}

body.theme-her .msg.assistant .msg-avatar {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
}

/* ── Input area — frosted glass ── */
body.theme-her .input-area {
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-top: 1px solid var(--glass-border);
}

body.theme-her #msg-input {
  background: rgba(15, 25, 50, 0.4);
  border: 1px solid rgba(100, 160, 240, 0.15);
  border-radius: 20px;
  padding: 12px 18px;
}

body.theme-her #msg-input:focus {
  border-color: rgba(96, 165, 250, 0.4);
  box-shadow: 0 0 20px rgba(96, 165, 250, 0.1);
}

body.theme-her .send-btn {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  border-radius: 50%;
}

body.theme-her .stop-btn {
  border-radius: 50%;
}

body.theme-her .mic-btn {
  border-radius: 50%;
}

/* ── Suggestion pills — glass style ── */
body.theme-her .suggestion {
  background: rgba(15, 25, 50, 0.4);
  border: 1px solid rgba(100, 160, 240, 0.12);
  border-radius: 24px;
  backdrop-filter: blur(8px);
  transition: all 0.2s;
}

body.theme-her .suggestion:hover {
  background: rgba(96, 165, 250, 0.1);
  border-color: rgba(96, 165, 250, 0.3);
  color: var(--accent);
  box-shadow: 0 0 20px rgba(96, 165, 250, 0.1);
}

/* ── Auth screen — gradient + glass ── */
body.theme-her #auth-screen {
  background:
    radial-gradient(ellipse 60% 50% at 50% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 70%);
}

body.theme-her .auth-card {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid var(--glass-border);
}

/* ── Connect screen ── */
body.theme-her #connect-screen {
  background: #0a0e1a;
}

body.theme-her #connect-screen .big-spinner {
  border-color: rgba(96, 165, 250, 0.15);
  border-top-color: #60a5fa;
}

/* ── Thinking blocks — translucent ── */
body.theme-her .thinking-block {
  background: rgba(15, 25, 50, 0.35);
  border-color: rgba(96, 165, 250, 0.1);
  backdrop-filter: blur(8px);
}

body.theme-her .tool-block {
  background: rgba(15, 25, 50, 0.3);
  border-color: rgba(96, 165, 250, 0.08);
  backdrop-filter: blur(8px);
}

/* ── Files panel — glass ── */
body.theme-her .files-panel {
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-left: 1px solid var(--glass-border);
}

/* ── Memory panel — glass ── */
body.theme-her .memory-panel {
  background: rgba(15, 22, 42, 0.85);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid var(--glass-border);
}

/* ── Permission modal — glass ── */
body.theme-her .perm-card {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid var(--glass-border);
}

/* ── Scrollbars — subtle ── */
body.theme-her ::-webkit-scrollbar {
  width: 4px;
}
body.theme-her ::-webkit-scrollbar-thumb {
  background: rgba(96, 165, 250, 0.15);
  border-radius: 2px;
}
body.theme-her ::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Project pills — glass ── */
body.theme-her .proj-pill {
  border-color: rgba(100, 160, 240, 0.12);
  background: rgba(15, 25, 50, 0.3);
}

body.theme-her .proj-pill:hover,
body.theme-her .proj-pill.active {
  border-color: rgba(96, 165, 250, 0.3);
  background: rgba(96, 165, 250, 0.08);
}

/* ── Code blocks ── */
body.theme-her .msg-body pre {
  background: rgba(6, 8, 16, 0.6);
  border-color: rgba(100, 140, 220, 0.1);
}

/* ── Theme switcher button ── */
.theme-switcher {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}
.theme-switcher:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Responsive — Her theme mobile ── */
@media (max-width: 768px) {
  body.theme-her .sidebar {
    background: var(--glass);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
  }

  /* Her sidebar responds to her-open on mobile too */
  body.theme-her .sidebar.her-open {
    transform: translateX(0);
    box-shadow: 6px 0 30px rgba(0,0,0,0.5);
  }

  /* Her backdrop works on mobile too */
  body.theme-her #her-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 101;
    backdrop-filter: blur(4px);
  }
  body.theme-her #her-backdrop.visible {
    display: block;
  }

  /* Hide the old 3-button mobile toolbar — replaced by header buttons */
  body.theme-her #mobile-toolbar {
    display: none !important;
  }

  /* Hide desktop-only header items on mobile */
  body.theme-her .user-badge,
  body.theme-her .header-signout,
  body.theme-her #files-toggle {
    display: none !important;
  }

  /* Show the mobile files button in header */
  body.theme-her .mob-header-files {
    display: flex !important;
    width: 36px; height: 36px;
    color: var(--text-muted);
  }
  body.theme-her .mob-header-files:hover {
    color: var(--text);
  }

  /* Show user info + logout in sidebar footer */
  body.theme-her .sidebar-user-row {
    display: flex;
  }

  body.theme-her .messages {
    padding: 12px 16px;
  }

  .orb {
    width: 60px;
    height: 60px;
  }

  .orb-ring {
    width: 90px;
    height: 90px;
  }

  body.theme-her .hamburger-btn {
    display: flex !important;
  }
}

/* Hide theme switcher on mobile portrait */
@media (max-width: 768px) and (orientation: portrait) {
  body.theme-her .theme-switcher {
    display: none !important;
  }
}

/* ── Transition between themes ── */
body {
  transition: background 0.5s ease, color 0.3s ease;
}

header, .sidebar, .input-area, .files-panel, .auth-card, .msg-body {
  transition: background 0.5s ease, border-color 0.3s ease, backdrop-filter 0.3s ease;
}
