@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg-app: #080c14;
  --bg-surface: #0e1422;
  --bg-surface-elevated: #151d30;
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(99, 102, 241, 0.45);
  
  --accent-cobalt: #3b82f6;
  --accent-indigo: #6366f1;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-app);
  color: #f1f5f9;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.in-chat {
  overflow: hidden;
}

/* Full View Layout & State-Driven Controls */
#chat-view {
  width: 100%;
  height: calc(100vh - 4rem);
  height: calc(100dvh - 4rem);
  display: none !important;
  flex-direction: row;
  overflow: hidden;
  position: relative;
}

body.in-chat #chat-view {
  display: flex !important;
}

body.in-chat #launchpad-view {
  display: none !important;
}

body:not(.in-chat) #chat-view,
body:not(.in-chat) #room-sidebar,
body:not(.in-chat) #sidebar-backdrop,
body:not(.in-chat) #nav-room-details,
body:not(.in-chat) #nav-room-actions {
  display: none !important;
}

body.in-chat #live-status-pill {
  display: none !important;
}

@media (max-width: 639px) {
  body.in-chat #brand-link {
    display: none !important;
  }
}

@media (max-width: 1023px) {
  body.in-chat #brand-text {
    display: none !important;
  }
}

#room-sidebar {
  width: 300px;
  flex-shrink: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #0a0e19;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 30;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#room-sidebar.collapsed {
  display: none !important;
}

#main-conversation-panel {
  flex: 1 1 0%;
  height: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #07090e;
  position: relative;
}

@media (max-width: 1023px) {
  #chat-view {
    height: calc(100vh - 4rem);
    height: calc(100dvh - 4rem);
  }
  body.in-chat #room-sidebar {
    position: fixed !important;
    top: 4rem !important;
    bottom: 0 !important;
    left: 0 !important;
    height: calc(100% - 4rem) !important;
    height: calc(100dvh - 4rem) !important;
    width: 300px !important;
    max-width: 85vw !important;
    z-index: 50 !important;
    transform: translateX(-100%) !important;
    display: flex !important;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.85);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }
  body.in-chat #room-sidebar.open,
  #room-sidebar.open {
    transform: translateX(0) !important;
  }
  #sidebar-backdrop {
    top: 4rem !important;
    height: calc(100% - 4rem) !important;
    height: calc(100dvh - 4rem) !important;
    z-index: 40 !important;
  }
}

code, pre, .font-mono {
  font-family: 'Geist Mono', monospace;
}

/* Sophisticated Graphite Backdrop with subtle structural lighting */
.bg-mesh-grid {
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.12) 0%, transparent 65%),
    radial-gradient(circle at 100% 100%, rgba(16, 185, 129, 0.06) 0%, transparent 50%),
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 48px 48px, 48px 48px;
}

/* Sleek Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Studio Glass Panels */
.studio-card {
  background: rgba(14, 20, 34, 0.78);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 16px 36px -12px rgba(0, 0, 0, 0.5);
}

.studio-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* Refined Message Bubbles */
.bubble-user {
  background: linear-gradient(135deg, #4338ca 0%, #4f46e5 50%, #6366f1 100%);
  color: #ffffff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.22);
}

.bubble-peer {
  background: rgba(21, 29, 48, 0.9);
  color: #f1f5f9;
  border-radius: 18px 18px 18px 4px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Quick Action Chips */
.quick-chip {
  background: rgba(21, 29, 48, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  transition: all 0.15s ease-out;
  white-space: nowrap;
}

.quick-chip:hover {
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(99, 102, 241, 0.35);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Avatars */
.avatar-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Emoji Drawer Tabs */
.emoji-tab-btn {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 8px;
  color: #94a3b8;
  transition: all 0.15s ease;
}
.emoji-tab-btn.active, .emoji-tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Smooth message animations */
@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-anim {
  animation: messageIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.pulse-emerald {
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
}
