/* ===============================
   🌙 AI BTC - Final Optimized Style
   =============================== */

:root {
  --bg: #0f1724;
  --panel: #0b1220;
  --muted: #94a3b8;
  --accent: #0ea5a4;
  --card: #0b1622;
  --danger: #ef4444;
  --glass: rgba(255,255,255,0.03);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden; /* 🚫 stops any vertical scroll beyond viewport */
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #071226 0%, #071623 100%);
  color: #e6eef6;
  font-size: 14px;
  display: flex;
  flex-direction: column;
    overflow: hidden;
}

/* ===============================
   ⚙️ Layout
   =============================== */
.layout {
  display: flex;
  flex: 1;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}

/* ===============================
   📚 Sidebar
   =============================== */
.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  background: #1e293b;
  width: 260px;
  min-height: 100vh;
  padding: 20px 16px;
  box-sizing: border-box;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.user-name {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  margin-top: 10px;
  margin-bottom: 10px;
  padding-right: 4px;
  scrollbar-width: thin;
}

/* Sidebar buttons */
.sidebar .ai-btn,
.sidebar button {
  display: block;
  width: 100%;
  background: #14b8a6;
  color: white;
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar .ai-btn:hover,
.sidebar button:hover {
  background: #0d9488;
}

/* “New Chat” special */
.sidebar .new-chat-btn {
  background: #10b981;
}
.sidebar .new-chat-btn:hover {
  background: #059669;
}

/* Logout */
.sidebar .logout-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: #e2e8f0;
}
.sidebar .logout-btn:hover {
  background: rgba(255,255,255,0.12);
}

/* ===============================
   💬 Chat Container
   =============================== */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  border-radius: 0 12px 12px 0;
  justify-content: space-between;
  overflow: hidden;
}

.chat-header {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 20px;
  font-weight: 600;
  color: #f1f5f9;
}

.query-counter {
  font-size: 13px;
  color: var(--muted);
}

/* Messages */
.chat-box {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-row { display: flex; align-items: flex-end; margin: 6px 0; }
.user-row { justify-content: flex-end; }
.bot-row { justify-content: flex-start; }

.message {
  max-width: 70%;
  padding: 10px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
}
.message.user {
  background: linear-gradient(90deg, #064e4a, #0ea5a4);
  color: #021;
}
.message.bot {
  background: rgba(255,255,255,0.03);
  color: var(--muted);
}

/* ===============================
   ✍️ Input Bar
   =============================== */
.chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 26px;
  border-top: 1px solid rgba(255,255,255,0.1);
  background: rgba(15,23,42,0.95);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
  position: sticky;
  bottom: 0;
  z-index: 10;
}





/* ✅ Textarea (chat box input) */
#userInput {
  flex: 1;
  background: rgba(30, 41, 59, 0.95);
  color: #f8fafc;
  border: none;
  border-radius: 10px;
  outline: none;
  font-size: 15px;
  line-height: 1.6;
  padding: 16px 18px;              /* 🔹 increase for taller box */
  min-height: 60px;                /* 🔹 default height */
  max-height: 160px;               /* 🔹 prevent too large expansion */
  resize: none;
  overflow-y: auto;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

#userInput:focus {
  outline: 2px solid #3b82f6;      /* blue outline */
  box-shadow: 0 0 0 2px #3b82f6aa; /* subtle blue glow */
}



.ai-textarea {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: white;
  padding: 10px 12px;
  font-size: 15px;
  resize: none;
  min-height: 44px;
  max-height: 320px;
  line-height: 1.4;
  overflow-y: auto;
}

.ai-btn {
  background: #14b8a6;
  border: none;
  color: white;
  border-radius: 6px;
  padding: 10px 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.ai-btn:hover { background: #0d9488; }


/* ===============================
   🪟 chat item
   =============================== */

/* ✅ Sidebar Chat List Styling (final clean version) */


/* ✅ Final Sidebar Chat List with minimal inline ❌ delete */

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

/* Chat Item Wrapper */
.chat-item {
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.04);
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.25s ease, transform 0.1s ease;
  cursor: pointer;
  position: relative;
}

.chat-item:hover {
  background: rgba(255,255,255,0.08);
  transform: translateX(1px);
}

/* Active Chat */
.chat-item.active {
  background: rgba(255,255,255,0.1);
  border-left: 3px solid #14b8a6;
}

/* Chat name + small delete X inline */
.chat-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: #e5e7eb;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chat time */
.chat-time {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 2px;
  font-style: italic;
  user-select: none;
}

/* 🚫 Prevent delete-chat-btn from inheriting sidebar button styles */
.sidebar .delete-chat-btn {
  all: unset; /* remove all previous button styles */
  color: #ef4444; /* red text only */
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 6px;
  opacity: 0;
  line-height: 1;
  transition: opacity 0.25s ease, color 0.2s ease;
  display: inline; /* ensure it stays beside chat name */
  background: none !important;
  width: auto !important;
  height: auto !important;
  padding: 0 !important;
  border: none !important;
  box-shadow: none !important;
}

/* 👁️ Show only on hover */
.chat-item:hover .delete-chat-btn {
  opacity: 1;
}

/* 💫 Soft hover glow */
.delete-chat-btn:hover {
  color: #f87171;
  text-shadow: 0 0 4px rgba(239,68,68,0.4);
}

/* 📱 On mobile, make visible by default */
@media (max-width: 900px) {
  .sidebar .delete-chat-btn {
    opacity: 1;
    font-size: 12px;
    margin-left: 4px;
  }
}


/* Scrollbar styling */
.chat-list::-webkit-scrollbar {
  width: 6px;
}
.chat-list::-webkit-scrollbar-thumb {
  background-color: rgba(255,255,255,0.2);
  border-radius: 3px;
}
.chat-list::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255,255,255,0.35);
}



/* ===============================
   🪟 Modal
   =============================== */
.modal {
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2,6,23,0.8);
  z-index: 9999 !important;
  backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease;
}
.modal.hidden { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-card {
  background: var(--card);
  padding: 20px;
  border-radius: 10px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  color: #fff;
  text-align: center;
}

/* ===============================
   📱 Mobile Optimization
   =============================== */
@media (max-width: 900px) {
  .layout { flex-direction: column; height: auto; min-height: 100dvh; }

  .sidebar {
    width: 100%;
    border-radius: 0;
    padding: 12px 16px;
    min-height: auto;
  }

  .sidebar-footer {
    flex-direction: row;
    justify-content: space-between;
    gap: 8px;
    border-top: none;
    padding-top: 0;
  }

  .chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
  }

  .chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px 80px;
    scroll-behavior: smooth;
  }

  .chat-input {
    position: fixed !important;
    bottom: 0 !important;
    left: 0;
    right: 0;
    z-index: 999;
    background: rgba(15, 23, 42, 0.97);
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 10px 12px;
  }

  .ai-textarea {
    font-size: 15px;
    min-height: 40px;
    max-height: 100px;
    padding: 8px 10px;
  }

  .ai-btn {
    font-size: 14px;
    padding: 8px 12px;
  }

  @supports (height: 100dvh) {
    .chat-container { min-height: 100dvh; height: 100dvh; }
  }
}

@media (max-height: 500px) {
  .chat-box { padding-bottom: 100px; }
}

/* ✅ FULL MOBILE FIX — no overlap, sidebar first, chat below */
@media (max-width: 900px) {
  html, body {
    overflow: auto !important;         /* allow page scrolling */
    height: auto !important;
  }

  .layout {
    display: flex;
    flex-direction: column;            /* stack vertically */
    width: 100%;
    min-height: 100svh;                /* use safe viewport height */
    height: auto;
    overflow: visible !important;      /* allow normal scroll */
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  }

  /* ✅ Sidebar becomes top section */
  .sidebar {
    width: 100%;
    min-height: auto;
    padding: 16px;
    background: #1e293b;
    border-radius: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    overflow: visible;
    z-index: 10;
    position: relative;
  }

  .sidebar-body {
    max-height: none;
    overflow-y: visible;
  }

  /* ✅ Footer buttons visible and inline */
  .sidebar-footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
  }

  .sidebar-footer .ai-btn {
    flex: 1;
    font-size: 14px;
    padding: 10px 8px;
  }

  /* ✅ Chat container below sidebar */
  .chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    border-radius: 0;
    overflow: visible;
    padding-bottom: 60px;
  }

  .chat-box {
    flex: 1;
    overflow-y: auto;
   padding: 16px 20px 220px;
  }

  /* ✅ Input fixed at bottom of entire viewport */
  .chat-input {
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: rgba(15,23,42,0.97);
    padding: 10px 12px;
  }

  .ai-textarea {
    min-height: 40px;
    max-height: 100px;
  }
}


/* ✅ Reduce chat area height slightly on mobile to prevent overlap */
@media (max-width: 900px) {
  .chat-container {
    height: calc(100vh - 50px) !important; /* reduce height by 50px */
    overflow: hidden;
  }

  .chat-box {
    height: calc(100vh - 140px) !important; /* adjust internal scrollable area */
    overflow-y: auto;
  }
}


/* 🔔 Toast notification style */

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(40, 40, 40, 0.95);
  color: #fff;
  padding: 12px 22px;
  border-radius: 10px;
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.4s ease;
  z-index: 99999;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}






/* Live signals widget */
#liveSignalsWidget {
  position: fixed;
  top: 120px;
  right: 20px;
  width: 360px;
  height: 420px;
  background: #0b0b0b;
  color: #fff;
  border: 1px solid #2b2b2b;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  resize: both;            /* allow resizing */
  overflow: auto;
  min-width: 260px;
  min-height: 120px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

/* Header */
#liveSignalsWidget .lw-header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:8px 10px;
  border-bottom:1px solid rgba(255,255,255,0.04);
  cursor: move; /* draggable hint */
  user-select:none;
}
#liveSignalsWidget .lw-title { font-weight:700; font-size:14px; color:#fff; }
#liveSignalsWidget .lw-close {
  background:transparent;
  color:#fff;
  border:none;
  font-size:18px;
  cursor:pointer;
  padding:4px 8px;
}

/* Body columns */
#liveSignalsWidget .lw-body {
  display:flex;
  gap:8px;
  padding:10px;
  flex:1 1 auto;
  overflow:auto;
}
.lw-col {
  flex:1 1 50%;
  min-width: 100px;
}
.lw-col h4 {
  margin:0 0 6px 0;
  font-size:13px;
  color:#ddd;
  font-weight:600;
}
.lw-list {
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height:100%;
}
.lw-item {
  background: rgba(255,255,255,0.02);
  padding:6px 8px;
  border-radius:6px;
  font-size:13px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.lw-price { font-weight:700; color:#fff; margin-right:8px; }
.lw-time { color:#bdbdbd; font-size:12px; }

/* Footer small helper */
#liveSignalsWidget .lw-footer {
  padding:6px 10px;
  border-top:1px solid rgba(255,255,255,0.03);
  font-size:12px;
  color:#bdbdbd;
  text-align:left;
}

/* Responsive */
@media (max-width:520px){
  #liveSignalsWidget { width: 92%; right:4%; left:4%; top:60px; height: 52vh; }
}
