/* ===============================
   🌙 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; }

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-x: 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;
  
}

.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;
  min-height: 0;
   font-size: 18px ;   
  line-height: 1.6;
}

.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 16px;
  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;
}

.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: 120px;
  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; }

/* ===============================
   🌌 Sidebar Layout
   =============================== */
.sidebar {
  display: flex;
  flex-direction: column;
  width: 260px;
  height: 100vh; /* full height of screen */
  background: #0b1220;
  border-right: 1px solid rgba(255,255,255,0.08);
  color: #fff;
}

/* Header & Footer fixed height */
.sidebar-header,
.sidebar-footer {
  flex-shrink: 0;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
}

/* The middle part takes all remaining height */
.sidebar-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* prevent double scroll */
}


/* ===============================
   💬 Chat Items
   =============================== */
.chat-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
}

.chat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.chat-item:hover {
  background: rgba(255,255,255,0.05);
}
.chat-item.active {
  background: rgba(255,255,255,0.1);
  border-left: 3px solid #14b8a6;
}

.chat-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: #e5e7eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===============================
   ❌ Delete Cross Button
   =============================== */
/* ===============================
   ❌ Clean Minimal Red Cross Button
   =============================== */
.delete-chat-btn {
  all: unset;                  /* removes all inherited button styles */
  display: inline-block;
  margin-left: 6px;
  cursor: pointer;
  color: #f87171;              /* soft red */
  font-size: 13px;
  line-height: 1;
  opacity: 0.8;
  transition: transform 0.2s ease, opacity 0.2s ease, color 0.2s ease;
}

.delete-chat-btn:hover {
  opacity: 1;
  color: #ef4444;              /* bright red on hover */
  transform: scale(1.15);
}

/* Ensure it's never styled like other buttons */
.sidebar .delete-chat-btn,
.ai-btn.delete-chat-btn {
  background: none !important;
  border: none !important;
  padding: 0 !important;
  color: #f87171 !important;
  font-size: 13px !important;
}

/* ===============================
   🧱 Branding
   =============================== */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-logo {
  width: 22px;
  height: 22px;
}
.brand-name {
  font-size: 16px;
  font-weight: 600;
  color: #14b8a6;
}







/* Sidebar Layout */
.sidebar {
  display: flex;
  flex-direction: column;
  width: 260px;
  height: 100vh; /* full height */
  background: #0b1220;
  border-right: 1px solid rgba(255,255,255,0.08);
  overflow: hidden; /* no full scroll */
}

/* ===============================
   🌌 Sidebar Layout
   =============================== */
.sidebar {
  display: flex;
  flex-direction: column;
  width: 260px;
  height: 100vh; /* full window height */
  background: #0b1220;
  border-right: 1px solid rgba(255,255,255,0.08);
  color: #fff;
  overflow: hidden; /* only inner section scrolls */
}

/* Header + Footer fixed */
.sidebar-header,
.sidebar-footer {
  flex-shrink: 0;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
}

/* Middle section scrolls */
.chat-scroll-container {
  flex: 1; /* fill remaining height */
  overflow-y: auto; /* enables scroll */
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

/* Chrome / Edge / Safari scrollbars */
.chat-scroll-container::-webkit-scrollbar {
  width: 6px;
}
.chat-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
}
.chat-scroll-container::-webkit-scrollbar-track {
  background: transparent;
}

/* Chat list and items */
.chat-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
}

.chat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.chat-item:hover {
  background: rgba(255,255,255,0.05);
}
.chat-item.active {
  background: rgba(255,255,255,0.1);
  border-left: 3px solid #14b8a6;
}

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

/* Small red delete cross */
.delete-chat-btn {
  all: unset;
  display: inline-block;
  margin-left: 6px;
  cursor: pointer;
  color: #f87171;
  font-size: 13px;
  line-height: 1;
  opacity: 0.8;
  transition: transform 0.2s ease, opacity 0.2s ease, color 0.2s ease;
}
.delete-chat-btn:hover {
  opacity: 1;
  color: #ef4444;
  transform: scale(1.15);
}



.chat-scroll-container {
  overflow-y: scroll;
}

/* ===============================
   🪟 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; }
}


/* ===============================
   ✅ Mobile Chat Area Fix
   =============================== */
@media (max-width: 900px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  .layout {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    position: relative;
  }

  .chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px 80px;
    min-height: 0;
  }

  .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);
  }
}

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