/* © 2025 Authenti. All Rights Reserved. */

/* =================================================================== */
/* BASE STYLES (Default)                      */
/* =================================================================== */

:root {
  --color-primary: #bd7bff;
  --color-primary-light: #eadaff;
  --color-primary-subtle-light: #c58aff;
  --color-secondary: #dce775;

  /* === CHAT VIEW SLOT COLORS === */
  --color-view-0: #8ab4f8; /* Blue */
  --color-view-1: #ffab91; /* Orange */
  --color-view-2: #a8dab5; /* Soft Mint Green */
  --color-view-3: #f6c1e2; /* Soft Pink */

  --color-tertiary: var(--color-view-0); /* Legacy fallback */
  --color-quaternary: var(--color-view-1); /* Legacy fallback */

  --color-tertiary-alpha-20: rgba(138, 180, 248, 0.2);
  --color-tertiary-alpha-25: rgba(138, 180, 248, 0.25);
  --color-tertiary-alpha-30: rgba(138, 180, 248, 0.3);

  --color-tertiary-xlight: #eaf2fe;
  --color-tertiary-light: #b9d2f9;
  --color-quaternary-xlight: #fff1ec;
  --color-quaternary-light: #ffcebb;

  --color-background-light: #f8f9fa;
  --color-text-dark: #5e5e5e;
  --color-border: #ced4da;
  --color-error: #d9534f;
  --color-error-light: #fddede;
  --color-background-medium: #e0e0e0;
  --color-accent: #7a73ff;
  --color-text-medium: #757575;
  --color-border-light: #e0e0e0;
  --color-border-xlight: #e0e0e0;
  --color-success: #5cb85c;
  --header-height: 30px;

  /* Added for new login style */
  --login-primary-color: #bd7bff;
  --primary-hover: #a753fb;
  --login-primary-hover: var(--primary-hover);
  --login-background-color: #f3f4f6;
  --login-card-background: #ffffff;
  --login-text-primary: #bd7bff;
  --login-text-secondary: #6b7280;
  --login-font-family: "Inter", sans-serif;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: "Inter", sans-serif;
  background-color: var(--color-background-light);
  box-sizing: border-box;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh; /* Use dynamic viewport height for better mobile support */
  padding: 0;
}

/* --- LOGIN SCREEN STYLES (MODIFIED) --- */
.auth-wrapper {
  display: flex; /* Make the login screen visible by default */
  flex-direction: column; /* This is the key change */
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 100vh;
  padding: 20px;
  box-sizing: border-box;
  background-color: var(--login-background-color);
  font-family: var(--login-font-family);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2000;
}

.auth-wrapper .background-pattern {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 300px;
  background: linear-gradient(to bottom, var(--login-primary-color), #bd7bff);
  z-index: -1;
}

/* === STYLE FOR NEW HEADER LOGO === */
.header-logo {
  display: block;
  margin: 0 auto 40px auto;
  max-width: 200px;
  width: 80%;
}

/* === STYLE FOR RECAPTCHA LINKS === */
.recaptcha-link {
  color: inherit;
}

.auth-container {
  background: var(--login-card-background);
  border-radius: 16px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  padding: 48px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
}

.auth-container .icon-wrapper {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f3f4f6;
  color: var(--login-primary-color);
  margin-bottom: 24px;
}

.auth-container h2 {
  font-family: var(--login-font-family);
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 24px;
  color: var(--login-text-primary);
}

.auth-container input {
  width: 100%;
  padding: 14px;
  margin-bottom: 18px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 16px;
  box-sizing: border-box;
  font-family: var(--login-font-family);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-container input:focus {
  border-color: var(--login-primary-color);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.2);
  outline: none;
}

.auth-container .cta-button {
  width: 100%;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background-color: var(--color-primary);
  color: white;
  transition: all 0.2s ease-in-out;
}

.auth-container .cta-button:hover {
  background-color: var(--login-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.auth-container .forgot-password-link {
  display: block;
  margin-top: 16px;
  color: var(--login-primary-color);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.auth-container .forgot-password-link:hover {
  text-decoration: underline;
}

.auth-container .login-error {
  color: var(--color-error, #ef4444);
  margin-top: 15px;
  font-size: 14px;
  height: 1em; /* reserve space to prevent layout shift */
}

/* Style for the footer, copied from subscription.css for consistency */
.subscription-footer {
  margin-top: 32px;
  font-size: 14px;
  color: #d1d5db; /* A light color that works on the dark gradient */
}

.subscription-footer p {
  margin: 0;
}
/* --- END OF LOGIN SCREEN STYLES --- */

/* Owner Settings Header Bar */
.owner-settings-header-bar {
  width: 100%;
  background: radial-gradient(
    circle at top right,
    #ce9cff,
    var(--color-primary) 100%
  );
  color: #ffffff;
  padding: 5px 20px 5px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 15px;
  flex-wrap: wrap; /* Revert to wrap by default for owner/supervisor views */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  min-height: var(--header-height, 30px);
  position: relative;
  z-index: 100; /* Added to ensure it stacks above the page content */
}

/* Only apply nowrap for the agent view to keep the helper menu on one line */
.agent-view .owner-settings-header-bar {
  flex-wrap: nowrap;
}
.owner-settings-header-bar label {
  color: #ffffff;
  margin-bottom: 0;
}
.owner-settings-header-bar .header-left {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-shrink: 0;
  flex-grow: 1; /* Added to push right-side content to the edge */
}
.owner-settings-header-bar .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0; /* Prevent this section from shrinking */
}
.owner-settings-header-bar .company-logo-container {
  position: relative; /* Added for positioning context */
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: color 0.2s ease;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 1.4em;
  font-weight: bold;
  color: #ffffff;
  flex-shrink: 0;
}

/* Style for the hover-icon overlay */
.owner-settings-header-bar .company-logo-container::after {
  content: "";
  position: absolute;
  top: 5px; /* Aligns with the container's top padding */
  left: 10px; /* Aligns with the container's left padding */
  width: 40px; /* Matches the profile picture's width */
  height: 40px; /* Matches the profile picture's height */
  border-radius: 50%; /* Ensures the overlay is circular */
  background-image: url("/images/logo-icon.png");
  background-color: rgba(
    255,
    255,
    255,
    0.7
  ); /* Semi-transparent white overlay */
  background-size: 55%; /* Controls the size of the icon */
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0; /* Hidden by default */
  transition: opacity 0.2s ease-in-out;
  pointer-events: none; /* Prevents the overlay from interfering with clicks */
}

/* Show the icon overlay when hovering the container */
.owner-settings-header-bar .company-logo-container:hover::after {
  opacity: 1; /* Make it visible on hover */
}
.owner-settings-header-bar .company-logo-container:hover {
  background-color: rgba(255, 255, 255, 0.15);
}
/* This rule applies the CIRCLE SHAPE to BOTH the image and the letter avatar */
.owner-settings-header-bar .company-logo-container #companyLogoImg,
.default-avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid white;
  flex-shrink: 0;
}

/* This rule makes sure uploaded images fit nicely within the circle */
.owner-settings-header-bar .company-logo-container #companyLogoImg {
  object-fit: cover;
  vertical-align: middle;
}

/* This rule applies the background and font styles ONLY to the letter avatar */
.default-avatar-circle {
  background-color: white !important; /* Force white background to prevent flash */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--color-primary);
}

.owner-settings-header-bar .company-logo-container #companyLogoImg {
  object-fit: cover;
  vertical-align: middle;
}

.owner-settings-header-bar .company-logo-container #companyNameDisplay {
  display: inline;
  color: inherit;
}
.status-toggle-container {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-toggle-container #ownerStatusText {
  color: #ffffff;
  margin-right: 15px;
}
.status-toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}
.status-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-quaternary);
  transition: 0.4s;
  box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
input:checked + .slider {
  background-color: #81c784;
}
input:focus + .slider {
  box-shadow: 0 0 1px #81c784;
}
input:checked + .slider:before {
  transform: translateX(20px);
}
.slider.round {
  border-radius: 28px;
}
.slider.round:before {
  border-radius: 50%;
}

.owner-settings-header-bar .settings-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.owner-settings-header-bar .compact-input {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 0.9em;
  width: 140px;
  min-width: 90px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.owner-settings-header-bar .compact-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}
.owner-settings-header-bar .compact-input:focus {
  border-color: #ffffff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.custom-color-picker-wrapper {
  position: relative;
}
.color-preview {
  width: 45px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.color-preview:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}
.color-picker-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: white;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
  z-index: 101;
  margin-top: 5px;
  min-width: 170px;
  box-sizing: border-box;
}
.color-picker-dropdown.show {
  display: block;
}
.hex-color-input {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9em;
  color: var(--color-text-dark);
  text-transform: uppercase;
  margin-bottom: 10px;
}
color-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, 25px);
  justify-content: center;
  gap: 8px;
}
.palette-color {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s ease, border-color 0.2s ease;
}
.palette-color:hover {
  transform: scale(1.1);
}
.palette-color.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px white, 0 0 0 4px var(--color-primary);
}

.owner-settings-header-bar .compact-btn {
  padding: 8px 15px;
  font-size: 0.9em;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  cursor: pointer;
  position: relative;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}
.owner-settings-header-bar .compact-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

#closeWidgetSettingsBtn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: white;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 1.4em;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

#closeWidgetSettingsBtn:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

/* Style for disabled buttons in the header */
.owner-settings-header-bar .compact-btn:disabled {
  background-color: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  color: rgba(255, 255, 255, 0.4) !important;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Style for plan-gated features */
.owner-settings-header-bar .compact-btn.feature-locked {
  background-color: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  color: rgba(255, 255, 255, 0.4) !important;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Help Button */
.fixed-help-button {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background-color: #f0f0f0;
  color: var(--color-primary);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.3em;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease,
    box-shadow 0.2s ease, width 0.2s ease, height 0.2s ease, font-size 0.2s ease,
    left 0.2s ease, bottom 0.2s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  z-index: 999;
}
.fixed-help-button:hover {
  background-color: var(--color-primary) !important;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

/* Sticky Note Container */
.sticky-note-container {
  position: fixed;
  bottom: 10px;
  left: 70px;
  z-index: 998;
  display: none;
  align-items: flex-end;
  gap: 5px;
}

.sticky-note-container {
  position: fixed;
  bottom: 10px;
  left: 70px;
  z-index: 998;
  display: none;
  align-items: flex-end;
  gap: 5px;
}

/* Agent-specific view adjustments */
.agent-view .fixed-help-button {
  display: none;
}

.agent-view .sticky-note-container {
  left: 20px;
}

.fixed-note-input {
  width: 230px;
  min-height: 40px;
  max-height: 120px;
  padding: 8px 12px;
  border-radius: 20px;
  border: none;
  background-color: #ffffe0;
  color: var(--color-text-dark, #333);
  font-size: 0.9em;
  line-height: 1.4;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, height 0.1s ease;
  resize: none;
  overflow-y: hidden;
  box-sizing: border-box;
}

.fixed-note-input::placeholder {
  color: var(--color-text-medium, #757575);
  opacity: 0.8;
}

.fixed-note-input:focus {
  box-shadow: 0 0 0 3px var(--color-tertiary-alpha-20),
    0 2px 5px rgba(0, 0, 0, 0.1);
  outline: none;
}

.diminish-sticky-note-btn {
  width: 24px;
  height: 24px;
  background-color: #ffffff;
  border: 1px solid #bbb;
  color: #333;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  line-height: 22px;
  text-align: center;
  padding: 0;
  flex-shrink: 0;
  margin-bottom: 7px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.diminish-sticky-note-btn:hover {
  background-color: #f0f0f0;
  border-color: #aaa;
}

/* Dashboard Layout */
.dashboard-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex-grow: 1;
  background-color: transparent;
  overflow: hidden; /* Still prevent dashboard-container from scrolling */
  min-height: 0;
  padding-top: 20px;
  box-sizing: border-box;
  /* Re-evaluating height: Let's explicitly define it to fill the remaining viewport height */
  height: calc(
    100dvh - var(--header-height) - 70px
  ); /* Adjusted to ensure it takes available vertical space. Verify 70px is correct for your footer height. */
}
.dashboard-content-area {
  display: flex;
  width: 97%;
  max-width: 1500px;
  height: 100%; /* Make content area fill the dashboard-container's height */
  margin: 0 auto;
  gap: 15px;
  overflow: hidden; /* Prevents dashboard-content-area from scrolling */
  min-height: 0; /* Important for flex children */
  flex-grow: 1;
}

.dashboard-sidebar {
  width: 290px;
  background-color: #ffffff;
  color: var(--color-text-dark, #333);
  padding: 15px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: none;
  border-right: none;
  border-radius: 16px;
  overflow-y: auto !important; /* Force scrollbar on sidebar, overriding potential conflicts */
  overflow-x: hidden; /* Prevent horizontal scroll */
  min-height: 0; /* Crucial for flex children in column layout */
  height: 100%; /* Ensures it fills parent height available */
}
.search-container {
  position: relative;
  width: 100%;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--color-border, #ccc);
  border-radius: 20px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-input-wrapper:focus-within {
  border-color: var(--color-tertiary);
  box-shadow: 0 0 0 2px var(--color-tertiary-alpha-30);
}
.search-input-main {
  flex-grow: 1;
  border: none;
  outline: none;
  padding: 10px 110px 10px 15px;
  font-size: 0.95em;
  color: var(--color-text-dark, #333);
  background: transparent;
}
.filter-dropdown-trigger {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 12px;
  cursor: pointer;
  background-color: transparent;
  color: var(--color-text-medium);
  transition: background-color 0.2s ease;
}
.filter-dropdown-trigger:hover {
  background-color: #efefef;
}
.current-filter {
  margin-right: 8px;
  font-size: 0.9em;
  font-weight: 500;
}
.filter-dropdown-menu {
  display: none;
  position: absolute;
  top: 105%;
  left: 0;
  right: 0;
  background-color: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  z-index: 10;
  max-height: auto;
  overflow-y: auto;
  margin-top: 5px;
}
.filter-dropdown-menu.show {
  display: block;
}
.filter-option {
  padding: 10px 15px;
  cursor: pointer;
  font-size: 0.9em;
}
.filter-option:hover {
  background-color: var(--color-tertiary-xlight);
}
.dashboard-sidebar .search-filter-options select:focus {
  border-color: var(--color-tertiary);
  box-shadow: 0 0 0 2px var(--color-tertiary-alpha-30);
}
.dashboard-sidebar .search-filter-options select option {
  background-color: #ffffff;
  color: var(--color-text-dark, #333);
}

.dashboard-sidebar .sidebar-subheading {
  text-align: left;
  margin: 15px 0 10px 0;
  color: var(--color-text-dark, #555);
  font-size: 0.9em;
  font-weight: 300;
  text-transform: lowercase;
  letter-spacing: 0.2px;
  border-bottom: none;
  padding-bottom: 0;
  padding-left: 10px;
  flex-shrink: 0;
}

.client-list {
  margin-top: 0;
  padding-left: 0;
  min-height: 0;
  list-style: none;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.active-chats-section {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  flex-shrink: 1;
  min-height: 0;
  overflow: hidden;
}
.active-chats-section .sidebar-subheading {
  flex-shrink: 0;
}

.history-chats-section {
  display: flex;
  flex-direction: column;
  flex-shrink: 0; /* Keep this for non-expanded state */
  margin-top: auto;
  min-height: 0;
}

/* When history is NOT expanded, limit its height and hide overflow */
.dashboard-sidebar:not(.history-expanded) .history-chats-section {
  overflow: hidden;
  max-height: 40px; /* Limits to just the header */
}

/* When history IS expanded, allow it to fill space and show overflow */
.dashboard-sidebar.history-expanded .history-chats-section {
  flex-grow: 1; /* Allow it to take up available space */
  max-height: 100%; /* Ensure it doesn't exceed parent height */
  overflow-y: auto; /* Enable scrolling for the section itself */
  padding-top: 10px; /* Ensure consistent padding */
  margin-top: 10px; /* Ensure consistent margin */
}

/* Ensure the list inside the expanded history section can also scroll */
.dashboard-sidebar.history-expanded .history-chats-section #historyClientList {
  flex-grow: 1;
  overflow-y: auto;
}

/* Ensure buttons don't shrink */
.dashboard-sidebar.history-expanded
  .history-chats-section
  #closeFullHistoryViewBtn,
.dashboard-sidebar.history-expanded
  .history-chats-section
  #downloadAllHistoryInfoBtn {
  flex-shrink: 0; /* Prevent these buttons from shrinking */
  margin-bottom: 5px; /* Add some space below the buttons */
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px 15px 10px;
  cursor: pointer;
  background-color: #ffffff;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}
.history-header:hover {
  background-color: #ffffff !important;
}
.sidebar-subheading#historySubheading {
  padding-left: 0;
  margin: 0;
  display: flex;
  align-items: center;
}

.new-form-indicator {
  display: none;
  background-color: #4caf50;
  color: white;
  padding: 4px 8px;
  font-size: 0.5em;
  border-radius: 8px;
  font-weight: bold;
  line-height: 1;
  vertical-align: middle;
}

@keyframes wiggle-then-wait {
  /* This is the "wiggle" part, lasting about 0.6 seconds */
  0% {
    transform: rotate(0);
  }
  1.2%,
  3.6%,
  6%,
  8.4%,
  10.8% {
    transform: rotate(-8deg);
  }
  2.4%,
  4.8%,
  7.2%,
  9.6% {
    transform: rotate(8deg);
  }

  /* This is the "wait" part, a pause for the rest of the loop */
  12%,
  100% {
    transform: rotate(0);
  }
}

/* This class applies the looping animation with the new name */
.wiggle-repeatedly {
  animation: wiggle-then-wait 8s ease-in-out infinite;
}

#toggleHistoryIcon {
  font-size: 0.95em;
  padding: 5px;
  border-radius: 8px;
  color: var(--color-text-medium);
  transition: color 0.2s ease, background-color 0.2s ease;
}
#toggleHistoryIcon:hover {
  color: var(--primary-hover);
  background-color: rgba(0, 0, 0, 0.05);
}

.client-list li {
  padding: 8px 10px;
  border-radius: 12px;
  /* MODIFIED: Removed horizontal margins and added width: 100% */
  margin: 0 0 8px 0;
  width: 100%;
  border-bottom: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s ease, transform 0.1s ease,
    box-shadow 0.2s ease;
  position: relative;
  color: #ffffff;
  box-sizing: border-box;
  z-index: 1;
}

#activeClientList li,
#queueClientList li {
  background-color: #d9b3ff;
}
#activeClientList li:hover {
  background-color: color-mix(
    in srgb,
    var(--color-primary-light) 96%,
    black 4%
  );
}
#historyClientList li {
  background-color: #ced4da;
}
#historyClientList li:hover {
  background-color: #efefef;
}

#historySubheading .new-form-indicator,
#historySubheading .new-message-indicator {
  margin-left: 5px;
}

.client-list li.active-in-view-0,
.client-list li.active-in-view-0:hover {
  background-color: var(--color-view-0) !important;
  color: white !important;
}
.client-list li.active-in-view-2,
.client-list li.active-in-view-2:hover {
  background-color: var(--color-view-2) !important; /* Teal for view 2 */
  color: white !important;
}

.client-list li.active-in-view-1,
.client-list li.active-in-view-1:hover {
  background-color: var(--color-view-1) !important;
  color: white !important;
}
.client-list li.active-in-view-3,
.client-list li.active-in-view-3:hover {
  background-color: var(--color-view-3) !important; /* Purple for view 3 */
  color: white !important;
}

#historyClientList li.active-in-view-0,
#historyClientList li.active-in-view-0:hover,
#historyClientList li.active-in-view-1,
#historyClientList li.active-in-view-1:hover,
#historyClientList li.active-in-view-2,
#historyClientList li.active-in-view-2:hover,
#historyClientList li.active-in-view-3,
#historyClientList li.active-in-view-3:hover {
  background-color: #ced4da !important;
  color: #343a40 !important;
  box-shadow: none !important;
}
#historyClientList li.active-in-view-0 .client-last-contact,
#historyClientList li.active-in-view-0:hover .client-last-contact,
#historyClientList li.active-in-view-1 .client-last-contact,
#historyClientList li.active-in-view-1:hover .client-last-contact,
#historyClientList li.active-in-view-2 .client-last-contact,
#historyClientList li.active-in-view-2:hover .client-last-contact,
#historyClientList li.active-in-view-3 .client-last-contact,
#historyClientList li.active-in-view-3:hover .client-last-contact {
  color: #495057 !important;
}

#activeClientList li.active-in-view-0,
#activeClientList li.active-in-view-0:hover {
  box-shadow: inset 3px 0 0 0 var(--color-tertiary-light) !important;
}
#activeClientList li.active-in-view-2,
#activeClientList li.active-in-view-2:hover {
  box-shadow: inset 3px 0 0 0
    color-mix(in srgb, var(--color-quinary) 70%, white) !important; /* Teal for view 2 */
}

#activeClientList li.active-in-view-1,
#activeClientList li.active-in-view-1:hover {
  box-shadow: inset 3px 0 0 0 var(--color-quaternary-light) !important;
}
#activeClientList li.active-in-view-3,
#activeClientList li.active-in-view-3:hover {
  box-shadow: inset 3px 0 0 0 color-mix(in srgb, var(--color-senary) 70%, white) !important; /* Purple for view 3 */
}

.client-list li.active-in-view-0 .client-last-contact,
.client-list li.active-in-view-0:hover .client-last-contact,
.client-list li.active-in-view-1 .client-last-contact,
.client-list li.active-in-view-1:hover .client-last-contact,
.client-list li.active-in-view-2 .client-last-contact,
.client-list li.active-in-view-2:hover .client-last-contact,
.client-list li.active-in-view-3 .client-last-contact,
.client-list li.active-in-view-3:hover .client-last-contact {
  color: rgba(255, 255, 255, 0.8) !important;
}

.client-name-indicator-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 3px;
  box-sizing: border-box;
  flex-grow: 1;
  overflow: hidden;
}
.client-list li .client-name-display {
  font-weight: bold;
  font-size: 0.95em;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.client-list li .client-last-contact {
  font-size: 0.75em;
  opacity: 0.8;
  color: #ffffff;
  margin-top: 2px;
  margin-left: 4px;
}
.client-list li .client-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  margin-right: 15px;
  overflow: hidden;
}

.client-list li .client-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  margin-right: 15px;
  overflow: hidden;
}

.new-message-indicator.sidebar-form-badge {
  background-color: #4caf50 !important; /* Use green to indicate a form */
  color: white !important;
  border-color: #388e3c !important;
}

.new-message-indicator {
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 8px;
  margin-left: 3px;
  margin-right: 3px;
  font-size: 0.5em;
  font-weight: bold;
  line-height: 1;
  text-align: center;
  vertical-align: middle;
}

.new-message-indicator.sidebar-new-badge,
.new-message-indicator.sidebar-form-badge {
  display: inline-block;
  background-color: var(--color-secondary);
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.5em;
  font-weight: bold;
  line-height: 1;
  text-align: center;
  vertical-align: middle;
}

.client-list li .remove-chatroom-btn {
  background: none;
  border: none;
  color: var(--color-text-medium, #757575);
  font-size: 1.2em;
  cursor: pointer;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}
.client-list li:hover .remove-chatroom-btn {
  opacity: 1;
  background-color: none;
  color: var(--color-text-dark);
}
.client-list li .remove-chatroom-btn:hover {
  background-color: rgba(0, 0, 0, 0.1) !important;
  color: var(--color-text-dark) !important;
}

.dashboard-main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column; /* <-- This is the key change */
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  gap: 15px;
}

.chat-area-wrapper {
  display: flex;
  flex-grow: 1;
  gap: 15px;
  min-height: 0;
  overflow: hidden;
}

.chat-view-slot {
  display: none;
  flex-direction: column;
  background-color: #ffffff;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  flex-grow: 1;
  flex-shrink: 1;
  transition: background-color 0.3s ease;
}

.chat-view-slot.showing-history-chat {
  background-color: #f0f0f0 !important;
  border: 1px solid #e0e0e0;
}
.chat-view-slot.showing-history-chat .client-detail-section,
.chat-view-slot.showing-history-chat .dashboard-chat-area,
.chat-view-slot.showing-history-chat .typing-indicator-container {
  background-color: transparent !important;
}

.chat-view-slot.showing-history-chat
  .dashboard-chat-input-area
  input[type="text"] {
  background-color: #e9ecef;
  border: 1px solid #ced4da;
  color: #6c757d;
  cursor: not-allowed;
}
.chat-view-slot.showing-history-chat
  .dashboard-chat-input-area
  input[type="text"]::placeholder {
  color: #6c757d;
  opacity: 0.7;
}
.chat-view-slot.showing-history-chat
  .dashboard-chat-input-area
  .dashboardSendMessageBtn:disabled,
.chat-view-slot.showing-history-chat
  .dashboard-chat-input-area
  .dashboardSendMessageBtn {
  background-color: #adb5bd;
  border-color: #adb5bd;
  color: #f8f9fa;
  cursor: not-allowed;
  opacity: 0.65;
  transform: none !important;
}
.chat-view-slot.showing-history-chat
  .dashboard-chat-input-area
  .dashboardSendMessageBtn:disabled:hover,
.chat-view-slot.showing-history-chat
  .dashboard-chat-input-area
  .dashboardSendMessageBtn:hover {
  background-color: #adb5bd !important;
  border-color: #adb5bd !important;
  filter: none !important;
}

.chat-view-slot.active.single-view {
  display: flex;
  flex-basis: 100%;
}

.chat-view-slot.active.dual-view {
  display: flex;
  flex-basis: calc(50% - 7.5px);
}

.chat-area-wrapper.grid-view-active {
  flex-wrap: wrap;
}

.chat-view-slot.grid-view-item {
  flex-basis: calc(50% - 7.5px);
  height: calc(50% - 7.5px);
  flex-grow: 0; /* This prevents the item from stretching to fill empty space */
}

.close-view-btn {
  background-color: transparent;
  color: var(--color-text-medium);
  border: 1px solid transparent;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 1.3em;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease,
    border-color 0.2s ease;
  margin-left: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.close-view-btn:hover {
  background-color: var(--color-error-light, #fddede);
  color: var(--color-error, #d9534f);
  border-color: var(--color-error-light, #fddede);
}
.desktop-only-close-btn {
  display: none;
}

.no-chat-selected-placeholder {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  color: #e0e0e0;
  font-size: 1.2em;
  text-align: center;
  background-color: #ffffff;
  border-radius: 16px;
  padding-bottom: 50px;
}
.chat-view-slot.showing-history-chat .no-chat-selected-placeholder {
  background-color: #f0f0f0 !important;
}

.sound-activation-message {
  margin-top: 10px;
  font-size: 0.8em;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: color 0.3s ease;
  white-space: nowrap; /* Keep on one line for desktop */
}

.sound-activation-message.activated {
  color: var(--color-primary);
}

#soundStatusIcon {
  font-size: 1.1em;
}

.client-detail-section {
  background-color: transparent;
  padding: 12px 15px;
  border-bottom: none;
  box-shadow: 0px 0px 9px 4px #f0f0f0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}
.client-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--color-border);
}
.client-name-and-icon-wrapper {
  display: flex;
  align-items: center;
  flex-shrink: 1;
  margin-right: auto;
  overflow: hidden;
}
.client-detail-header h3 {
  margin: 0;
  font-size: 1.25em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block; /* Changed from flex to block to enable ellipsis */
  /* align-items: center; is not needed for display: block */
}

.client-name-form-indicator {
  background-color: #4caf50;
  color: white;
  padding: 1px 5px;
  font-size: 0.6em;
  border-radius: 8px;
  margin-left: 8px;
  font-weight: bold;
  line-height: 1;
  vertical-align: middle;
}

#chat-view-slot-0 .client-detail-header h3 {
  color: var(--color-view-0);
}
#chat-view-slot-2 .client-detail-header h3 {
  color: var(--color-view-2); /* Teal for view 2 */
}
#chat-view-slot-1 .client-detail-header h3 {
  color: var(--color-view-1);
}
#chat-view-slot-3 .client-detail-header h3 {
  color: var(--color-view-3); /* Purple for view 3 */
}

.chat-view-slot.showing-history-chat .client-detail-header h3 {
  color: #6c757d !important;
}

.new-message-in-view-indicator {
  display: none;
  background-color: var(--color-secondary);
  color: #ffffff;
  padding: 4px 8px;
  margin-bottom: 5px;
  border-radius: 8px;
  margin-left: 8px;
  margin-right: 5px;
  font-size: 0.5em;
  font-weight: bold;
  line-height: 1;
  text-align: center;
  vertical-align: middle;
}
/*.new-message-in-view-indicator.is-visible::before {
    content: "NEW";
}*/
.new-message-in-view-indicator.is-visible {
  display: inline-block;
}

.expand-info-icon {
  display: inline-block;
  font-size: 1em;
  color: var(--color-tertiary);
  vertical-align: middle;
  flex-shrink: 0;
  margin-left: 10px;
}
.header-controls-wrapper {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.header-note-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.header-note-wrapper::before {
  content: "#";
  font-size: 0.9em;
  color: var(--color-text-medium, #757575);
  padding-right: 4px;
  line-height: normal;
}
.compact-header-input {
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--color-border-light, #e0e0e0);
  background-color: #fff;
  color: var(--color-text-dark, #333);
  font-size: 0.8em;
  width: 120px;
}
.compact-header-input::placeholder {
  color: var(--color-text-light, #aaa);
}
.compact-header-input:focus {
  border-color: var(--color-tertiary);
  outline: none;
  box-shadow: 0 0 0 2px var(--color-tertiary-alpha-30);
}
.chat-view-slot.showing-history-chat .compact-header-input {
  background-color: #fff;
  border: 1px solid #d1d1d1;
}

.client-editable-info-wrapper {
  max-height: 500px;
  overflow: hidden;
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out,
    padding 0.3s ease-out, visibility 0s 0s;
  opacity: 1;
  padding-top: 10px;
  visibility: visible;
  padding-left: 0px;
  padding-right: 0px;
}
.client-detail-section.collapsed .client-editable-info-wrapper {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  visibility: hidden;
  transition: max-height 0.3s ease-out, opacity 0.2s ease-out,
    padding 0.3s ease-out, visibility 0s 0.3s;
}
.client-editable-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px 12px;
}

.client-editable-info .info-group.client-reason-and-buttons {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  gap: 5px;
}
.client-editable-info
  .info-group.client-reason-and-buttons
  label[for^="clientReason"] {
  grid-area: label;
}

.client-editable-info .info-group.client-reason-and-buttons .textarea-wrapper {
  flex-grow: 1;
}
.client-editable-info
  .info-group.client-reason-and-buttons
  textarea[id^="clientReason"] {
  height: 38px;
  margin-bottom: 0;
}

.client-editable-info
  .info-group.client-reason-and-buttons
  button.saveClientInfoBtn {
  grid-area: save;
}
.client-editable-info
  .info-group.client-reason-and-buttons
  button.downloadClientInfoBtn {
  grid-area: download;
}

.client-editable-info .info-group.client-reason-and-buttons .primary-btn,
.client-editable-info .info-group.client-reason-and-buttons .secondary-btn {
  padding: 6px 10px;
  font-size: 0.75em;
  height: 38px;
  align-self: stretch;
  border-radius: 8px;
}
.client-editable-info
  .info-group.client-reason-and-buttons
  .secondary-btn.downloadClientInfoBtn {
  background-color: #ffffff;
  border-color: #dcdcdc;
  color: #ccc;
}
.client-editable-info
  .info-group.client-reason-and-buttons
  .secondary-btn.downloadClientInfoBtn:hover {
  background-color: #f0f0f0;
  border-color: #dcdcdc;
  color: #ccc;
}

.client-editable-info input[type="text"],
.client-editable-info input[type="tel"],
.client-editable-info input[type="email"],
.client-editable-info textarea {
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.8em;
  background-color: #fff;
  color: var(--color-text-dark);
  width: 100%;
  box-sizing: border-box;
  font-family: "Courier New", Courier, monospace;
}
.client-editable-info textarea {
  resize: vertical;
}

.client-editable-info input:focus,
.client-editable-info textarea:focus {
  border-color: var(--color-tertiary);
  outline: none;
  box-shadow: 0 0 0 2px var(--color-tertiary-alpha-30);
}

.client-editable-info input:disabled,
.client-editable-info textarea:disabled {
  background-color: #f0f0f0 !important;
  color: #888 !important;
  cursor: not-allowed;
  border-color: var(--color-border-light) !important;
}
.client-editable-info button:disabled {
  background-color: #ccc !important;
  border-color: #bbb !important;
  color: #777 !important;
  cursor: not-allowed;
  opacity: 0.7;
}

.dashboard-chat-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background-color: transparent;
  min-height: 0;
  overflow: hidden;
  padding: 0px 15px 15px 15px;
}
.typing-indicator-container {
  height: 22px;
  padding: 0 0 5px 5px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.typing-indicator {
  font-size: 0.8em;
  color: #777;
  font-style: italic;
  height: 100%;
  display: flex;
  align-items: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}
.typing-indicator.active {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.typing-indicator-text {
  margin-right: 3px;
}
.typing-ellipsis::after {
  content: "...";
  display: inline-block;
  animation: typing-ellipsis-animation 1.5s infinite;
  width: 1.2em;
  text-align: left;
  vertical-align: bottom;
}
@keyframes typing-ellipsis-animation {
  0% {
    content: ".";
  }
  33% {
    content: "..";
  }
  66% {
    content: "...";
  }
  100% {
    content: ".";
  }
}

.chat-messages {
  width: 100%;
  flex-grow: 1;
  overflow-y: auto;
  padding-bottom: 15px;
  padding-top: 10px;
  background-color: transparent;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-messages div.chat-message {
  padding: 8px 12px;
  border-radius: 12px;
  max-width: 75%;
  box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.1);
  word-wrap: break-word;
  font-size: 0.9em;
  line-height: 1.4;
  position: relative;
  transition: background-color 0.3s ease;
}
.timestamp-wrapper {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7em;
  opacity: 0.7;
  margin-top: 4px;
}
.chat-messages div.chat-message.customer .timestamp-wrapper {
  justify-content: flex-start;
}
.chat-messages div.chat-message.owner .timestamp-wrapper {
  justify-content: flex-end;
}
.message-date {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width 0.4s ease-in-out;
}
.message-date.visible {
  max-width: 100px; /* Allows the date to expand into view */
}

.chat-messages div.chat-message.customer {
  background-color: #f5f8fa;
  border: 1px solid var(--color-border-xlight, #e0e0e0);
  align-self: flex-start;
  color: var(--color-text-dark, #333);
  text-align: left;
  border-radius: 12px 12px 12px 0;
}
.chat-messages div.chat-message.customer.new-owner-unreplied {
  background-color: var(--color-secondary) !important;
  border-color: color-mix(
    in srgb,
    var(--color-secondary) 85%,
    black
  ) !important;
}

.chat-messages div.chat-message.owner {
  background-color: #eadaff;
  align-self: flex-end;
  color: var(--color-text-dark, #333);
  text-align: right;
  border-radius: 12px 12px 0 12px;
}

.chat-messages div.chat-message.system {
  background: none;
  border: none;
  box-shadow: none;
  align-self: center;
  text-align: center;
  max-width: 100%;
  color: #6c757d;
  font-style: italic;
  font-size: 0.85em;
  padding: 5px 0;
}

/* Style for transfer system messages */
.chat-messages div.chat-message.system.transfer-message {
  background-color: var(--color-tertiary-xlight);
  border: 1px dashed var(--color-tertiary-light);
  color: var(--color-text-dark);
  padding: 8px 12px;
  border-radius: 8px;
}

.chat-messages div.chat-message.offline-form-message {
  background-color: #f0f8ff;
  border: 1px dashed #add8e6;
  color: #334;
  align-self: stretch;
  max-width: 90%;
  white-space: pre-wrap;
  font-style: italic;
  font-size: 0.85em;
  border-radius: 12px;
}

.pii-button {
  background-color: #eef2fa;
  border: 1px solid #b0c4de;
  padding: 2px 6px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85em;
  margin: 0 2px;
  transition: background-color 0.2s ease, border-color 0.2s ease,
    color 0.2s ease;
  font-family: inherit;
  line-height: normal;
  display: inline-block;
  vertical-align: baseline;
}
.pii-button:hover {
  background-color: #d6e0f0;
  border-color: #9cb3d9;
}

.pii-button.pii-button-view-0 {
  background-color: var(--color-tertiary-xlight);
  color: var(--color-tertiary);
  border-color: var(--color-tertiary-light);
}
.pii-button.pii-button-view-0:hover {
  background-color: var(--color-tertiary-light);
  border-color: var(--color-tertiary);
}

.pii-button.pii-button-view-1 {
  background-color: var(--color-quaternary-xlight);
  color: var(--color-quaternary);
  border-color: var(--color-quaternary-light);
}
.pii-button.pii-button-view-1:hover {
  background-color: var(--color-quaternary-light);
  border-color: var(--color-quaternary);
}

.dashboard-chat-input-area {
  flex-shrink: 0;
  padding-top: 10px;
  background-color: transparent;
  border-top: none;
  display: flex;
  gap: 8px;
  align-items: center;
}
.dashboard-chat-input-area input[type="text"] {
  flex-grow: 1;
  padding: 10px 15px;
  border: 1px solid var(--color-border, #ccc);
  border-radius: 20px;
  font-size: 0.9em;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.dashboard-chat-input-area input[type="text"]:focus {
  border-color: var(--color-tertiary);
  box-shadow: 0 0 0 2px var(--color-tertiary-alpha-25);
}
.dashboard-chat-input-area button {
  background-color: var(--color-primary);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 500;
  transition: background-color 0.2s ease, transform 0.1s ease;
  position: relative;
  overflow: hidden;
}

.dashboard-chat-input-area button span {
  display: inline-block;
  transition: transform 0.4s cubic-bezier(0.76, 0, 0.24, 1);
}

.dashboard-chat-input-area button:hover span,
.dashboard-chat-input-area button.typing-active span {
  transform: translateX(200%);
}

.dashboard-chat-input-area button::after {
  content: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><path d='M10 50 H85 M60 25 L85 50 L60 75' stroke='%23ffffff' stroke-width='12' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  width: 22px;
  height: 22px;
  position: absolute;
  top: 50%;
  left: -40px;
  transform: translateY(-50%);
  transition: left 0.4s cubic-bezier(0.76, 0, 0.24, 1);
}

.dashboard-chat-input-area button:hover::after,
.dashboard-chat-input-area button.typing-active::after {
  left: 50%;
  transform: translate(-50%, -50%);
}

.dashboard-chat-input-area button:disabled:hover span,
.dashboard-chat-input-area button:disabled.typing-active span {
  transform: translateX(0);
}

.dashboard-chat-input-area button:disabled:hover::after,
.dashboard-chat-input-area button:disabled.typing-active::after {
  left: -40px;
}

.dashboard-chat-input-area button:disabled {
  background-color: #cccccc !important;
  border-color: #cccccc !important;
  color: #666666 !important;
  cursor: not-allowed !important;
  opacity: 0.65 !important;
  transform: none !important;
}

#chat-view-slot-0 .dashboard-chat-input-area .dashboardSendMessageBtn {
  background-color: var(--color-tertiary);
  color: white;
}
#chat-view-slot-2 .dashboard-chat-input-area .dashboardSendMessageBtn {
  background-color: var(--color-view-2); /* Teal for view 2 */
  color: white;
}
#chat-view-slot-0 .dashboard-chat-input-area .dashboardSendMessageBtn:hover {
  background-color: color-mix(in srgb, var(--color-tertiary) 85%, black);
}
#chat-view-slot-2 .dashboard-chat-input-area .dashboardSendMessageBtn:hover {
  background-color: color-mix(
    in srgb,
    var(--color-quinary) 85%,
    black
  ); /* Teal for view 2 */
}

#chat-view-slot-1 .dashboard-chat-input-area .dashboardSendMessageBtn {
  background-color: var(--color-quaternary);
  color: white;
}
#chat-view-slot-3 .dashboard-chat-input-area .dashboardSendMessageBtn {
  background-color: var(--color-view-3); /* Pink for view 3 */
  color: white;
}
#chat-view-slot-1 .dashboard-chat-input-area .dashboardSendMessageBtn:hover {
  background-color: color-mix(in srgb, var(--color-quaternary) 85%, black);
}
#chat-view-slot-3 .dashboard-chat-input-area .dashboardSendMessageBtn:hover {
  background-color: color-mix(
    in srgb,
    var(--color-senary) 85%,
    black
  ); /* Purple for view 3 */
}

/* =================================================================== */
/* CENTRALIZED MODAL STYLES                                            */
/* =================================================================== */
/* These base styles apply to all modals for consistency. */

/* --- Modal Backdrop --- */
.modal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place even when scrolling */
  z-index: 1000; /* Sit on top of everything else */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto; /* Enable scroll if needed */
  background-color: rgba(30, 30, 50, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  align-items: center; /* Center the modal content vertically */
  justify-content: center; /* Center the modal content horizontally */
}

/* --- Modal Content Box (Base) --- */
.modal-content {
  position: relative; /* Establishes positioning context for the close button */
  border-radius: 16px;
  padding: 25px 30px;
  max-width: 650px; /* A good default max-width */
  text-align: center; /* Default alignment for simple modals */
}

.close-button {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 2em;
  font-weight: 300;
  color: #aaa;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease;
  z-index: 10;
}

.close-button:hover {
  color: #333;
}

/* Specific max-widths can still be set via ID for complex modals */
#helpModal .modal-content,
#faqSettingsModal .modal-content,
#promoSettingsModal .modal-content,
#standalonePromoModal .modal-content {
  max-width: 800px;
}
#embedWidgetModal .modal-content {
  max-width: 680px;
}
#deleteChatConfirmModal .modal-content {
  max-width: 420px;
}
#companyBrandingModal .modal-content {
  max-width: 450px;
}

/* --- Modal Typography --- */
/* Main Title */
.modal-content h2 {
  color: var(--color-primary);
  font-size: 1.6em;
  font-weight: 600;
  margin: 0 0 10px 0;
  text-align: center;
}
/* Main Description (under the title) */
.modal-description {
  font-size: 0.95em;
  color: #555;
  line-height: 1.5;
  margin: 0 auto 25px auto;
  max-width: 700px; /* Consistent max-width for readability */
  text-align: center;
}
/* All other headings (h3, h4) default to left-aligned */
.modal-content h3,
.modal-content h4 {
  text-align: left;
  color: var(--color-text-dark);
  margin-bottom: 15px;
  margin-top: 5px;
}
/* All other paragraphs (p) default to left-aligned */
.modal-content p {
  text-align: center;
  color: var(--color-text-dark);
  line-height: 1.6;
  margin-bottom: 12px;
}
/* Center-align paragraphs only in the simplest confirmation modals */
#deleteChatConfirmModal .modal-content p,
#blockUnblockModal .modal-content p,
#mergeConfirmModal .modal-content p {
  text-align: center;
}

/* --- Modal Button Container & Styles --- */
.modal-buttons {
  display: flex;
  justify-content: center; /* Default alignment */
  align-items: center; /* This line fixes the vertical alignment */
  gap: 10px;
  margin-top: 25px;
}
/* Modifier to right-align buttons where needed */
#embedWidgetModal .modal-buttons {
  justify-content: flex-end;
}
/* Primary Button in Modals */
.modal .primary-btn {
  background-color: var(--color-primary);
  color: white;
  border: 1px solid var(--color-primary);
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9em;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.modal .primary-btn:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}
.modal .primary-btn:disabled {
  background-color: #cccccc !important;
  border-color: #cccccc !important;
  cursor: not-allowed;
  opacity: 0.7;
}
.modal .secondary-btn {
  background-color: #f6f6f6;
  color: #333;
  border: 1px solid #ccc;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9em;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  min-width: 100px;
  text-align: center;
}

/* Add space between icons and text on specific modal buttons */
#addHelperLinkBtn i,
#addHelperSubmenuBtn i {
  margin-right: 8px;
}

/* Fix to ensure modal buttons have the same height */
.modal-buttons .primary-btn,
.modal-buttons .secondary-btn {
  height: 42px; /* Enforces a consistent height */
  display: inline-flex; /* Aligns text vertically */
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
.modal .secondary-btn:hover {
  background-color: #e9e9e9;
  border-color: #bbb;
}

/* Destructive action button style for confirmation modals */
#deleteChatConfirmModal #confirmDeleteChatBtn {
  background-color: var(--color-error-light);
  border-color: var(--color-error);
  color: var(--color-error);
  font-weight: 600;
}

#deleteChatConfirmModal #confirmDeleteChatBtn:hover {
  background-color: var(--color-error);
  border-color: var(--color-error);
  color: #ffffff;
}
.modal .secondary-btn:disabled {
  background-color: #e9ecef !important;
  border-color: #ced4da !important;
  color: #6c757d !important;
  cursor: not-allowed;
  opacity: 0.65;
}

/* --- Other Modal Specifics --- */
.upload-message {
  margin-top: 15px;
  color: var(--color-text-medium);
  font-size: 0.9em;
  text-align: center;
  transition: display 0.3s ease;
}

.modal-content.company-branding-modal .logo-upload-section {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--color-border);
  text-align: left;
}
.modal-content.company-branding-modal .logo-upload-section label {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: normal;
  color: var(--color-text-dark);
}
.modal-content.company-branding-modal
  .logo-upload-section
  img#modalCompanyLogoPreview {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--color-border);
  display: none;
}
.modal-content.company-branding-modal
  .logo-upload-section
  input[type="file"]#companyLogoUpload {
  display: none;
}
.modal-content.company-branding-modal .logo-upload-section .upload-btn {
  background-color: var(--color-success, #5cb85c);
  color: white;
  padding: 8px 15px;
  border: 1px solid transparent; /* Use transparent border for consistent sizing */
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9em;
  transition: background-color 0.2s ease;
}

.modal-content.company-branding-modal .logo-upload-section .upload-btn:hover {
  background-color: #4cae4c;
}

/* --- Agent Management Modal Form Styles --- */
#inviteAgentForm {
  display: flex;
  flex-direction: column;
  gap: 15px; /* Spacing between form groups */
  text-align: left;
  margin-top: 20px;
}

#inviteAgentForm .form-group {
  display: flex;
  flex-direction: column;
}

#inviteAgentForm label {
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 0.9em;
  color: var(--color-text-dark);
}

#inviteAgentForm input[type="text"],
#inviteAgentForm input[type="email"],
#inviteAgentForm input[type="password"] {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9em;
  box-sizing: border-box;
  font-family: inherit;
}

#inviteAgentForm input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-tertiary-alpha-25);
  outline: none;
}

#inviteAgentForm button[type="submit"] {
  align-self: flex-start;
}

.existing-agents-section {
  text-align: left;
}

.agent-info .agent-name {
  font-weight: 500;
}
.agent-info .agent-email {
  font-size: 0.85em;
  color: #666;
  margin-left: 10px;
}
.remove-agent-btn {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 1.4em;
}
.remove-agent-btn:hover {
  color: var(--color-error);
}
.modal-divider {
  border: none;
  margin: 25px 0;
}

.logo-button-group {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.remove-logo-btn {
  padding: 8px 15px;
  font-size: 0.9em;
  background-color: transparent;
  color: var(--color-error, #d9534f);
  border: 1px solid var(--color-error, #d9534f);
  border-radius: 8px; /* Ensure border radius is consistent */
}

.remove-logo-btn:hover {
  background-color: var(--color-error-light, #fddede);
}
.help-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}
.help-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}
.help-modal ul {
  list-style: none;
  padding-left: 0;
  text-align: left;
  margin-bottom: 20px;
}
.help-modal ul li {
  margin-bottom: 10px;
  color: var(--color-text-dark);
}
.help-modal ul li strong {
  color: var(--color-primary);
}

.dashboard-footer {
  display: flex;
  justify-content: space-between; /* Aligns items to the left and right */
  align-items: center;
  padding: 15px 20px; /* Base padding */
  padding-left: 285px; /* Pushes content past the sticky note on desktop */
  font-size: 0.8em;
  color: #888888;
  flex-shrink: 0;
  background-color: var(--color-background-light);
  gap: 10px;
}

.dashboard-footer a {
  color: #666666;
  text-decoration: none;
}
.dashboard-footer a:hover {
  text-decoration: underline;
}

.dashboard-footer .footer-btn {
  background: transparent;
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
  cursor: pointer;
  font-size: 0.9em; /* Makes font slightly smaller */
  padding: 6px 12px; /* Adjusts padding for a consistent look */
  border-radius: 8px;
  text-decoration: none;
  line-height: normal;
  transition: all 0.2s ease;
  white-space: nowrap; /* Prevents text from wrapping to a new line */
  flex-shrink: 0; /* Prevents buttons from shrinking in a crowded footer */
}
.dashboard-footer .footer-btn:hover {
  background-color: transparent;
  border-color: var(--primary-hover);
  color: var(--primary-hover);
}

.footer-item-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-footer .trial-tag {
  background-color: #81c784;
  color: white;
  padding: 3px 7px;
  border-radius: 8px;
  font-size: 0.7em;
  font-weight: bold;
  text-transform: uppercase;
  line-height: 1;
}

.embed-options-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 25px;
}

.embed-option-box {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px;
  border: 2px solid var(--color-border-light);
  border-radius: 12px;
  cursor: pointer;
  background-color: #fcfcfc;
  transition: border-color 0.2s ease, background-color 0.2s ease,
    box-shadow 0.2s ease;
}

.embed-option-box:hover {
  border-color: var(--color-tertiary);
  background-color: #ffffff;
}

.embed-option-box.selected {
  border-color: var(--color-primary);
  background-color: #f8f0ff;
  box-shadow: 0 0 0 3px var(--color-tertiary-alpha-25);
}

.embed-option-icon {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
}
.embed-option-icon svg {
  width: 100%;
  height: 100%;
}
.embed-option-text h3 {
  margin: 0 0 5px 0;
  font-size: 1.1em;
  color: var(--color-text-dark);
  text-align: left;
}
.embed-option-text p {
  margin: 0;
  font-size: 0.9em;
  color: #666;
  line-height: 1.4;
  text-align: left;
}

.embed-instructions-area {
  margin-top: 20px;
  border-top: 0px solid var(--color-border);
}

.embed-code-wrapper {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

#generatedEmbedCode {
  flex-grow: 1;
  padding: 12px 15px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9em;
  background-color: #f1f3f5;
  color: #333;
  resize: none;
  height: 110px;
  box-sizing: border-box;
  white-space: pre-wrap;
  word-break: break-all;
}

#copyEmbedCodeBtn {
  flex-shrink: 0;
  padding: 0 20px;
  align-self: flex-start;
  height: 46px; /* Match textarea height */
}

#embedInstructionsText {
  font-size: 0.9em;
  color: #444;
  line-height: 1.6;
  background-color: #f7f9fc;
  padding: 12px 15px;
  border-radius: 8px;
  margin-bottom: 15px;
}
#embedInstructionsText strong {
  color: var(--color-primary);
}

.embed-learn-more {
  font-size: 0.85em;
  color: #666;
  text-align: center;
}
.embed-learn-more a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}
.embed-learn-more a:hover {
  text-decoration: underline;
}

.accordion {
  width: 100%;
  border-top: 1px solid var(--color-border-light);
}
.accordion-item {
  border-bottom: 1px solid var(--color-border-light);
}
.accordion-header {
  background-color: transparent;
  color: var(--color-text-dark);
  cursor: pointer;
  padding: 15px;
  width: 100%;
  text-align: left;
  border: none;
  outline: none;
  transition: background-color 0.2s ease;
  font-size: 1.1em;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.accordion-header:hover,
.accordion-header.active {
  background-color: var(--color-tertiary-xlight);
  color: var(--primary-hover);
}
.accordion-header i {
  transition: transform 0.3s ease;
}
.accordion-header.active i {
  transform: rotate(180deg);
}
.accordion-panel {
  background-color: white;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}
.accordion-content {
  padding: 18px;
}
.accordion-content p {
  margin: 0;
  line-height: 1.6;
  color: var(--color-text-dark);
}

#helpModal .help-content p {
  margin-bottom: 12px;
  line-height: 1.6;
}
#helpModal .help-content strong {
  color: #bd7bff; /* Main theme color for titles */
  font-weight: 600;
}

.textarea-wrapper {
  position: relative;
  display: flex;
  flex-grow: 1;
}

.client-editable-info
  .info-group.client-reason-and-buttons
  textarea[id^="clientReason"] {
  resize: none;
  width: 100%;
  padding-right: 35px;
}

.expand-textarea-btn {
  position: absolute;
  bottom: 5px;
  right: 5px;
  cursor: pointer;
  background: transparent;
  border: none;
  color: #a0a0a0;
  font-size: 0.9em;
  padding: 5px;
  border-radius: 5px;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.expand-textarea-btn:hover {
  color: #333;
  background-color: #f0f0f0;
}

.client-editable-info
  .info-group.client-reason-and-buttons
  textarea[id^="clientReason"].expanded {
  height: 180px;
}

.grecaptcha-badge {
  visibility: hidden;
}

#faqModalContentWrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  text-align: left;
}

.faq-item {
  width: 100%;
  background-color: var(--color-tertiary-xlight, #eaf2fe);
  border: 1px solid var(--color-tertiary-light, #b9d2f9);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 15px;
}

.faq-item label {
  font-weight: 500;
  font-size: 0.9em;
  margin-bottom: 5px;
  display: block;
}

.faq-question-input,
.faq-answer-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9em;
  box-sizing: border-box;
}

.faq-question-input {
  display: block;
  width: 100%;
  margin-bottom: 10px;
}

#faqModalContentWrapper .faq-question-input {
  width: 100%;
}

.faq-answer-textarea {
  resize: vertical;
  min-height: 80px;
  font-family: sans-serif;
  line-height: 1.5;
}

.faq-question-input:focus,
.faq-answer-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-tertiary-alpha-25);
  outline: none;
}

.remove-faq-btn {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 1.4em;
  line-height: 1;
  padding: 0 5px;
}

.remove-faq-btn:hover {
  color: var(--color-error);
}

.greeting-modal-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: left;
  margin-top: 20px;
}

.greeting-modal-body .form-group {
  display: flex;
  flex-direction: column;
}

.greeting-modal-body label {
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 0.9em;
  color: var(--color-text-dark);
}

.greeting-modal-body textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9em;
  box-sizing: border-box;
  resize: vertical;
  min-height: 70px;
  font-family: sans-serif;
  line-height: 1.5;
}

.greeting-modal-body textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-tertiary-alpha-25);
  outline: none;
}

/* =================================================================== */
/* DESKTOP STYLES (1060px and up)                      */
/* =================================================================== */
@media (min-width: 1150px) {
  .client-editable-info {
    grid-template-columns: 1fr 1fr;
  }
  .client-editable-info .info-group {
    grid-column: auto;
  }
  .client-editable-info .info-group.client-reason-and-buttons {
    grid-column: 1 / -1;
    margin-top: 0px;
  }

  #ownerNameInput::placeholder {
    color: transparent;
  }

  .desktop-only-close-btn {
    display: flex !important;
  }
  .history-header #toggleHistoryIcon {
    display: inline-block !important;
  }

  .owner-settings-header-bar .header-left {
    width: auto;
    justify-content: flex-start;
    gap: 15px;
    padding: 0;
  }
  .owner-settings-header-bar .header-right {
    width: auto;
    justify-content: flex-end;
    margin-right: 0;
  }
  .owner-settings-header-bar .status-toggle-container {
    position: static;
    transform: none;
    background-color: transparent;
    padding: 0;
    z-index: auto;
  }
  .owner-settings-header-bar .status-toggle-container #ownerStatusText {
    font-size: 1em;
  }
  .owner-settings-header-bar .header-right button.compact-btn#saveSettingsBtn {
    margin-left: 0;
    font-weight: 200;
  }
  .sticky-note-container {
    display: flex;
  }
  .fixed-help-button {
    width: 40px;
    height: 40px;
    font-size: 1.3em;
    left: 20px;
    bottom: 10px;
  }
  .fixed-help-button:hover {
    background-color: var(--primary-hover);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
  }

  .owner-settings-header-bar
    #chatColorSettingsGroup
    label[for="chatColorInput"] {
    display: none;
  }
  .owner-settings-header-bar
    #chatColorSettingsGroup
    .custom-color-picker-wrapper {
    margin-left: 0;
  }

  .dashboard-sidebar {
    width: 30%;
    max-width: 280px;
    height: auto;
    padding: 15px;
    overflow: hidden;
  }

  .client-detail-section:not(.collapsed) .client-editable-info-wrapper {
    max-height: 500px;
    opacity: 1;
    padding-top: 10px;
    visibility: visible;
  }

  .chat-view-slot.active.dual-view .client-detail-header h3 {
    max-width: 180px;
  }
  .chat-view-slot.active.dual-view .compact-header-input {
    width: 90px;
  }
  .chat-view-slot.active.dual-view .client-editable-info {
    grid-template-columns: 1fr;
  }

  .dashboard-footer {
    justify-content: flex-end;
    padding-right: 20px;
  }

  /* From original min-width: 1351px */
  .dashboard-container {
    padding-top: 20px;
  }
  .dashboard-sidebar {
    width: 290px;
    flex-grow: 0;
    flex-shrink: 0;
    height: 100%;
    padding: 15px;
    overflow: hidden;
  }

  #activeClientList li,
  #agentsList li {
    /* Apply the same padding and margin to agentsList items */
    padding: 8px 10px;
    width: auto; /* Allow width to adjust based on content and margins */
  }
  #activeClientList {
    display: block; /* Ensure it behaves as a block list */
    max-height: none;
  }
  /* Ensure agentsList also behaves as a block list by default for consistent styling */
  #agentsList {
    display: block;
    max-height: none; /* Allow content to dictate height */
  }
  .active-chats-section .sidebar-subheading {
    display: block !important;
  }
  .dashboard-sidebar .sidebar-subheading {
    margin: 15px 0 10px 0;
    padding-left: 10px;
  }

  .owner-settings-header-bar .header-right button.compact-btn#saveSettingsBtn {
    width: auto;
    height: auto;
    font-size: 0.9em;
    padding: 8px 15px;
    border-radius: 5px;
    background-image: none;
    text-indent: 0;
  }
  .owner-settings-header-bar
    #chatColorSettingsGroup
    label[for="chatColorInput"] {
    display: inline;
  }
  .owner-settings-header-bar #greetingMessageSettingsGroup {
    display: flex !important;
  }
  .expand-info-icon {
    display: inline-block !important; /* Changed from none to inline-block */
  }
  /* This rule now only applies when the section is NOT collapsed */
  .client-detail-section:not(.collapsed) .client-editable-info-wrapper {
    max-height: 500px;
    opacity: 1 !important;
    padding-top: 10px;
    visibility: visible !important;
  }

  .chat-view-slot.active.dual-view .compact-header-input {
    width: 120px;
  }
  .chat-view-slot.active.dual-view .client-editable-info {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }

  /* Fix: Reorder header elements for desktop view when settings are open */
  .owner-settings-header-bar > #managementSettingsContainer {
    order: 1;
  }

  .owner-settings-header-bar > .header-right {
    order: 2;
  }
}

/* =================================================================== */
/* INTERMEDIATE STYLES (842px to 1300px)              */
/* =================================================================== */
@media (min-width: 842px) and (max-width: 1300px) {
  .owner-settings-header-bar {
    justify-content: flex-end; /* Align content (and wrapped lines) to the right */
  }
  .owner-settings-header-bar .header-left {
    margin-right: auto; /* Push the left-side content back to the far left */
  }

  .client-editable-info {
    grid-template-columns: 1fr 1fr;
  }
  .client-editable-info .info-group {
    grid-column: auto;
  }
  .client-editable-info .info-group.client-reason-and-buttons {
    grid-column: 1 / -1;
    margin-top: 0px;
  }
  .chat-view-slot.active.dual-view
    .client-editable-info
    .info-group.client-reason-and-buttons {
    margin-top: 0px;
  }

  #ownerNameInput::placeholder {
    color: transparent;
  }

  .desktop-only-close-btn {
    display: flex !important;
  }
  .history-header #toggleHistoryIcon {
    display: inline-block !important;
  }
  .owner-settings-header-bar {
    flex-direction: row;
    align-items: center;
    gap: 0px;
    padding-bottom: 10px;
  }
  .owner-settings-header-bar .header-left {
    width: auto;
    justify-content: flex-start;
    gap: 15px;
    padding: 0;
  }
  .owner-settings-header-bar .header-right {
    width: auto;
    justify-content: flex-end;
    margin-right: 0;
  }
  .owner-settings-header-bar .status-toggle-container {
    position: static;
    transform: none;
    background-color: transparent;
    padding: 0;
    z-index: auto;
  }
  .owner-settings-header-bar .status-toggle-container #ownerStatusText {
    font-size: 1em;
  }
  .owner-settings-header-bar .header-right button.compact-btn#saveSettingsBtn {
    margin-left: 0;
    font-weight: 200;
  }

  .sticky-note-container {
    display: flex;
  }
  .fixed-help-button {
    width: 40px;
    height: 40px;
    font-size: 1.3em;
    left: 20px;
    bottom: 10px;
  }
  .fixed-help-button:hover {
    background-color: var(--primary-hover);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
  }

  .owner-settings-header-bar
    #chatColorSettingsGroup
    label[for="chatColorInput"] {
    display: none;
  }
  .owner-settings-header-bar
    #chatColorSettingsGroup
    .custom-color-picker-wrapper {
    margin-left: 0;
  }
  .owner-settings-header-bar .header-right button.compact-btn#saveSettingsBtn {
    padding: 8px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 0;
    background-color: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23FFFFFF'%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3zm3-10H5V5h10v4z'/%3E%3C/svg%3E");
    background-size: 60%;
    background-repeat: no-repeat;
    background-position: center;
    text-indent: -9999px;
    line-height: 0;
  }

  .dashboard-sidebar {
    width: 30%;
    max-width: 280px;
    height: auto;
    padding: 15px;
    overflow: hidden;
  }

  .client-detail-section .expand-info-icon {
    display: inline-block !important;
  }

  .chat-view-slot.active.dual-view .client-detail-header h3 {
    max-width: 180px;
  }
  .chat-view-slot.active.dual-view .compact-header-input {
    width: 90px;
  }
  .chat-view-slot.active.dual-view .client-editable-info {
    grid-template-columns: 1fr;
  }

  .dashboard-footer {
    justify-content: flex-end;
    padding-right: 20px;
  }
}

/* =================================================================== */
/* MOBILE STYLES (842px and less)                      */
/* =================================================================== */
@media (max-width: 842px) {
  .client-editable-info .info-group.client-reason-and-buttons {
    margin-top: 0px;
  }

  .owner-settings-header-bar {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 15px;
    padding-bottom: 8px;
  }

  .agent-view .supervisor-status-indicator {
    display: none !important;
  }

  .agent-view .helper-menu-bar {
    display: none !important; /* Hide helper menu on mobile */
  }
  .owner-settings-header-bar .header-left {
    justify-content: flex-start;
    flex-grow: 1; /* Pushes the right-side content to the very end of the line */
  }
  .owner-settings-header-bar .header-right {
    gap: 8px;
  }

  /* When management settings are opened on mobile, they take the full width on a new line */
  .owner-settings-header-bar #managementSettingsContainer {
    flex-basis: 100%;
    margin-top: 8px;
    gap: 8px; /* Add gap between items */
  }

  /* Make the inputs within the mobile settings view grow to fill the space */
  .owner-settings-header-bar #managementSettingsContainer .compact-input {
    flex-grow: 1;
  }
  .owner-settings-header-bar .settings-group {
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
  }
  .owner-settings-header-bar .settings-group label {
    display: none;
  }
  .owner-settings-header-bar .compact-input {
    width: 100%;
    height: 36px;
    box-sizing: border-box;
  }
  .owner-settings-header-bar .status-toggle-container {
    position: static;
    transform: none;
    padding: 0;
    right: auto;
    top: auto;
    z-index: auto;
    background-color: transparent;
    flex-shrink: 0;
  }
  .owner-settings-header-bar .status-toggle-container #ownerStatusText {
    font-size: 0.85em;
  }
  .owner-settings-header-bar #openGreetingModalBtn,
  .owner-settings-header-bar #chatColorSettingsGroup,
  .owner-settings-header-bar .compact-btn#faqSettingsBtn,
  .owner-settings-header-bar .compact-btn#promoSettingsBtn {
    display: none !important;
  }
  .owner-settings-header-bar .header-right button.compact-btn#saveSettingsBtn {
    padding: 8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 0;
    background-color: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23FFFFFF'%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3zm3-10H5V5h10v4z'/%3E%3C/svg%3E");
    background-size: 60%;
    background-repeat: no-repeat;
    background-position: center;
    text-indent: -9999px;
    line-height: 0;
    margin-left: auto;
    flex-grow: 0;
    flex-shrink: 0;
  }
  .owner-settings-header-bar .company-logo-container {
    font-size: 1.1em;
    gap: 6px;
    padding: 5px 6px;
  }
  .owner-settings-header-bar .company-logo-container #companyLogoImg {
    width: 30px;
    height: 30px;
  }

  .fixed-help-button {
    width: 32px;
    height: 32px;
    font-size: 1em;
    left: 5px;
    bottom: 5px;
    transform: none;
    right: auto;
    position: fixed;
    z-index: 999;
  }

  .sticky-note-container {
    display: none !important;
  }

  .dashboard-container {
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
  }

  .dashboard-content-area {
    display: flex;
    flex-grow: 1;
    min-height: 0;
    flex-direction: column;
    width: 100%;
    padding-left: 10px;
    padding-right: 10px;
    box-sizing: border-box;
    gap: 10px;
    overflow: auto;
  }
  .dashboard-main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .dashboard-sidebar {
    width: 100%;
    padding: 10px;
    min-height: auto;
    overflow: visible;
    box-shadow: none;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid var(--color-border-light, #e0e0e0);
    height: auto;
    border-radius: 12px;
  }

  .search-container,
  .queue-section .sidebar-subheading,
  .active-chats-section .sidebar-subheading {
    display: none !important;
  }
  .dashboard-sidebar .sidebar-subheading {
    margin: 8px 0 5px 0;
    padding-left: 5px;
  }
  .history-chats-section .sidebar-subheading#historySubheading {
    display: flex;
    align-items: center;
    margin: 8px 0 5px 0;
    padding-left: 5px;
  }

  .dashboard-sidebar .search-input-main {
    margin-left: 0;
    margin-right: 0;
  }
  .dashboard-sidebar .search-input-main,
  .dashboard-sidebar .search-filter-options {
    display: none !important;
    margin-left: 0;
    margin-right: 0;
  }
  .client-list {
    padding-left: 0;
    padding-right: 0;
  }

  .active-chats-section {
    display: flex !important;
    flex-grow: 0;
    flex-shrink: 0;
    min-height: auto;
    overflow: visible;
    margin-top: 0;
    padding-top: 0;
  }

  #activeClientList {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    margin: 0 -10px;
    padding: 0 10px 8px 10px;
  }
  #activeClientList li {
    padding: 12px 10px;
    margin: 0;
    overflow: hidden;
    height: auto;
    flex: 0 0 calc(50% - 6px);
  }

  .history-chats-section {
    display: none;
    flex-direction: column;
    min-height: 0;
  }

  .dashboard-sidebar.mobile-search-active .history-chats-section {
    margin-top: 10px;
    border-top: 1px solid var(--color-border-light, #e0e0e0);
    padding-top: 10px;
  }
  .dashboard-sidebar.mobile-search-active:not(.history-expanded)
    .history-chats-section {
    flex-grow: 0;
    flex-shrink: 0;
  }
  .dashboard-sidebar.mobile-search-active.history-expanded
    .history-chats-section {
    flex-grow: 1;
  }

  .dashboard-footer .footer-btn {
    display: none !important;
  }
  .modal-content.embed-widget-modal {
    max-width: 90%;
  }
  .embed-options-container {
    grid-template-columns: 1fr;
  }
  #generatedEmbedCode {
    font-size: 0.8em;
  }
  .dashboard-footer {
    justify-content: center;
    padding: 5px 20px;
  }

  .sound-activation-message {
    flex-direction: column;
    align-items: center;
    white-space: normal;
    text-align: center;
  }

  .client-list li .remove-chatroom-btn {
    display: none !important;
  }

  @media (hover: none) {
    .login-box button:hover,
    .auth-container .cta-button:hover,
    .dashboard-chat-input-area button:hover,
    .fixed-help-button:hover,
    .owner-settings-header-bar .company-logo-container:hover,
    .owner-settings-header-bar .compact-btn:hover,
    .diminish-sticky-note-btn:hover,
    .history-header:hover,
    #toggleHistoryIcon:hover,
    .client-list li:hover .remove-chatroom-btn:hover,
    .close-view-btn:hover,
    .client-editable-info
      .info-group.client-reason-and-buttons
      .secondary-btn.downloadClientInfoBtn:hover,
    .pii-button:hover,
    .pii-button.pii-button-view-0:hover,
    .pii-button.pii-button-view-1:hover,
    .modal button.primary-btn:hover,
    #closeFullHistoryViewBtn.primary-btn:hover,
    .modal button.secondary-btn:hover,
    .modal-content.company-branding-modal
      .logo-upload-section
      .upload-btn:hover,
    .embed-option-box:hover,
    .dashboard-footer .footer-btn:hover,
    #chat-view-slot-0
      .client-editable-info
      .info-group.client-reason-and-buttons
      .saveClientInfoBtn:hover,
    #chat-view-slot-0 .dashboard-chat-input-area .dashboardSendMessageBtn:hover,
    #chat-view-slot-1
      .client-editable-info
      .info-group.client-reason-and-buttons
      .saveClientInfoBtn:hover,
    #chat-view-slot-1 .dashboard-chat-input-area .dashboardSendMessageBtn:hover,
    .accordion-header:hover,
    .expand-textarea-btn:hover,
    .client-list li:hover {
      background-color: initial !important;
      color: initial !important;
      border-color: initial !important;
      transform: none !important;
      box-shadow: none !important;
      text-decoration: none !important;
      filter: none !important;
      opacity: initial !important;
    }
  }
}

/* --- Styles for Show/Hide Password Toggle --- */
.password-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.password-wrapper input {
  padding-right: 45px; /* Make space for the icon */
}

.password-toggle-icon {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: #9ca3af; /* A medium grey color */
  transition: color 0.2s ease;
}

.password-toggle-icon:hover {
  color: #6b7280; /* A darker grey on hover */
}

/* Adjust icon position for auth-container inputs which are taller */
.auth-container .password-wrapper .password-toggle-icon {
  top: 24px; /* Manually adjust for the specific input height */
}

/* Adjust icon position for signup-box inputs */
.signup-box .password-wrapper .password-toggle-icon {
  top: 50%; /* This one can use the default centering */
}

/* Layout fix for translations */
/* Layout fix for translations */
.owner-settings-header-bar .header-right {
  flex-wrap: wrap;
  gap: 8px 12px;
}
.owner-settings-header-bar .settings-group {
  flex-shrink: 0;
}
.color-palette {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* Styles for New Embed Modal Layout */
.embed-settings-title {
  text-align: center;
  color: var(--color-text-dark);
  font-weight: 600;
  margin-bottom: 25px;
  border-bottom: 1px solid var(--color-border-light);
  padding-bottom: 15px;
}
.embed-setting-block {
  background-color: #f7f9fc;
  border: 1px solid #e7eaf3;
  border-radius: 12px;
  padding: 20px 20px 15px 20px; /* Reduced bottom padding */
  margin-bottom: 20px;
  text-align: left;
}
.embed-step-title {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.1em;
  color: var(--color-text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}
.step-number {
  background-color: var(--color-primary);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8em;
  font-weight: 700;
}
.allowed-domains-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background-color: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  min-height: 44px;
  margin-bottom: 10px;
}
.domain-tag {
  display: inline-flex;
  align-items: center;
  background-color: #e0e7ff;
  color: #4338ca;
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 0.9em;
  font-weight: 500;
}
.remove-domain-btn {
  background: #c7d2fe;
  color: #4338ca;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  margin-left: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 16px;
  text-align: center;
  padding: 0;
}
.add-domain-wrapper {
  display: flex;
  gap: 10px;
}
#newDomainInput {
  flex-grow: 1;
  padding: 10px 12px; /* Adjusted padding */
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1em;
  height: 42px; /* Explicit height */
  box-sizing: border-box;
}
#addDomainBtn {
  height: 42px; /* Explicit height */
  flex-shrink: 0;
  box-sizing: border-box;
}
.save-status-message {
  font-size: 0.85em;
  color: green;
}
.embed-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px; /* Slightly reduced gap */
  cursor: pointer;
  font-size: 0.95em;
}

.embed-checkbox-label input[type="checkbox"] {
  margin: 0; /* Reset browser-default margins */
  margin-right: 5px;
  flex-shrink: 0; /* Prevent the checkbox from shrinking */
  transform: translateY(1px);
  width: 16px;
  height: 16px;
}

/* Visually disable the attachments block for non-enterprise users */
#attachmentsSettingBlock.disabled-for-plan {
  opacity: 0.6;
  cursor: pointer;
  background-color: #f0f0f0;
}

/* --- Custom Promo Settings Modal Styles --- */
.promo-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr; /* Creates a two-column layout */
  gap: 15px 20px;
  text-align: left;
  margin-top: 20px;
}

.promo-form-grid .form-group {
  display: flex;
  flex-direction: column;
}

.promo-form-grid .form-group.full-width {
  grid-column: 1 / -1; /* Makes an element span both columns */
}

.promo-form-grid label {
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 0.9em;
  color: var(--color-text-dark);
}

.promo-form-grid .form-group .form-field-description {
  font-size: 0.8em;
  color: #888;
  margin: -5px 0 8px 1px;
  font-style: italic;
  padding: 0;
  text-align: left;
}

.promo-form-grid input[type="text"],
.promo-form-grid input[type="url"],
.promo-form-grid input[type="number"],
.promo-form-grid textarea,
.promo-form-grid select,
#embedLanguageSelect {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9em;
  box-sizing: border-box;
  font-family: inherit;
}

/* Set a smaller, more appropriate width for the number input */
#standalonePromoDelay {
  width: 350px;
}

/* Style the embed code textarea to match other fields and make it taller */
.label-with-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 100%;
}

.help-link-inline {
  font-size: 0.8em;
  font-weight: 400;
  color: var(--color-primary);
  text-decoration: none;
  white-space: nowrap;
}

.help-link-inline:hover {
  text-decoration: underline;
}

.promo-form-grid textarea {
  resize: vertical;
  min-height: 90px;
}

.promo-form-grid input:focus,
.promo-form-grid textarea:focus,
.promo-form-grid select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-tertiary-alpha-25);
  outline: none;
}

/* Custom styling for select dropdowns in forms */
.promo-form-grid select,
#embedLanguageSelect,
#supervisorSelectionDropdown {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 40px; /* Add space for arrow */
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 1.5em;
  background-color: #fff;
  cursor: pointer;
}

.promo-toggle-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Makes the promo modal content area flexible */
#promoSettingsModal .modal-content {
  display: flex;
  flex-direction: column;
}

/* Allows the form grid to grow */
.promo-form-grid {
  flex-grow: 1;
  display: flex; /* Change from grid to flex for better textarea growth */
  flex-direction: column;
}

/* Make the description group fill the available vertical space */
.promo-form-grid .form-group.full-width.description-group {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

/* --- New Standalone Promo List Styles --- */
#activePromosContainer {
  width: 100%;
  margin-bottom: 20px;
  border-top: 1px solid var(--color-border-light);
  border-bottom: 1px solid var(--color-border-light);
  padding: 20px 0;
}

.promo-loading-state {
  text-align: center;
  padding: 40px 20px;
  color: #888;
  font-style: italic;
}

.active-promos-heading,
.promo-form-title {
  text-align: left;
  font-size: 1.2em;
  font-weight: 500;
  color: var(--color-text-dark);
  margin: 0 0 15px 0;
}

.promo-form-title {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px dashed var(--color-border-light);
}

#activePromosList {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 240px; /* Approx 3-4 items */
  overflow-y: auto;
  padding: 0 5px; /* Adds a little space for scrollbar */
}

.active-promo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  background-color: #f7f9fc;
  border: 1px solid #e7eaf3;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}

.active-promo-item:hover {
  background-color: #f1f3f9;
}

.promo-name {
  font-weight: 500;
  color: var(--color-text-dark);
  cursor: pointer;
  transition: color 0.2s ease;
  flex-grow: 1;
}

.promo-name:hover {
  color: var(--color-primary);
}

.promo-actions {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-shrink: 0;
}

.promo-actions .remove-promo-btn {
  padding: 0;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background-color: transparent;
  color: var(--color-text-medium);
  border: 1px solid transparent;
  font-size: 1.5em;
  line-height: 1;
  font-weight: 400;
  transition: all 0.2s ease;
}

.promo-actions .remove-promo-btn:hover {
  background-color: var(--color-error-light);
  color: var(--color-error);
  border-color: var(--color-error-light);
  transform: scale(1.1);
}

.empty-list-message {
  text-align: center;
  color: #888;
  padding: 20px 0;
  font-style: italic;
  margin: 0;
}

#createNewPromoBtnContainer {
  justify-content: center;
  margin-top: 0;
}

/* Add this new rule for the promo code textarea */
#standalonePromoModal .embed-code-wrapper textarea {
  width: 100%;
  min-height: 110px; /* Make the field larger */
  padding: 10px; /* Match other input fields */
  border: 1px solid var(--color-border); /* Match other input fields */
  border-radius: 8px; /* Match other input fields */
  font-family: "Courier New", Courier, monospace; /* Use a monospace font for code */
  font-size: 0.9em;
  background-color: #f1f3f5; /* Use a light grey to indicate it's read-only */
  color: #333;
  resize: vertical;
  box-sizing: border-box;
  white-space: pre-wrap;
  word-break: break-all;
}

/* --- Styles for Emoji Picker --- */
.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background-color: #f7f9fc;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-top: 8px;
}

.emoji-option {
  cursor: pointer;
  font-size: 1.5em;
  padding: 2px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.emoji-option:hover {
  background-color: var(--color-border-light);
}

.agent-assignment-info {
  font-size: 0.75em;
  color: #fff;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  margin-left: 4px;
}
.agent-assignment-info i {
  font-size: 0.9em;
}
#historyClientList .agent-assignment-info {
  color: #666;
}

/* --- Agent Management Modal Status Styles --- */
.agent-list-item {
  position: relative;
  padding-left: 35px; /* Make space for the status dot */
}

.agent-status-indicator {
  /* position, left, top, and transform are removed */
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
  flex-shrink: 0; /* Prevents the dot from shrinking */
}

.agent-status-indicator.online {
  background-color: #34a853; /* Green */
}

.agent-status-indicator.offline {
  background-color: #9e9e9e; /* Grey */
}

.agent-timestamps {
  font-size: 0.8em;
  color: #777;
  margin-top: 5px;
  line-height: 1.4;
}

/* --- Agent Status Icon & Name Color in Sidebar List --- */
.agent-assignment-info .agent-status-icon {
  color: var(--color-error); /* Red for offline status */
  transition: color 0.3s ease;
}

.agent-assignment-info span {
  transition: color 0.3s ease;
}

/* When the parent container has the .online class, make only the icon green */
.agent-assignment-info.online .agent-status-icon {
  color: #34a853; /* Green when online */
}

#agentsList .agent-assignment-info:not(.online) span {
  color: var(--color-error); /* Red for offline status */
}

/* When an agent is ready, make their name green */
#myTeamList .agent-assignment-info.ready span {
  color: #34a853; /* Online Green */
}

/* --- End Chat Button Style --- */
.end-chat-wrapper {
  text-align: center;
}
.end-chat-btn {
  background: none;
  border: none;
  color: var(--color-text-medium);
  cursor: pointer;
  font-size: 0.8em;
  text-decoration: underline;
  padding: 0;
  opacity: 0.7;
}
.end-chat-btn:hover {
  opacity: 1;
  color: var(--color-error);
}

/* --- Action Bar above Chat Input --- */
.chat-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 22px;
  padding: 0 5px;
}

.chat-action-bar .typing-indicator-container {
  padding: 0; /* Remove default padding */
}

/* --- START: New Team Tabs & Lists Styles --- */
.team-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.team-tabs {
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid var(--color-border-light);
  margin-bottom: 10px;
}
.team-tab-btn {
  flex: 1;
  padding: 10px 5px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.85em;
  font-weight: 500;
  color: #888;
  border-bottom: 3px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
  position: relative;
}
.team-tab-btn:hover {
  color: var(--color-primary);
}
.team-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.tab-count-badge {
  display: inline-block;
  background-color: var(--color-success);
  color: white;
  font-size: 0.8em;
  padding: 2px 6px;
  border-radius: 8px;
  margin-left: 4px;
  font-weight: bold;
}
.team-tab-content {
  display: none;
  flex-grow: 1;
  min-height: 0;
  overflow-y: auto;
}
.team-tab-content.active {
  display: block;
}
/* Style for items in New Messages tab */
#newInternalMessagesList .client-item.has-new-message {
  background-color: #e6f7ea; /* A soft green */
  border-left: 4px solid var(--color-success);
}
#newInternalMessagesList .client-item.has-new-message:hover {
  background-color: #dcf0e0;
}
/* Style for all internal chat items */
.team-tab-content .client-item {
  background-color: #f8f9fa;
  color: #333;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.team-tab-content .client-item:hover {
  background-color: #f1f3f5;
}
.team-tab-content .agent-assignment-info {
  color: #333;
}
.team-tab-content .agent-assignment-info .agent-status-icon {
  color: #9e9e9e; /* Offline Grey */
}
.team-tab-content .agent-assignment-info.online .agent-status-icon {
  color: #34a853; /* Online Green */
}
.team-hierarchy-header {
  font-size: 0.8em;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  margin: 15px 0 5px 5px;
}
.pin-icon {
  color: #ccc;
  cursor: pointer;
  font-size: 1.1em;
  padding: 5px;
  border-radius: 50%;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.pin-icon:hover {
  color: var(--color-primary);
  background-color: transparent;
}
.pin-icon.pinned {
  color: var(--color-primary);
}
/* --- END: New Team Tabs & Lists Styles --- */

/* ================================================== */
/* --- FINAL CONSOLIDATED HISTORY SCROLLING STYLE --- */
/* ================================================== */

/* When history is expanded, hide other sections to prevent overlap */
.dashboard-sidebar.history-expanded .active-chats-section,
.dashboard-sidebar.history-expanded .team-section {
  display: none !important;
}

/* Ensure the history section expands and has a solid background to cover other content */
.dashboard-sidebar.history-expanded .history-chats-section {
  background-color: #ffffff;
  flex-grow: 1; /* Allows the history section to take all available space */
  min-height: 0; /* Prevents flex item from preventing shrinking below its content size */
  height: auto; /* Let content determine height within flex-grow */
  max-height: none; /* Critical: Remove any max-height here*/
  overflow-y: visible; /* Important: Content flows out, making the PARENT (.dashboard-sidebar) scroll */
  display: flex; /* Establish flex context for internal layout */
  flex-direction: column; /* Stack children vertically */
  margin-top: 0; /* Reset margin from auto */
  padding-bottom: 0; /* Remove potential extra padding at the very bottom */
}

/* Ensure #historyClientList itself does not have its own scrollbar.
   Its content directly contributes to the parent sidebar's scroll. */
.dashboard-sidebar.history-expanded .history-chats-section #historyClientList {
  flex-grow: 1; /* Allow the list to take up as much space as possible */
  overflow-y: visible; /* Content flows out, contributes to parent scroll */
  padding-bottom: 10px; /* Add some padding within the list to separate from buttons */
}

/* Ensure the footer buttons and note within the history section do not shrink
   and are part of the overall sidebar scroll. */
.dashboard-sidebar.history-expanded
  .history-chats-section
  #closeFullHistoryViewBtn,
.dashboard-sidebar.history-expanded
  .history-chats-section
  #downloadAllHistoryInfoBtn,
.dashboard-sidebar.history-expanded .history-chats-section > p {
  flex-shrink: 0; /* Prevents these elements from shrinking */
  margin-top: 8px; /* Add some space above them */
  padding: 0 10px; /* Consistent padding */
  box-sizing: border-box; /* Include padding in element's total width/height */
}

.dashboard-sidebar.history-expanded
  .history-chats-section
  #closeFullHistoryViewBtn {
  background-color: var(--color-primary); /* Primary button background color */
  color: white; /* Text color */
  border: none; /* Remove any default border, as padding would apply to it */
  padding: 12px 20px; /* INCREASED PADDING for better button feel*/
  border-radius: 8px; /* Rounded corners */
  cursor: pointer;
  font-weight: 600; /* Make text bolder for primary action */
  font-size: 1em; /* Slightly larger font size */
  transition: background-color 0.2s ease, transform 0.1s ease;
  text-align: center; /* Ensure text is centered */
}

.dashboard-sidebar.history-expanded
  .history-chats-section
  #downloadAllHistoryInfoBtn {
  background-color: #f0f0f0; /* Light grey background for secondary button */
  color: var(--color-text-dark); /* Dark text color */
  border: 1px solid #d1d5db; /* Light border */
  padding: 12px 20px; /* INCREASED PADDING for better button feel*/
  border-radius: 8px; /* Rounded corners */
  cursor: pointer;
  font-weight: 600; /* Bolder text */
  font-size: 0.7em; /* Slightly larger font size */
  transition: background-color 0.2s ease, border-color 0.2s ease,
    box-shadow 0.2s ease;
  text-align: center;
}

/* Ensure buttons are displayed as blocks and fill width */
.dashboard-sidebar.history-expanded #closeFullHistoryViewBtn {
  /* This button always shows when history is expanded (for both admin/agent) */
  display: block !important; /* Retain !important for the Close button, it's always block */
  width: calc(
    100% - 20px
  ); /* Account for 10px padding on each side of sidebar */
  margin-left: auto; /* Center with auto margins */
  margin-right: auto; /* Center with auto margins */
}

/* Only apply block display to download button if JS determines it should be visible */
.dashboard-sidebar.history-expanded #downloadAllHistoryInfoBtn {
  /* No !important here. JS will set display to 'block' or 'none'. */
  display: block; /* Default to block, but JS will override if not admin */
  width: calc(100% - 20px);
  margin-left: auto;
  margin-right: auto;
}

/* Hover states for the download button */
.dashboard-sidebar.history-expanded
  .history-chats-section
  #downloadAllHistoryInfoBtn:hover {
  background-color: #e2e2e2;
  border-color: #c4c4c4;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Mobile-specific adjustments for the sidebar when history is expanded or searched. */
@media (max-width: 842px) {
  .dashboard-sidebar.mobile-search-active .history-chats-section,
  .dashboard-sidebar.history-expanded .history-chats-section {
    flex-grow: 1;
    min-height: 0;
    max-height: none; /* Allow content to push height, forcing parent sidebar to scroll */
    overflow-y: visible; /* Content flows out */
    display: flex !important;
    flex-direction: column;
  }

  /* Ensure the dashboard-sidebar on mobile itself has a defined scrollable area */
  .dashboard-sidebar {
    /* This max-height needs to be precise for mobile.
       It calculates 100% of the viewport height minus the header (var(--header-height))
       and the search/filter area (approx. 130px). Adjust 130px if needed. */
    max-height: calc(100dvh - var(--header-height) - 130px); /* */
    overflow-y: auto !important; /* Force scroll for the entire sidebar on mobile */
    min-height: 0;
  }
}

.cockpit-modal .modal-content {
  max-width: 90vw;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.cockpit-section-header h3 {
  color: var(--color-primary);
}

.cockpit-content {
  text-align: left;
}

.cockpit-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 30px;
  padding-bottom: 20px;
  flex-shrink: 0;
}

.cockpit-supervisor-info {
  flex-grow: 1;
}

.cockpit-supervisor-info h2 {
  margin: 0 0 15px 0;
  text-align: left;
  font-size: 2em;
}

#cockpitMessageInput {
  width: 100%;
  padding: 10px 15px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  font-size: 1em;
}

.cockpit-controls {
  display: flex;
  gap: 25px;
  flex-shrink: 0;
  background-color: #f7f9fc;
  padding: 15px 20px;
  border-radius: 12px;
  border: 1px solid var(--color-border-light);
}

.control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.control-group > label {
  font-weight: 500;
  font-size: 0.9em;
  color: var(--color-text-dark);
  white-space: nowrap;
}

.existing-agents-section {
  flex-grow: 1; /* Allows this section to fill available space */
  min-height: 0; /* Important for flex children */
  overflow-y: auto; /* Make the list scrollable */
  padding: 10px;
  background-color: #fdfdfd;
  border-radius: 8px;
}

.invite-agent-section {
  padding-top: 15px;
}

.supervisor-message {
  display: none; /* JS will show it for agents if it has content */
  background-color: #fffbe6; /* A soft, noticeable yellow */
  border: 1px solid #ffe58f;
  border-radius: 12px;
  color: #856404; /* Darker text for readability */
  font-size: 0.8em;
  font-weight: 500;
  padding: 15px 20px;
  margin: 0 auto 25px auto; /* Centered, with margin below it */
  max-width: 90%;
  text-align: center;
  line-height: 1.5;
}
/* Find and modify this rule */
.cockpit-message-wrapper {
  display: flex;
  gap: 10px;
  flex-grow: 1; /* Add this line */
}
#cockpitMessageInput {
  flex-grow: 1;
}
#saveCockpitMessageBtn {
  padding: 10px 20px;
  height: 42px; /* Match input height */
  flex-shrink: 0;
}

@media (max-width: 1129px) {
  .footer-copyright-item {
    display: none;
  }
}

/* Makes the cockpit header responsive */
.cockpit-header {
  flex-wrap: wrap;
}

/* Styles for inline form groups like the supervisor name */
.form-group-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}
.form-group-inline label {
  font-weight: 500;
  font-size: 0.9em;
  color: var(--color-text-dark);
  white-space: nowrap;
  flex-shrink: 0;
}
.compact-input-modal {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9em;
  background-color: #ffffff;
  box-sizing: border-box;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.compact-input-modal:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-tertiary-alpha-25);
  outline: none;
}

/* Removes the top-level title from the form since it's now on the button */
#inviteAgentFormContainer .invite-agent-section h3 {
  display: none;
}

/* New layout for the supervisor title and name input */
.supervisor-title-wrapper {
  display: flex;
  align-items: baseline;
  gap: 15px;
}
.supervisor-title-wrapper h2 {
  margin: 0;
  flex-shrink: 0;
}
.supervisor-title-wrapper .form-group-inline {
  margin-bottom: 0;
  flex-grow: 1;
}

/* Styles for the new dual-status indicator in the agent list */
.agent-list-item {
  padding-left: 55px; /* Increase padding to make space for both icons */
}

.agent-ready-indicator {
  font-size: 1.1em;
  color: #9e9e9e; /* Default to grey (Not Ready) */
  transition: color 0.3s ease;
}
.agent-ready-indicator.ready {
  color: #34a853; /* Green for Ready */
}

.create-agent-button-wrapper {
  padding-top: 0px; /* Adds space between the line and the button */
}

.existing-agents-section {
  flex-grow: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  background-color: #fdfdfd;
  border-radius: 8px;
  /* Adds the bottom divider line */
  margin-top: 25px;
}

/* Main wrapper for the top two-column layout */
.cockpit-top-section {
  display: flex;
  align-items: flex-start; /* Aligns columns to the top */
  gap: 20px;
}

/* Left column containing all supervisor inputs */
.cockpit-left-panel {
  display: flex;
  flex-direction: column;
  gap: 15px; /* Space between name row and message row */
  flex-grow: 1; /* Allows it to take up available space */
}

/* Row for "Supervisor" title and name input */
.supervisor-title-wrapper {
  display: flex;
  align-items: baseline; /* Aligns the title text with the input text */
  gap: 15px;
}
.supervisor-title-wrapper h2 {
  margin: 0;
  white-space: nowrap;
}
.supervisor-title-wrapper input {
  flex-grow: 1; /* Makes the name field expand */
}

/* Row for "Message for agents" input and save button */
.cockpit-message-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.cockpit-message-wrapper label {
  white-space: nowrap;
  font-weight: 500;
  font-size: 0.9em;
}
.cockpit-message-wrapper input {
  flex-grow: 1; /* Makes the message field expand */
}
.cockpit-message-wrapper button {
  flex-shrink: 0; /* Prevents save button from shrinking */
}

/* Right column for toggles */
.cockpit-controls {
  flex-shrink: 0; /* Prevents the toggle module from shrinking */
  padding-top: 11px;
}

.cockpit-left-panel .compact-input-modal {
  margin-bottom: 0 !important;
}

/* --- Responsive 6, 7, or 8-Column Grid Layout for the Agent List --- */
.agent-list-row {
  display: grid;
  /* Full view (8 columns): loggedin, ready, name, alias, email, logs, profile, actions */
  grid-template-columns: 50px 50px 1fr 1fr 1.5fr 160px 120px 180px;
  gap: 15px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--color-border-light);
}

/* Medium view (7 columns): Hide Alias */
#existingAgentsList.medium-view .agent-list-row,
#existingAgentsList.medium-view .agent-list-header {
  grid-template-columns: 50px 50px 1fr 1.5fr 160px 120px 180px;
}

#existingAgentsList.medium-view .agent-col-alias {
  display: none;
}

/* Compact view (6 columns): Hide Alias and Email */
#existingAgentsList.compact-view .agent-list-row,
#existingAgentsList.compact-view .agent-list-header {
  grid-template-columns: 50px 50px 1fr 160px 120px 180px;
}

#existingAgentsList.compact-view .agent-col-alias,
#existingAgentsList.compact-view .agent-col-email {
  display: none;
}

/* --- Responsive Layout for the Supervisor List (Mirrors Agent List) --- */
.supervisor-list-row {
  display: grid;
  /* Full view (8 columns): loggedin, name, alias, email, logs, profile, actions */
  grid-template-columns: 50px 1fr 1fr 1.5fr 160px 120px 180px;
  gap: 15px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--color-border-light);
}

/* Medium view (7 columns): Hide Alias */
#existingSupervisorsList.medium-view .supervisor-list-row,
#existingSupervisorsList.medium-view .supervisor-list-header {
  grid-template-columns: 50px 1fr 1.5fr 160px 120px 180px;
}

#existingSupervisorsList.medium-view .supervisor-col-alias {
  display: none;
}

/* Compact view (6 columns): Hide Alias and Email */
#existingSupervisorsList.compact-view .supervisor-list-row,
#existingSupervisorsList.compact-view .supervisor-list-header {
  grid-template-columns: 50px 1fr 160px 120px 180px;
}

#existingSupervisorsList.compact-view .supervisor-col-alias,
#existingSupervisorsList.compact-view .supervisor-col-email {
  display: none;
}

/* Header-specific styling */
.agent-list-header {
  font-size: 0.8em;
  font-weight: 600;
  color: #777;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border-light);
}

/* Styling for individual data rows */
#existingAgentsList .agent-list-row,
#existingSupervisorsList .supervisor-list-row {
  background-color: #f7f9fc;
  border-radius: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid transparent; /* Overrides default */
}
#existingAgentsList .agent-list-row:hover,
#existingSupervisorsList .supervisor-list-row:hover {
  background-color: #f1f3f9;
}

/* Center-align the status columns */
.agent-col-status {
  text-align: center;
  display: flex;
  justify-content: center;
}

/* Styling for the Logs column */
.agent-col-logs .agent-timestamps {
  font-size: 0.8em;
  line-height: 1.4;
  color: #666;
}

/* Styling for the Actions column (Edit/Delete buttons) */
.agent-col-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.agent-col-actions .edit-agent-btn,
.agent-col-actions .remove-agent-btn,
.agent-col-actions .edit-supervisor-btn,
.agent-col-actions .remove-supervisor-btn {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 1.1em;
  padding: 5px;
  border-radius: 4px;
}

.agent-col-actions .edit-agent-btn:hover,
.agent-col-actions .edit-supervisor-btn:hover {
  color: var(--color-primary);
  background-color: #eadaff;
}
.agent-col-actions .remove-agent-btn:hover,
.agent-col-actions .remove-supervisor-btn:hover {
  color: var(--color-error);
  background-color: var(--color-error-light);
}

.agent-col-email .agent-email,
.supervisor-col-email .agent-email {
  font-size: 0.9em;
  color: #555;
}

/* Styling for the input fields during inline edit */
.inline-edit-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-primary);
  border-radius: 4px;
  font-size: 0.9em;
  box-sizing: border-box;
  margin-bottom: 0 !important; /* This will force the override */
}
.inline-edit-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-tertiary-alpha-30);
}

/* Styling for the Save and Cancel buttons during inline edit */
.agent-col-actions .save-agent-btn {
  color: #34a853; /* Green */
}
.agent-col-actions .save-agent-btn:hover {
  background-color: #e6f4ea;
}

.agent-col-actions .cancel-edit-btn {
  font-size: 1.4em;
  color: var(--color-error);
}
.agent-col-actions .cancel-edit-btn:hover {
  background-color: var(--color-error-light);
}

/* New rules for responsive cockpit actions */
.agent-col-actions {
  align-items: center; /* Vertically center the items */
}

/* Keep agent action buttons horizontal */
.primary-agent-actions {
  display: flex;
  flex-direction: row;
  gap: 10px;
}

.agent-col-actions .reset-password-btn {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 1.1em;
  padding: 5px;
  border-radius: 4px;
}
.agent-col-actions .reset-password-btn:hover {
  color: #f59e0b; /* An amber color */
  background-color: #fffbeb;
}

.agent-col-actions .kick-agent-btn,
.agent-col-actions .kick-supervisor-btn {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 1.1em;
  padding: 5px;
  border-radius: 4px;
}
.agent-col-actions .kick-agent-btn:hover,
.agent-col-actions .kick-supervisor-btn:hover {
  color: #ef4444; /* A red color */
  background-color: #fee2e2;
}

.agent-col-actions .assign-supervisor-btn {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 1.1em;
  padding: 5px;
  border-radius: 4px;
}
.agent-col-actions .assign-supervisor-btn:hover {
  color: #6366f1; /* An indigo color */
  background-color: #e0e7ff;
}

/* Styles for the assignment modal */
.assignment-rules {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0;
}
.radio-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
#supervisorSelectGroup label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}
#supervisorSelectGroup select {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  font-size: 0.9em;
  font-family: inherit;
  background-color: #fff;
  cursor: pointer;
}

.form-group-column {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 8px;
  margin-top: 20px;
}
.form-group-column input {
  width: 100%;
  box-sizing: border-box;
}

.chat-messages .chat-message a {
  color: var(--color-primary) !important;
  text-decoration: underline;
  font-weight: 500;
}

.chat-messages .chat-message a:hover {
  color: var(--primary-hover);
}

#kickAgentConfirmModal {
  z-index: 1001;
}

.agent-col-logs .fa-info-circle {
  color: #aaa;
  font-size: 0.9em;
  margin-left: 5px;
  cursor: help;
}

/* Make sidebar lists scrollable */
.queue-section .client-list,
.active-chats-section .client-list {
  max-height: 250px; /* Adjust this value as needed */
  overflow-y: auto;
  padding-right: 5px; /* Add some space for the scrollbar */
}

/* Prevent the queue section from shrinking when active chats list grows */
.queue-section {
  flex-shrink: 0;
}

/* Remove margin below the last item in the queue list */
#queueClientList li:last-child {
  margin-bottom: 0;
}

/* When in agent view, change cursor for queue items to show they aren't clickable */
.agent-view .queue-section .client-item {
  cursor: default;
}

/* Ensure the "Take" button inside is still clickable */
.agent-view .queue-section .client-item .take-conversation-btn {
  cursor: pointer;
}

/*
=================================
STYLES FOR DISABLED BUTTON TOOLTIPS
=================================
*/
.tooltip-wrapper {
  position: relative;
  display: inline-block;
  cursor: not-allowed;
}

.tooltip-wrapper .take-conversation-btn[disabled] {
  pointer-events: none;
}

.tooltip-wrapper .tooltip-text {
  visibility: hidden;
  width: 220px;
  background-color: #555;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 10px;
  position: absolute;
  z-index: 10;
  bottom: 125%;
  right: 0;
  left: auto;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.85em;
  font-weight: normal;
  line-height: 1.4;
}

.tooltip-wrapper .tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 15px;
  left: auto;
  border-width: 5px;
  border-style: solid;
  border-color: #555 transparent transparent transparent;
}

.tooltip-wrapper:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Allow parent containers to show the tooltip without clipping it */
.queue-section .client-list:has(.tooltip-wrapper:hover),
.dashboard-sidebar:has(.tooltip-wrapper:hover) {
  overflow: visible;
}

/*
=================================
STYLES FOR GROUPED CHAT BUTTON
=================================
*/
.grouped-queue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f7f9fc; /* A more neutral background to match the green */
  border-left: 4px solid var(--color-secondary); /* This uses the same green as the 'NEW' badge */
  margin-bottom: 0;
}

.grouped-queue-item .grouped-info {
  font-weight: 500;
  color: #333;
}

.grouped-queue-item .grouped-title {
  font-size: 1rem;
  color: white;
}

.grouped-queue-item .waiting-time {
  font-size: 0.8rem;
  color: #666;
  margin-top: 4px;
}

/* Ensure the take button has some margin */
.grouped-queue-item .take-conversation-btn {
  margin-left: 10px;
  background-color: var(--primary-hover);
}

/* Hide Queue title on desktop views */
@media (min-width: 843px) {
  .queue-section .sidebar-subheading {
    display: none;
  }
}

#kickAgentsConfirmModal {
  z-index: 1001;
}

/* --- Agent Helper Menu Bar (Header) --- */
.helper-menu-bar {
  display: none; /* Hidden by default */
  flex-grow: 1;
  align-items: center;
  justify-content: flex-start; /* Align items to the left */
  gap: 5px;
  overflow: hidden; /* Set back to hidden for overflow logic */
  padding: 0 15px;
  min-width: 0;
  margin-right: 15px; /* Add a guaranteed margin */
}
.agent-view .helper-menu-bar {
  display: flex; /* Only visible for agents */
  position: relative; /* Establishes a stacking context */
  z-index: 0; /* Ensures correct layering for overflow clipping */
  transform: translateZ(
    0
  ); /* Forces hardware acceleration to fix Safari rendering glitches */
}
.helper-menu-bar a,
.helper-menu-bar .helper-menu-button {
  color: white;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.9em;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}
.helper-menu-bar a:hover,
.helper-menu-bar .helper-menu-button:hover {
  background-color: rgba(255, 255, 255, 0.15);
}
.helper-menu-button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  position: relative;
}
.helper-menu-dropdown {
  display: none;
  position: absolute;
  top: 110%;
  right: 0;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 8px 0;
  min-width: 200px;
  z-index: 110;
  border: 1px solid #eee;
}
.helper-menu-dropdown.show {
  display: block;
}
.helper-menu-dropdown a,
.helper-menu-dropdown .submenu-title {
  color: var(--color-text-dark);
  display: block;
  padding: 8px 15px;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}
.helper-menu-dropdown a:hover {
  background-color: #f5f5f5;
}
.submenu-title {
  font-weight: bold;
  color: #999;
  font-size: 0.8em;
  padding-top: 10px;
  padding-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.helper-menu-dropdown .submenu-items a {
  padding-left: 25px;
}

/* --- Helper Menu Editor Modal --- */
.menu-editor-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 50vh;
  overflow-y: auto;
}
#menu-editor-list {
  min-height: 200px;
}

/* Default style for items (TOP-LEVEL): transparent and borderless */
.menu-editor-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 0;
  background-color: transparent;
  border: none;
  margin-bottom: 15px;
}

/* Specific style for NESTED items: card with light blue background */
.submenu-list .menu-editor-item {
  padding: 10px;
  background-color: var(--color-tertiary-xlight); /* Light blue background */
  border: 1px solid var(--color-tertiary-light); /* Light blue border */
  border-radius: 6px;
  margin-bottom: 8px;
}

#helperMenuModal .item-content input {
  margin-bottom: 0;
}
.menu-editor-item .drag-handle {
  cursor: grab;
  color: #aaa;
}
.menu-editor-item .item-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-editor-item .item-content input {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: white; /* Ensure input backgrounds are white */
}
.menu-editor-item .item-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  font-size: 1.1em;
  color: #999;
}
.menu-editor-item .item-actions button:hover {
  color: var(--color-error);
}
.menu-editor-item.is-submenu > .item-content .item-title-input {
  font-weight: bold;
}
.menu-editor-item.is-submenu > .item-content .item-url-input {
  display: none;
}

/* Style for the drop zone of an empty submenu */
.menu-editor-item .submenu-list:empty {
  min-height: 40px;
  background-color: var(
    --color-tertiary-xlight
  ); /* Match nested item background */
  border: 1px solid var(--color-tertiary-light); /* Match nested item border */
  border-radius: 6px;
  margin-top: 8px;
  margin-left: 30px;
}

/* Style for the list holding sub-items */
.menu-editor-item .submenu-list {
  list-style: none;
  width: 100%;
  margin-top: 8px;
  padding-left: 30px;
  border-left: none;
}
.sortable-ghost {
  opacity: 0.4;
  background: #eadaff;
}
.sortable-drag {
  opacity: 0.9 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transform: scale(1.02);
}

/* --- Styles for Management Helper Menu Dropdown --- */
#managementHelperMenuBtn {
  padding: 8px 12px; /* Gives the icon a bit more space */
}

#managementHelperMenuDropdown {
  display: none; /* Hidden by default */
  position: absolute;
  top: 110%; /* Position it just below the button */
  right: 0;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 8px 0;
  min-width: 220px; /* Set a good width for the dropdown */
  z-index: 1010; /* Ensure it appears above other elements */
  border: 1px solid #eee;
  text-align: left;
}

#managementHelperMenuDropdown.show {
  display: block; /* Show the dropdown */
}

#managementHelperMenuDropdown a,
#managementHelperMenuDropdown .submenu-title {
  color: var(--color-text-dark);
  display: block;
  padding: 10px 18px;
  text-decoration: none;
  white-space: nowrap;
}

#managementHelperMenuDropdown a:hover {
  background-color: #f5f5f5;
}

#managementHelperMenuDropdown .submenu-title {
  font-weight: bold;
  color: #999;
  font-size: 0.8em;
  padding-top: 10px;
  padding-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#managementHelperMenuDropdown .submenu-items a {
  padding-left: 30px; /* Indent submenu items */
}

/* --- Toast Notification Styles --- */
#toastContainer {
  position: fixed;
  top: 90px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.toast-notification {
  background-color: #fff;
  color: #333;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-left: 5px solid;
  min-width: 250px;
  max-width: 350px;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
  font-size: 14px;
}
.toast-notification.show {
  opacity: 1;
  transform: translateX(0);
}
.toast-notification.success {
  border-left-color: #4caf50; /* Green */
}
.toast-notification.error {
  border-left-color: #d32f2f; /* Red */
}
.toast-notification.info {
  border-left-color: #8ab4f8; /* Blue */
}

/* --- START: Final Unified Helper Menu Styles --- */

/* This is the main style for ALL dropdown menu boxes (agent and supervisor) */
.helper-menu-dropdown {
  display: none;
  position: absolute;
  top: 110%;
  right: 0;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 8px 0;
  min-width: 220px;
  z-index: 1010;
  border: 1px solid #eee;
  text-align: left;
}

.helper-menu-dropdown.show {
  display: block;
}

/* This styles all ITEMS (links and buttons) inside ANY dropdown menu */
.helper-menu-dropdown a,
.helper-menu-dropdown .helper-menu-button {
  display: block;
  width: 100%;
  padding: 10px 18px;
  background: none;
  border: none;
  color: var(--color-text-dark);
  text-align: left;
  font-family: inherit;
  font-size: 1em;
  cursor: pointer;
  position: relative;
  text-decoration: none;
  white-space: nowrap;
}

.helper-menu-dropdown a:hover,
.helper-menu-dropdown .helper-menu-button:hover {
  background-color: #f5f5f5;
}

/* Add padding to submenu buttons in the supervisor menu to make space for the left-side arrow */
#managementHelperMenuDropdown > .helper-menu-button:has(.helper-menu-dropdown) {
  padding-left: 35px;
}

/* Add a left-arrow icon ONLY to submenu buttons inside the supervisor's main dropdown */
#managementHelperMenuDropdown
  > .helper-menu-button:has(.helper-menu-dropdown)::before {
  content: "\f0d9"; /* Font Awesome left chevron */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  left: 18px; /* Position on the left */
  top: 50%;
  transform: translateY(-50%);
  transition: color 0.2s ease; /* Animate the color change */
}

/* Position nested submenus to the side */
.helper-menu-dropdown .submenu {
  top: -9px; /* Align with the top of the parent item */
  left: 100%;
  margin-left: 1px;
  border: 1px solid #e0e0e0;
}

/* This prevents submenus in the supervisor dropdown from going off-screen */
#managementHelperMenuDropdown .helper-menu-button:hover > .submenu,
#managementHelperMenuDropdown .helper-menu-button:focus-within > .submenu {
  display: block;
  right: 100%;
  left: auto;
  margin-right: 1px;
}

/* Change arrow color to blue on hover instead of rotating */
#managementHelperMenuDropdown > .helper-menu-button:hover::before {
  color: var(--color-tertiary); /* Set hover color to the theme's blue */
}
/* --- END: Final Unified Helper Menu Styles --- */
/* --- START: Agent "More Options" Dropdown Arrow Styles --- */

/* Add a right-arrow icon to submenu buttons inside the agent's 'More' dropdown */
.more-menu-btn
  > .helper-menu-dropdown
  .helper-menu-button:has(.helper-menu-dropdown)::after {
  content: "\f0da"; /* Font Awesome right chevron */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  transition: color 0.2s ease;
}

/* Change the arrow color to blue on hover */
.more-menu-btn
  > .helper-menu-dropdown
  .helper-menu-button:has(.helper-menu-dropdown):hover::after {
  color: var(--color-tertiary);
}

/* --- END: Agent "More Options" Dropdown Arrow Styles --- */

/* --- START: Internal Chat UI Adjustments --- */

/* When an internal team chat is active, hide specific client info fields. */
.chat-view-slot.internal-chat-active .info-group:has([id^="clientFirstName-"]),
.chat-view-slot.internal-chat-active .info-group:has([id^="clientLastName-"]),
.chat-view-slot.internal-chat-active .info-group:has([id^="clientPhone-"]),
.chat-view-slot.internal-chat-active .info-group:has([id^="clientEmail-"]) {
  display: none;
}

/* Also hide the 'Hashtag' note field from the header. */
.chat-view-slot.internal-chat-active .header-note-wrapper {
  display: none;
}

/* Finally, hide the Save and Download buttons, as they don't apply. */
.chat-view-slot.internal-chat-active .saveClientInfoBtn,
.chat-view-slot.internal-chat-active .downloadClientInfoBtn {
  display: none;
}

/* --- END: Internal Chat UI Adjustments --- */

/* --- START: Cockpit Close Button Padding Fix --- */

.cockpit-modal .modal-content {
  padding-top: 50px;
}

/* --- END: Cockpit Close Button Padding Fix --- */

/* ================================================== */
/* --- DEFINITIVE CLICK FIX (Overlay Neutralizer) --- */
/* ================================================== */
/* This rule neutralizes the login screen when it's hidden.
   It prevents the invisible wrapper from blocking clicks on the dashboard. */
#loginScreen[style*="display: none"] {
  z-index: -1 !important;
  pointer-events: none !important;
}

/* --- Loading Spinner Style --- */
.loading-spinner {
  border: 4px solid #f3f3f3; /* Light grey */
  border-top: 4px solid var(--color-primary); /* Purple */
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 40px auto; /* Centers the spinner in the chat view */
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
/* --- Flash Animation for New Users (This existing animation works fine) --- */
@keyframes flash-green-once {
  0%,
  100% {
    background-color: #d9b3ff;
  }
  50% {
    background-color: var(--color-secondary);
  }
}

/* --- New Profile Modal and Column Styles --- */
.agent-col-profile {
  text-align: center;
}

.profile-btn {
  background-color: #f0f0f0;
  border: 1px solid #ddd;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
  font-weight: 500;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.profile-btn:hover {
  background-color: #e2e2e2;
  border-color: #ccc;
}

.profile-form {
  margin-top: 20px;
}

/* This rule adds specificity to ensure all input fields inside the profile form look identical,
   overriding any conflicting styles from other stylesheets. */
#profileForm input.compact-input-modal {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9em;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 25px;
}

#customFieldsContainer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.custom-field-row {
  display: grid;
  /* Match the profile-grid layout but add a column for the remove button */
  grid-template-columns: 1fr 1fr auto;
  gap: 15px;
  align-items: center;
  margin-bottom: 10px; /* Add space between dynamically added rows */
}

.custom-field-row input.compact-input-modal {
  margin-bottom: 0; /* The row's margin-bottom will handle spacing */
}

/* Ensure readonly fields in the profile modal match other inputs */
#profileModal input[readonly] {
  background-color: #ffffff !important;
  color: var(--color-text-dark) !important;
  cursor: default !important; /* Use default cursor to indicate it's not for text input */
  border-color: var(--color-border) !important;
}

.remove-custom-field-btn {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 1.4em;
}

.remove-custom-field-btn:hover {
  color: var(--color-error);
}

#queueClientList .grouped-queue-item.new-user-flash {
  animation: flash-green-once 1.5s ease-in-out;
}

/* --- NEW ANIMATION METHOD FOR TIMED FLASHES --- */

/* 1. Define the keyframe animations for orange and red flashes */
@keyframes flash-orange-once {
  0%,
  100% {
    background-color: #d9b3ff;
  }
  50% {
    background-color: var(--color-quaternary);
  } /* Orange */
}

@keyframes flash-red-once {
  0%,
  100% {
    background-color: #d9b3ff;
  }
  50% {
    background-color: var(--color-error);
  } /* Red */
}

/* 2. Define classes to apply these animations directly to the queue item */
#queueClientList .grouped-queue-item.flash-active-warning {
  animation: flash-orange-once 1.5s ease-in-out;
}

#queueClientList .grouped-queue-item.flash-active-critical {
  animation: flash-red-once 1.5s ease-in-out;
}

/* --- NEWLY ADDED for Visual-Only (Standard Plan) Flashes --- */
#queueClientList .grouped-queue-item.flash-warning {
  animation: flash-orange-once 1.5s ease-in-out;
}
#queueClientList .grouped-queue-item.flash-critical {
  animation: flash-red-once 1.5s ease-in-out;
}

/* --- NEWLY ADDED for Persistent Border Indication --- */
.grouped-queue-item.border-warning {
  border-left-color: var(--color-quaternary) !important; /* Orange */
}
.grouped-queue-item.border-critical {
  border-left-color: var(--color-error) !important; /* Red */
}

/* --- START: Chat Transfer Styles --- */
.end-chat-wrapper {
  display: flex;
  gap: 15px;
  align-items: center;
}
.transfer-chat-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 0.8em;
  text-decoration: underline;
  padding: 0;
  font-weight: 500;
}
.transfer-chat-btn:hover {
  color: var(--primary-hover);
}
.transfer-targets-list {
  max-height: 50vh;
  overflow-y: auto;
  margin-top: 20px;
  text-align: left;
}
.transfer-targets-list .role-header {
  font-weight: bold;
  color: #888;
  font-size: 0.9em;
  text-transform: uppercase;
  margin: 15px 0 5px 0;
  border-bottom: 1px solid #eee;
  padding-bottom: 5px;
}
.transfer-target-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.transfer-target-item:hover {
  background-color: #f5f5f5;
}
.transfer-target-item.send-to-queue-item {
  background-color: #f0f0f0;
  font-weight: bold;
}
.transfer-target-item.send-to-queue-item i {
  color: var(--color-primary);
}
.transfer-target-item.send-to-queue-item:hover {
  background-color: #e0e0e0;
}
.transfer-target-item .agent-status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #34a853; /* online green */
}
.transfer-target-item .target-name {
  font-weight: 500;
}
/* --- END: Chat Transfer Styles --- */
