/* ------------------------------------------------------
   GLOBAL
------------------------------------------------------ */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  height: 100vh;
  overflow: hidden;
  background: #e8f5fb;
}

body,
.sidebar,
.chat-header,
.composer {
  transition: background 0.25s ease, color 0.25s ease;
}

.layout {
  display: flex;
  height: 100vh;
}

/* ------------------------------------------------------
   SIDEBAR
------------------------------------------------------ */
.sidebar {
  width: 270px;
  background: #ffffffcc;
  backdrop-filter: blur(16px);
  padding: 20px;
  border-right: 1px solid #d2e4ee;
  overflow-y: auto;
  position: relative;
  transition: width 0.25s ease;
}

.sidebar.collapsed {
  width: 70px;
  overflow: hidden;
}

/* Hide when collapsed */
.sidebar.collapsed .logo,
.sidebar.collapsed .newchat-anim,
.sidebar.collapsed .session-search,
.sidebar.collapsed .sidebar-sections,
.sidebar.collapsed .chat-menu,
.sidebar.collapsed .delete-bg,
.sidebar.collapsed .chat-name {
  display: none !important;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 18px;
  color: #06324a;
}

/* Logout button style (previously missing) */
.logout-btn {
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: #f2f3f5;
  border: none;
  cursor: pointer;
}
.logout-btn:hover {
  background: #e4e5e7;
}

/* New Chat Button Ripple */
.newchat-anim {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: #4b9fff;
  color: white;
  font-size: 15px;
  position: relative;
  overflow: hidden;
  --ripple-x: 0;
  --ripple-y: 0;
}

.newchat-anim::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  left: var(--ripple-x);
  top: var(--ripple-y);
  background: rgba(255, 255, 255, 0.75);
  transform: scale(0);
  opacity: 0;
}

.newchat-anim.ripple-active::after {
  animation: rippleAnim 0.45s ease-out;
}

@keyframes rippleAnim {
  from {
    transform: scale(0);
    opacity: 0.7;
  }
  to {
    transform: scale(26);
    opacity: 0;
  }
}

/* Search */
.session-search {
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  font-size: 14px;
  border-radius: 10px;
  border: 1px solid #d2e4ee;
}

/* ------------------------------------------------------
   SIDEBAR SECTIONS
------------------------------------------------------ */
.sidebar-sections {
  margin-top: 16px;
}

.section {
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px;
  cursor: pointer;
  font-weight: 600;
}

.section-badge {
  padding: 2px 8px;
  background: #d9ecf7;
  border-radius: 8px;
  font-size: 12px;
}

.section-body {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: max-height 0.25s ease, opacity 0.25s ease;
  max-height: 600px;
}

.section-body.collapsed {
  max-height: 0 !important;
  opacity: 0;
  overflow: hidden;
}

/* ------------------------------------------------------
   SESSION ITEM
------------------------------------------------------ */
.session-item {
  padding: 12px;
  background: #eef8fd;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: background 0.25s ease;
}

.session-item:hover {
  background: #dff2fb;
}

.session-item.active {
  border: 2px solid #4b9fff;
  background: #d6ebff;
}

.session-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #d3eaff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #083452;
  flex-shrink: 0;
}

.chat-name {
  flex: 1;
}

.unread-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff4444;
}

.chat-menu {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.chat-menu button {
  flex: 1;
  padding: 6px;
  border-radius: 8px;
  background: #e6f2ff;
  border: none;
  cursor: pointer;
}

.chat-menu button:hover {
  background: #d4e9ff;
}

.delete-bg {
  position: absolute;
  top: 0;
  right: 0;
  width: 70px;
  height: 100%;
  background: #ff4b4b;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
}

/* ------------------------------------------------------
   SIDEBAR RESIZER
------------------------------------------------------ */
.sidebar-resizer {
  width: 6px;
  cursor: ew-resize;
  height: 100%;
  right: 0;
  top: 0;
  position: absolute;
}

/* ------------------------------------------------------
   CHAT AREA
------------------------------------------------------ */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #e8f5fb, #f8fcff);
  position: relative;
}

/* ------------------------------------------------------
   HEADER
------------------------------------------------------ */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: #ffffffcc;
  border-bottom: 1px solid #d2e4ee;
  backdrop-filter: blur(14px);
  z-index: 30;
}

.chat-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  padding: 9px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #eaf3f7;
  transition: 0.25s;
}

.icon-btn:hover {
  background: #dcedf2;
}

.icon-btn#voiceToggleBtn.active {
  background: #4b9fff !important;
  color: white !important;
}

/* Voice selector */
.voice-selector {
  display: flex;
  gap: 6px;
}

.vs-btn {
  padding: 6px 10px;
  background: #e6f1ff;
  border: 1px solid #bfd6ff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

.vs-btn.active {
  background: #4b9fff;
  color: white;
}

/* ------------------------------------------------------
   MESSAGES
------------------------------------------------------ */
.messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ------------------------------------------------------
   BUBBLES
------------------------------------------------------ */
.bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(6px);
  transition: 0.25s;
  word-break: break-word;
}

.bubble.show {
  opacity: 1;
  transform: translateY(0);
}

.bubble.user {
  align-self: flex-end;
  background: #c8efff;
}

.bubble.bot {
  align-self: flex-start;
  background: #ffffff;
}

/* ------------------------------------------------------
   TYPING INDICATOR
------------------------------------------------------ */
.floating-typing {
  position: fixed;
  bottom: 140px;
  right: 30px;
  padding: 12px 16px;
  background: #ffffffcc;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(12px);
  display: none;
  z-index: 2000;
}

.typing span {
  width: 6px;
  height: 6px;
  background: #4b9fff;
  display: inline-block;
  margin: 0 2px;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}

.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typingBounce {
  0%, 70%, 100% { transform: translateY(0); }
  35% { transform: translateY(-6px); }
}

/* ------------------------------------------------------
   COMPOSER
------------------------------------------------------ */
.composer {
  display: flex;
  padding: 14px;
  background: #ffffffcc;
  border-top: 1px solid #d2e4ee;
  z-index: 40;
}

.composer textarea {
  flex: 1;
  padding: 10px;
  border: 1px solid #d2e4ee;
  border-radius: 12px;
  font-size: 15px;
  resize: none;
}

.send-btn {
  margin-left: 12px;
  padding: 12px 18px;
  background: #4ba4dd;
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}

.send-btn:hover {
  background: #3c92cc;
}

/* ------------------------------------------------------
   EMOJI PICKER
------------------------------------------------------ */
.emoji-picker {
  position: fixed;
  bottom: 180px; /* fixed overlap issue */
  right: 70px;
  width: 300px;
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
  display: none;
  max-height: 260px;
  overflow-y: auto;
  z-index: 3000;
}

.emoji-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 22px;
  padding: 6px;
}

/* ------------------------------------------------------
   MODALS
------------------------------------------------------ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 4000;
}

.modal {
  background: #fff;
  padding: 26px;
  width: 320px;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* ------------------------------------------------------
   AUTH MODAL
------------------------------------------------------ */
.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5000;
}

.auth-box {
  background: #fff;
  padding: 26px;
  width: 320px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-primary {
  padding: 12px;
  border-radius: 8px;
  background: #4ba4dd;
  color: #fff;
  border: none;
  cursor: pointer;
}

.btn-primary:hover {
  background: #3c92cc;
}

.btn-secondary {
  padding: 12px;
  border-radius: 8px;
  background: #e6e6e6;
  border: none;
  cursor: pointer;
}

/* ------------------------------------------------------
   WALLPAPERS
------------------------------------------------------ */
body.wall-default .chat-area {
  background: linear-gradient(135deg, #e8f5fb, #f8fcff) !important;
}

body.wall-lavender .chat-area {
  background: linear-gradient(135deg, #eee4ff, #f6f4ff) !important;
}

body.wall-nature .chat-area {
  background: url("nature.jpg") center/cover no-repeat !important;
}

body.wall-dark .chat-area {
  background: #0a121b !important;
}

/* Dark mode wallpaper override fix */
body.theme-dark.wall-dark .chat-area {
  background: #000 !important;
}

/* ------------------------------------------------------
   DARK THEME
------------------------------------------------------ */
body.theme-dark {
  background: #071019 !important;
  color: #e0f3ff !important;
}

body.theme-dark .sidebar,
body.theme-dark .composer,
body.theme-dark .chat-header {
  background: #0d1b25cc !important;
  color: #e8faff !important;
}

body.theme-dark .session-item {
  background: #102431 !important;
  color: #d3edff !important;
}

body.theme-dark .session-item.active {
  background: #1a394e !important;
}

body.theme-dark .bubble.user {
  background: #103549 !important;
  color: #d1f4ff !important;
}

body.theme-dark .bubble.bot {
  background: #0d1f2b !important;
  color: #dbf2ff !important;
}

body.theme-dark .audio-preview {
  background: #102431 !important;
  color: #d1efff !important;
  border-color: #1c3545 !important;
}

/* ------------------------------------------------------
   RECORDING BUBBLE
------------------------------------------------------ */
.recording-bubble {
  position: fixed;
  bottom: 120px;
  left: 20px;
  right: 20px;
  background: #ffffffdd;
  padding: 14px 18px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(12px);
  z-index: 3000;

  /* Fix: Prevent blocking UI behind */
  pointer-events: none;
}

.recording-bubble * {
  pointer-events: auto;
}

.rec-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.record-icon {
  font-size: 18px;
}

.rec-text {
  font-size: 14px;
  font-weight: 600;
}

.rec-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.record-timer {
  font-weight: 600;
  font-size: 16px;
}

.waveform {
  height: 50px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin-top: 4px;
}

.waveform .bar {
  width: 6px;
  height: 6px;
  background: #4ba4dd;
  border-radius: 4px;
  transition: height 0.1s ease;
}

.rec-right {
  font-size: 12px;
  color: #c0392b;
  font-weight: 600;
}

.record-btn.canceling {
  background: #ff3b3b !important;
  color: white !important;
  transform: scale(1.1);
}

/* ------------------------------------------------------
   AUDIO PREVIEW
------------------------------------------------------ */
.audio-preview {
  display: flex;
  gap: 14px;
  align-items: center;
  background: #ffffffdd;
  border-radius: 14px;
  padding: 10px 14px;
  margin: 10px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(10px);
  animation: fadeInUp 0.25s ease;
}

@keyframes fadeInUp {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
