/* ==========================================================================
   THEME VARIABLES (SCOPED & ISOLATED)
   ========================================================================== */
:root {
  --chat-bg-light: #E2E8F0;
  --chat-bg-dark: #263147;
  --chat-accent: #00BFAF;
  
  /* Guardian Color Variations (Derived strictly from allowed palette) */
  --chat-dark-text: #263147;
  --chat-light-text: #E2E8F0;
  --chat-border-dark: rgba(38, 49, 71, 0.2);
  --chat-border-light: rgba(226, 232, 240, 0.3);
  --chat-overlay-bg: rgba(38, 49, 71, 0.6);
  --chat-hover-accent: rgba(0, 191, 175, 0.8);
  --chat-hover-dark: rgba(38, 49, 71, 0.9);
  --chat-shadow: 0 4px 12px rgba(38, 49, 71, 0.15);
}


#helpBtn, .live-chat-panel, .admin-panel, .help-modal-overlay {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.4;
}
#helpBtn *, .live-chat-panel *, .admin-panel *, .help-modal-overlay * {
  box-sizing: border-box;
}




/* ==========================================================================
   1. LIVE HELP FLOATING BUTTON
   ========================================================================== */
#helpBtn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999999;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 2px solid var(--chat-accent);
  border-radius: 20px;
  color: var(--chat-light-text);
  font-weight: 700;
  background: var(--chat-bg-dark);
  box-shadow: var(--chat-shadow);
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  
}

#helpBtn:hover {
  background: var(--chat-accent);
  color: var(--chat-bg-dark);
  border-color: var(--chat-bg-dark);
}

#helpBtn:active {
  transform: scale(0.95);
}

#helpBtn .dot {
  width: 8px;
  height: 8px;
  background-color: var(--chat-accent);
  border-radius: 50%;
  display: inline-block;
}
#helpBtn:hover .dot {
  background-color: var(--chat-bg-dark);
}

#helpBtn .help-badge {
  background: var(--chat-accent);
  color: var(--chat-bg-dark);
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 800;
  margin-left: 4px;
  border: 1px solid var(--chat-bg-dark);
}

/* ==========================================================================
   2. LIVE CHAT PANEL (USER SIDE)
   ========================================================================== */
.live-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 70px;
  width: 320px;
  height: 420px;
  min-width: 280px;
  min-height: 320px;
  max-width: 95vw;
  max-height: 85vh;
  background: var(--chat-bg-light);
  border: 2px solid var(--chat-bg-dark);
  border-radius: 8px;
  box-shadow: var(--chat-shadow);
  z-index: 999998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header & Drag Handle */
.panel-header {
  background: var(--chat-bg-dark);
  color: var(--chat-light-text);
  padding: 1px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.panel-header.drag-handle {
  cursor: move;
  touch-action: none;
}

.panel-header .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--chat-accent);
  background: var(--chat-bg-light);
}
.panel-header .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.panel-header .header-info {
  display: flex;
  flex-direction: column;
}
.panel-header .title {
  font-weight: 700;
  font-size: 13px;
  color: var(--chat-light-text);
}
.panel-header .sub {
  font-size: 11px;
  color: var(--chat-accent);
}

.panel-header .spacer {
  flex: 1;
}

.panel-header .action-btn {
  background: transparent;
  border: none;
  color: var(--chat-light-text);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}
.panel-header .action-btn:hover {
  background: var(--chat-border-light);
  color: var(--chat-accent);
}

/* Panel Body */
.panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 2px;
  gap: 2px;
}

/* Messages Container */
.msgs-container {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(226, 232, 240, 0.5);
  border-radius: 4px;
  border: 1px solid var(--chat-border-dark);
}

/* Chat Bubbles (Compact) */
.chat-msg {
  max-width: 85%;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  word-wrap: break-word;
}
.chat-msg.incoming {
  background: var(--chat-bg-dark);
  color: var(--chat-light-text);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.chat-msg.outgoing {
  background: var(--chat-accent);
  color: var(--chat-bg-dark);
  align-self: flex-end;
  border-bottom-right-radius: 2px;
  font-weight: 500;
}

/* Composer & Inputs */
.composer-container {
  display: flex;
  flex-direction: column;
  gap: 0px;
}
.input-group {
  display: flex;
  gap: 4px;
}
.compact-input {
  flex: 1;
  border: 1px solid var(--chat-bg-dark);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
  background: var(--chat-light-text);
  color: var(--chat-dark-text);
  outline: none;
}
.compact-input:focus {
  border-color: var(--chat-accent);
  box-shadow: 0 0 0 1px var(--chat-accent);
}

/* Buttons */
.compact-btn {
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.primary-btn {
  background: var(--chat-accent);
  color: var(--chat-bg-dark);
}
.primary-btn:hover {
  background: var(--chat-bg-dark);
  color: var(--chat-accent);
}
.secondary-btn {
  background: var(--chat-bg-dark);
  color: var(--chat-light-text);
}
.secondary-btn:hover {
  background: var(--chat-accent);
  color: var(--chat-bg-dark);
}

.composer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px;
}
.muted-text {
  font-size: 11px;
  color: rgba(38, 49, 71, 0.7);
}
.text-center {
  text-align: center;
}
.w-100 {
  width: 100%;
}

.link-btn {
  background: none;
  border: none;
  color: var(--chat-bg-dark);
  text-decoration: underline;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  font-weight: 600;
}
.link-btn:hover {
  color: var(--chat-accent);
}

.admin-notice {
  background: var(--chat-bg-dark);
  color: var(--chat-accent);
  padding: 6px;
  text-align: center;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

/* Custom Resize Handle Placement */
.resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  cursor: se-resize;
  background: linear-gradient(135deg, transparent 30%, var(--chat-bg-dark) 30%, var(--chat-bg-dark) 50%, transparent 50%, transparent 70%, var(--chat-bg-dark) 70%);
  background-size: 4px 4px;
  z-index: 10000;
  touch-action: none; /* improves touch handling */
}

/* ========================================================================== \
   3. AUTHENTICATION MODAL
   ========================================================================== */
.help-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--chat-overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000000;
}
.modal-box {
  background: var(--chat-bg-light);
  border: 2px solid var(--chat-bg-dark);
  border-radius: 8px;
  width: 280px;
  padding: 12px;
  box-shadow: var(--chat-shadow);
}
.modal-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--chat-dark-text);
  margin-bottom: 8px;
  text-align: center;
}
.status-msg {
  font-size: 12px;
  color: var(--chat-dark-text);
  margin-bottom: 8px;
  text-align: center;
}
.auth-btn {
  border: none;
  border-radius: 4px;
  padding: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.divider {
  height: 1px;
  background: var(--chat-border-dark);
  margin: 8px 0;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
}

/* ========================================================================== \
   4. ADMIN CONSOLE PANEL
   ========================================================================== */
.admin-panel {
  position: fixed;
  left: 50px;
  top: 50px;
  width: 580px;
  height: 400px;
  min-width: 334px;
  min-height: 300px;
  max-width: 95vw;
  max-height: 90vh;
  background: var(--chat-bg-light);
  border: 2px solid var(--chat-bg-dark);
  border-radius: 8px;
  box-shadow: var(--chat-shadow);
  z-index: 999997;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-panel-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Admin Sidebar */
.admin-sidebar {
  width: 180px;
  border-right: 1px solid var(--chat-border-dark);
  display: flex;
  flex-direction: column;
  background: rgba(226, 232, 240, 0.7);
}
.sidebar-header {
  padding: 6px;
  border-bottom: 1px solid var(--chat-border-dark);
}
.session-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Session Items (Compact) */
.session-item {
  padding: 6px 8px;
  border-bottom: 1px solid var(--chat-border-dark);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.2s;
}
.session-item:hover {
  background: rgba(0, 191, 175, 0.1);
}
.session-item.active {
  background: var(--chat-bg-dark);
  color: var(--chat-light-text);
}
.session-item.active .muted-text {
  color: var(--chat-accent);
}
.session-item.unread {
  border-left: 3px solid var(--chat-accent);
  font-weight: 700;
}

/* Admin Chat View Area */
.admin-chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 6px;
  gap: 6px;
  overflow: hidden;
}
.chat-view-header {
  padding: 2px 4px 6px 4px;
  border-bottom: 1px solid var(--chat-border-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.session-title {
  font-size: 13px;
  color: var(--chat-dark-text);
}
.session-meta {
  font-size: 11px;
}

#adminMsgs {
  background: rgba(226, 232, 240, 0.3);
}

/* ========================================================================== \
   5. FULLY RESPONSIVE MEDIA QUERIES (MOBILE FRIENDLY)
   ========================================================================== */
@media (max-width: 600px) {
  /* Live Chat Panel - Remove transform centering, allow resizing/dragging */
  .live-chat-panel {
    width: 90% !important;
    height: 60vh !important;
    max-height: 500px !important;
    bottom: 70px !important;
    left: 5% !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;  /* removed conflicting transform */
    border-radius: 16px !important;
    border: 2px solid var(--chat-bg-dark) !important;
  }
  
  /* Admin Panel adjustments for smaller screens */
  .admin-panel {
    width: 95% !important;
    height: 85vh !important;
    max-width: 95vw !important;
    max-height: 90vh !important;
    top: 5% !important;
    left: 2.5% !important;
    transform: none !important;  /* removed transform */
    border-radius: 12px !important;
    border: 2px solid var(--chat-bg-dark) !important;
  }
  
  .admin-panel-body {
    flex-direction: column;
  }
  
  .admin-sidebar {
    width: 100% !important;
    height: 130px;
    border-right: none;
    border-bottom: 2px solid var(--chat-bg-dark);
  }
  
  /* Make resize handle larger on touch devices */
  .resize-handle {
    width: 20px !important;
    height: 20px !important;
    background: linear-gradient(135deg, transparent 30%, var(--chat-bg-dark) 30%, var(--chat-bg-dark) 50%, transparent 50%, transparent 70%, var(--chat-bg-dark) 70%);
    background-size: 6px 6px;
  }
  
  /* Drag handle remains active */
  .panel-header.drag-handle {
    cursor: move;
  }
  
  /* Expand bubbles for easier reading */
  .chat-msg {
    max-width: 90%;
    font-size: 13px;
    padding: 8px 12px;
  }
  
  .compact-input {
    padding: 8px;
    font-size: 13px;
  }
  
  .compact-btn {
    padding: 8px 14px;
    font-size: 13px;
  }
}

/* For Tablets or Medium Screens */
@media (min-width: 601px) and (max-width: 900px) {
  .admin-panel {
    width: 90% !important;
    left: 5% !important;
    top: 5% !important;
    height: 80vh !important;
    transform: none !important;
  }
}

/* ========================================================================== \
   6. UTILITY AND FIXES (PREVENT OVERLAP / HIDDEN)
   ========================================================================== */
.msgs-container::-webkit-scrollbar,
.session-list::-webkit-scrollbar {
  width: 5px;
}
.msgs-container::-webkit-scrollbar-track,
.session-list::-webkit-scrollbar-track {
  background: transparent;
}
.msgs-container::-webkit-scrollbar-thumb,
.session-list::-webkit-scrollbar-thumb {
  background: rgba(38, 49, 71, 0.3);
  border-radius: 10px;
}
.msgs-container::-webkit-scrollbar-thumb:hover,
.session-list::-webkit-scrollbar-thumb:hover {
  background: var(--chat-accent);
}






/* Custom Resize Handle for Mobile & Desktop */
.resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 25px;       /* মোবাইলে সহজে টাচ করার জন্য একটু বড় সাইজ */
  height: 25px;
  cursor: se-resize; /* মাউস নিলে রিসাইজ আইকন দেখাবে */
  z-index: 100;
  touch-action: none; /* মোবাইলে টাচ করলে যেন ডিফল্ট স্ক্রল বা জুম না হয় */
  /* কোণায় একটি ছোট ত্রিভুজের মতো ডিজাইন (ঐচ্ছিক) */
  background: linear-gradient(135deg, transparent 50%, rgba(150, 150, 150, 0.5) 50%);
}

/* প্যানেলে নেটিভ রিসাইজ অফ করে কাস্টম রিসাইজ ব্যবহারের জন্য */
.live-chat-panel, .admin-panel {
  resize: none !important; /* ডেস্কটপে ডাবল হ্যান্ডেল এড়ানোর জন্য */
}



/* --- Admin Search Box Styles --- */
.search-input {
  width: 140px;
  margin-right: 8px;
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid var(--chat-border-dark);
  background: rgba(255, 255, 255, 0.9);
  transition: width 0.3s ease, border-color 0.2s ease;
}
.search-input:focus {
  width: 180px;
  background: #fff;
  border-color: var(--chat-accent);
}
@media (max-width: 600px) {
  .search-input { width: 100px; }
  .search-input:focus { width: 130px; }
}



