/* =========================================================
   TamilAI SIDEBAR CONTROLS
   PERMANENT VIEWPORT-BOTTOM FIX
   ---------------------------------------------------------
   IMPORTANT:
   - Theme + Profile stay at the real bottom of sidebar
   - Chat history remains independently scrollable
   - AI Plus / Knowledge / Programs stay above controls
   - Does NOT change main chat geometry
   - Does NOT create extra vertical space
   ========================================================= */

/* =========================================================
   SIDEBAR FOUNDATION
   ========================================================= */

.conversation-panel {
  min-height: 0 !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

/* =========================================================
   CHAT HISTORY
   ---------------------------------------------------------
   Only history scrolls.
   Bottom controls are NOT part of the scrolling content.
   ========================================================= */

.conversation-panel .chat-history {
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;

  /* Space only for the fixed bottom controls */
  padding-bottom: 76px !important;

  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.conversation-panel .chat-history::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

/* =========================================================
   FEATURE BUTTON AREA
   ---------------------------------------------------------
   AI Plus
   Knowledge
   Programs
   ========================================================= */

.conversation-panel .sidebar-icon-list {
  position: relative !important;
  z-index: 20 !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* =========================================================
   PERMANENT BOTTOM CONTROL BAR
   ---------------------------------------------------------
   THIS IS THE IMPORTANT FIX.

   The parent sidebar is now exactly viewport height.
   Therefore absolute bottom:0 means REAL bottom.
   ========================================================= */

.conversation-panel > .sidebar-bottom-controls {
  position: absolute !important;

  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;

  width: 100% !important;
  height: 68px !important;
  min-height: 68px !important;
  max-height: 68px !important;

  box-sizing: border-box !important;

  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;

  padding: 8px 14px !important;
  margin: 0 !important;

  background: var(--bg-secondary) !important;
  border-top: 1px solid var(--border) !important;

  z-index: 99999 !important;

  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;

  overflow: visible !important;

  /* Rich but subtle 3D separation */
  box-shadow:
    0 -8px 24px rgba(0, 0, 0, 0.08),
    0 -1px 0 rgba(255, 255, 255, 0.08) !important;
}

/* =========================================================
   THEME BUTTON
   ========================================================= */

.conversation-panel > .sidebar-bottom-controls > .sidebar-theme-btn {
  position: relative !important;

  inset: auto !important;

  flex: 0 0 44px !important;

  width: 44px !important;
  height: 44px !important;

  min-width: 44px !important;
  min-height: 44px !important;

  max-width: 44px !important;
  max-height: 44px !important;

  margin: 0 !important;
  padding: 0 !important;

  display: flex !important;
  align-items: center !important;
  justify-content: center !important;

  border-radius: 50% !important;

  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;

  z-index: 100000 !important;

  cursor: pointer !important;

  transform: translateZ(0);

  transition:
    transform 180ms ease,
    box-shadow 220ms ease,
    background-color 220ms ease !important;
}

/* Theme hover */

.conversation-panel > .sidebar-bottom-controls > .sidebar-theme-btn:hover {
  transform: translateY(-2px) scale(1.04) !important;

  box-shadow: 0 8px 22px rgba(124, 58, 237, 0.2) !important;
}

/* Theme click */

.conversation-panel > .sidebar-bottom-controls > .sidebar-theme-btn:active {
  transform: scale(0.94) !important;
}

/* =========================================================
   PROFILE AVATAR
   ========================================================= */

.conversation-panel > .sidebar-bottom-controls > .sidebar-profile-btn {
  position: relative !important;

  inset: auto !important;

  flex: 0 0 46px !important;

  width: 46px !important;
  height: 46px !important;

  min-width: 46px !important;
  min-height: 46px !important;

  max-width: 46px !important;
  max-height: 46px !important;

  margin: 0 !important;
  padding: 0 !important;

  display: flex !important;
  align-items: center !important;
  justify-content: center !important;

  border-radius: 50% !important;

  overflow: hidden !important;

  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;

  z-index: 100000 !important;

  cursor: pointer !important;

  transform: translateZ(0);

  transition:
    transform 180ms ease,
    box-shadow 220ms ease !important;
}

/* Avatar hover */

.conversation-panel > .sidebar-bottom-controls > .sidebar-profile-btn:hover {
  transform: translateY(-2px) scale(1.04) !important;

  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.22) !important;
}

/* Avatar click */

.conversation-panel > .sidebar-bottom-controls > .sidebar-profile-btn:active {
  transform: scale(0.94) !important;
}

/* =========================================================
   AVATAR IMAGE
   ========================================================= */

.conversation-panel > .sidebar-bottom-controls > .sidebar-profile-btn img {
  width: 100% !important;
  height: 100% !important;

  min-width: 100% !important;
  min-height: 100% !important;

  max-width: 100% !important;
  max-height: 100% !important;

  display: block !important;

  object-fit: cover !important;

  border-radius: 50% !important;
}

/* =========================================================
   AVATAR INITIALS
   ========================================================= */

.conversation-panel > .sidebar-bottom-controls > .sidebar-profile-btn span {
  width: 100% !important;
  height: 100% !important;

  display: flex !important;

  align-items: center !important;
  justify-content: center !important;

  border-radius: 50% !important;
}

/* =========================================================
   MOBILE
   ========================================================= */

@media screen and (max-width: 768px) {
  .conversation-panel {
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;

    overflow: hidden !important;

    box-sizing: border-box !important;
  }

  .conversation-panel .chat-history {
    padding-bottom: 70px !important;

    overflow-y: auto !important;
    overflow-x: hidden !important;

    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }

  .conversation-panel .chat-history::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
  }

  /* REAL bottom of mobile sidebar */

  .conversation-panel > .sidebar-bottom-controls {
    position: absolute !important;

    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;

    width: 100% !important;

    height: 64px !important;
    min-height: 64px !important;
    max-height: 64px !important;

    padding: 7px 12px calc(7px + env(safe-area-inset-bottom)) 12px !important;

    box-sizing: border-box !important;

    display: flex !important;

    align-items: center !important;
    justify-content: space-between !important;

    z-index: 99999 !important;

    visibility: visible !important;
    opacity: 1 !important;
  }

  /* Theme */

  .conversation-panel > .sidebar-bottom-controls > .sidebar-theme-btn {
    flex: 0 0 40px !important;

    width: 40px !important;
    height: 40px !important;

    min-width: 40px !important;
    min-height: 40px !important;

    max-width: 40px !important;
    max-height: 40px !important;

    border-radius: 12px !important;
  }

  /* Avatar */

  .conversation-panel > .sidebar-bottom-controls > .sidebar-profile-btn {
    flex: 0 0 42px !important;

    width: 42px !important;
    height: 42px !important;

    min-width: 42px !important;
    min-height: 42px !important;

    max-width: 42px !important;
    max-height: 42px !important;
  }
}

/* =========================================================
   SMALL PHONES
   ========================================================= */

@media screen and (max-width: 380px) {
  .conversation-panel > .sidebar-bottom-controls {
    height: 60px !important;
    min-height: 60px !important;
    max-height: 60px !important;

    padding: 6px 10px calc(6px + env(safe-area-inset-bottom)) 10px !important;
  }

  .conversation-panel > .sidebar-bottom-controls > .sidebar-theme-btn {
    flex-basis: 36px !important;

    width: 36px !important;
    height: 36px !important;

    min-width: 36px !important;
    min-height: 36px !important;

    max-width: 36px !important;
    max-height: 36px !important;
  }

  .conversation-panel > .sidebar-bottom-controls > .sidebar-profile-btn {
    flex-basis: 38px !important;

    width: 38px !important;
    height: 38px !important;

    min-width: 38px !important;
    min-height: 38px !important;

    max-width: 38px !important;
    max-height: 38px !important;
  }
}

/* =========================================================
   HIDE SIDEBAR SCROLLBARS
   ---------------------------------------------------------
   Scrolling still works.
   Only the visual scrollbar disappears.
   ========================================================= */

.conversation-panel,
.conversation-panel .chat-history,
.conversation-panel .sidebar-icon-list {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.conversation-panel::-webkit-scrollbar,
.conversation-panel .chat-history::-webkit-scrollbar,
.conversation-panel .sidebar-icon-list::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

/* =========================================================
   SMOOTH 3D FEEL
   ========================================================= */

.conversation-panel > .sidebar-bottom-controls,
.conversation-panel > .sidebar-bottom-controls > * {
  backface-visibility: hidden !important;
  -webkit-backface-visibility: hidden !important;
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .conversation-panel > .sidebar-bottom-controls,
  .conversation-panel > .sidebar-bottom-controls > * {
    transition: none !important;
  }
}
