/* Inherits variables from premium.css, but we define specifics here */
:root {
  /* Override or specific chat interactions */
  --sidebar-width: 280px;
  --header-height: 70px;
  --chat-bg: #050505;
}

body {
  background: var(--bg-main);
  color: var(--text-primary);
  /* disable scrolling on body, handle in app */
  overflow: hidden;
  font-family: 'Inter', sans-serif;
}

/* Layout Grid */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar chat";
  height: 100vh;
  background: var(--bg-main);
}

.app.sidebar-hidden {
  grid-template-columns: 0px 1fr;
}

/* Sidebar */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-surface);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
}

.brand {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--header-height);
  border-bottom: 1px solid var(--glass-border);
}

.logo {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: white;
  font-size: 1.3rem;
  /* Removed box styles */
  background: transparent;
  box-shadow: none;
  width: auto;
  height: auto;
}

.logo img {
  height: 40px;
  width: auto;
}

.side-actions {
  padding: 1rem;
}

.btn {
  width: 100%;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--brand-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(217, 37, 37, 0.3);
}

.btn-primary:hover {
  background: var(--brand-secondary);
  transform: translateY(-1px);
}


.hidden {
  display: none !important;
}

.convos {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

/* Scrollbar styles */
.convos::-webkit-scrollbar {
  width: 4px;
}

.convos::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 4px;
}

.convo {
  padding: 0.8rem 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: 0.2s;
  border-left: 2px solid transparent;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.convo:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

.convo.active {
  background: rgba(255, 255, 255, 0.05);
  color: white;
  border-left-color: white;
}

.sidebar-bottom {
  padding: 1rem;
  border-top: 1px solid var(--glass-border);
  background: var(--bg-surface-2);
}

.btn-ghost,
.btn-upgrade,
.btn-warn {
  background: transparent;
  color: var(--text-secondary);
  justify-content: flex-start;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.btn-upgrade {
  color: #FBBF24;
}

.btn-upgrade:hover {
  background: rgba(251, 191, 36, 0.1);
}

.btn-warn:hover {
  color: #EF4444;
  background: rgba(239, 68, 68, 0.1);
}


/* Topbar - Centered Upgrade Button */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: rgba(5, 5, 5, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 40;
  position: relative;
  /* Needed for absolute centering */
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Sidebar Toggle - Glass Style */
.sidebar-toggle {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: white;
  cursor: pointer;
  padding: 0.6rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.topbar-title-main {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
}

.btn-get-pro {
  background: var(--grad-brand);
  color: white;
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(217, 37, 37, 0.4);
  transition: 0.3s;

  /* Absolute Center */
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.btn-get-pro:hover {
  filter: brightness(1.1);
  transform: translateX(-50%) scale(1.02);
}

@media (max-width: 480px) {
  .btn-get-pro {
    padding: 0.4rem 0.5rem;
    min-width: 0;
  }

  .btn-get-pro [data-lang] {
    display: none;
  }
}

@media (max-width: 768px) {
  .btn-get-pro {
    position: static;
    transform: none;
    margin: 0;
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    order: 2;
    /* Put it after lang toggle or before? */
  }

  .btn-get-pro:hover {
    transform: scale(1.02);
  }
}

.lang-toggle-container {
  display: flex;
  align-items: center;
}

.lang-toggle-desktop {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50px;
  padding: 2px;
  height: 32px;
  border: 1px solid var(--glass-border);
}

.lang-toggle-btn {
  padding: 0 12px;
  font-size: 0.8rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  border-radius: 50px;
  cursor: pointer;
  transition: 0.2s;
}

.lang-toggle-btn.active {
  background: var(--brand-primary);
  color: white;
}

.icon-toggle-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

.icon-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-login {
  background: var(--bg-surface);
  color: white;
  border: 1px solid var(--glass-border);
  padding: 0.5rem 1.2rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.3s;
  position: relative;
}

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


/* Chat Area */
.chat {
  grid-area: chat;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  /* Important for scrolling inside wrapper */
}

/* Ambient Background */
.chat::before {
  content: '';
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(217, 37, 37, 0.15) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  filter: blur(80px);
}

.chat-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scroll-behavior: smooth;
  z-index: 1;
}

.chat-inner {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  padding: 2rem;
  flex: 1;
}

.composer-heading-wrapper {
  text-align: center;
  margin-top: 15vh;
  animation: fadeIn 0.8s ease;
}

.composer-heading {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1rem;
  background: linear-gradient(to right, #fff, #999);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  /* Fix for chopped letters (ikars) */
  line-height: 1.5;
  padding: 0.1em 0;
}

.composer-subheading {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Messages */
.msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 2rem;
  gap: 0;
  animation: slideUp 0.3s ease;
}

.msg.user {
  align-items: flex-end;
}

.bubble {
  max-width: 80%;
  padding: 0.8rem 1.5rem;
  border-radius: 18px;
  font-size: 1rem;
  line-height: 1.6;
  position: relative;
}

.msg.user .bubble {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px 18px 0 18px;
  /* Removed Red Shadow */
  box-shadow: none;
}

.msg.ai .bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  border-radius: 18px 18px 18px 0;
}

.bubble-actions {
  margin-top: 2px;
  display: flex;
  gap: 0.5rem;
  opacity: 0;
  transition: 0.2s;
}

.msg:hover .bubble-actions {
  opacity: 1;
}

.bubble-actions button {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.bubble-actions button:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}


/* Composer Input Area */
.composer {
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(to top, #050505 80%, transparent);
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.composer-box {
  width: 100%;
  max-width: 800px;
  position: relative;
}

.input-wrapper {
  position: relative;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  transition: 0.3s;
}

.input-wrapper:focus-within {
  /* CHANGED: White border instead of brand red */
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
}

#bottomInput {
  width: 100%;
  min-height: 60px;
  max-height: 200px;
  padding: 18px 60px 18px 25px;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  color: white;
  resize: none;
  outline: none;
  overflow-y: hidden;
}

/* Send Button - Refined */
.send-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  /* Glass background */
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: var(--brand-primary);
  /* Red icon */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s;
}

.send-btn:hover {
  background: var(--brand-primary);
  color: white;
  transform: scale(1.1);
  border-color: var(--brand-primary);
}

.send-btn:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: #555;
  border-color: transparent;
  cursor: default;
  transform: none;
}

.stop-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 40px;
  height: 40px;
  background: #EF4444;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* Loading / Suggestions */
.suggestions-wrapper {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  width: 100%;
}

.quick-actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  justify-content: center;
}

.quick-action {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  padding: 0.8rem 1.5rem;
  border-radius: 50px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: 0.3s;
  font-size: 0.9rem;
}

.quick-action:hover {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
  transform: translateY(-2px);
}

/* Animations */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Utils */
.hidden {
  display: none !important;
}

/* Mobile Optimization */
@media (max-width: 768px) {

  /* Use active viewport height to handle mobile browser bars */
  .app {
    height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: 60px 1fr;
    grid-template-areas: "topbar" "chat";
  }

  /* Improved Sidebar */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: 85%;
    max-width: 300px;
    z-index: 10000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    background: var(--bg-surface);
    border-right: 1px solid var(--glass-border);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Overlay when sidebar is open */
  .sidebar.mobile-open::after {
    content: '';
    position: fixed;
    top: 0;
    left: 100%;
    /* Start from right edge of sidebar */
    width: 100vw;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.7);
    z-index: -1;
  }

  /* Resizer hidden on mobile */
  .resizer {
    display: none;
  }

  /* Typography & Spacing */
  .composer-heading {
    font-size: 1.5rem;
    margin-top: 1rem;
  }

  .composer-subheading {
    font-size: 0.95rem;
  }

  .text-truncate {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* Hide desktop language toggle, show mobile icon on mobile */
  .lang-toggle-desktop {
    display: none !important;
  }

  .lang-toggle-mobile {
    display: block !important;
  }

  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: block !important;
  }

  /* Make user profile compact on mobile */
  .clickable-profile {
    padding: 2px !important;
    background: transparent !important;
    border: none !important;
  }

  .clickable-profile i {
    display: none !important;
  }

  .topbar-right {
    gap: 0.5rem !important;
    gap: 0.4rem !important;
    flex: 1;
    justify-content: flex-end;
  }

  /* Fix topbar on mobile */
  .topbar {
    z-index: 50;
    padding: 0 0.5rem;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
  }

  /* Upgrade button on mobile */
  .btn-get-pro {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    max-width: none;
    white-space: nowrap;
    width: auto;
  }

  /* Compact Sign In on mobile */
  .btn-login {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.75rem !important;
  }

  .btn-login span {
    display: none;
    /* Hide 'Sign In' text, keep icon */
  }

  .btn-login i {
    margin: 0 !important;
    font-size: 1rem;
  }

  /* Hide "Muon AI" text on mobile to save space */
  .topbar-title-main {
    display: none;
  }
}

.mobile-only {
  display: none;
}

/* Desktop: Show desktop toggle, hide mobile */
.lang-toggle-desktop {
  display: flex;
}

.lang-toggle-mobile {
  display: none;
}

/* User Dropdown Styles - Global access */
.clickable-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 12px 4px 4px;
  border-radius: 30px;
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  user-select: none;
}

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

.clickable-profile img {
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% !important;
  object-fit: cover;
  background: #333;
}

.clickable-profile span {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  animation: dropdownFade 0.2s ease-out;
}

@keyframes dropdownFade {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-menu.hidden {
  display: none;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dropdown-item i {
  width: 16px;
  text-align: center;
  color: var(--text-secondary);
}

.dropdown-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 0.25rem 0;
}

.dropdown-item.text-danger {
  color: #ff4d4d;
}

.dropdown-item.text-danger:hover {
  background: rgba(255, 77, 77, 0.1);
}

/* User Dropdown Styles */
.clickable-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 12px 4px 4px;
  border-radius: 30px;
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  user-select: none;
}

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

.clickable-profile img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: #333;
}

.clickable-profile span {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  animation: dropdownFade 0.2s ease-out;
}

@keyframes dropdownFade {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-menu.hidden {
  display: none;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dropdown-item i {
  width: 16px;
  text-align: center;
  color: var(--text-secondary);
}

.dropdown-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 0.25rem 0;
}

.dropdown-item.text-danger {
  color: #ff4d4d;
}

.dropdown-item.text-danger:hover {
  background: rgba(255, 77, 77, 0.1);
}


.chat-inner {
  padding: 1rem;
  padding-bottom: 2rem;
}

.msg .bubble {
  font-size: 0.95rem;
  padding: 0.8rem 1rem;
}

/* Input Area adjustments */
.input-wrapper {
  padding: 0.5rem;
  background: var(--bg-surface);
  /* Solid background to cover chat */
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
}

#bottomInput {
  font-size: 16px;
  /* Prevents auto-zoom on iOS */
  max-height: 120px;
  padding: 10px 12px;
}

.input-area {
  padding: 0.8rem;
  padding-bottom: calc(0.8rem + env(safe-area-inset-bottom));
  background: var(--bg-main);
  /* Ensure clear background */
}

/* Suggestion chips scrollable */
.suggestions {
  overflow-x: auto;
  justify-content: flex-start;
  padding-bottom: 5px;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  /* Force horizontal scroll */
}

.suggestion-chip {
  flex-shrink: 0;
  white-space: nowrap;
}

/* Desktop-only styles - Resizer and sidebar relative position */
@media (min-width: 769px) {
  .resizer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    cursor: col-resize;
    background: transparent;
    z-index: 100;
    transition: background 0.2s;
  }

  .resizer:hover,
  .sidebar.resizing .resizer {
    background: #ffffff;
    opacity: 0.3;
  }

  .sidebar.resizing .resizer {
    opacity: 0.6;
  }

  .sidebar {
    position: relative;
  }
}