/* 
   HR Management System - Complete CSS
   Clean, organized, and maintainable styles
   Contains styles for Login, Chat pages, and Enhanced Search functionality
   Includes responsive designs for all screen sizes
*/

/* ======================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   ====================================== */
:root {
  /* Main brand colors */
  --primary: #1ec1aa;
  --primary-dark: #19a999;
  --primary-light: #d0f0eb;
  --primary-bg: #e8f5f0;
  --secondary: #4fb0c9;
  --secondary-dark: #3a98b0;
  --secondary-light: #d3ebf2;
  --accent: #e2f4f5;
  --background: #e8f5f0;

  /* Interface colors */
  --success: #28a745;
  --info: #17a2b8;
  --warning: #ffc107;
  --danger: #dc3545;
  --dark: #343a40;
  --light: #f8f9fa;
  --white: #ffffff;

  /* Status colors */
  --status-online: var(--success);
  --status-offline: #adb5bd;
  --status-away: var(--warning);
  --status-busy: var(--danger);
  --status-dnd: #e74c3c;

  /* Message status */
  --message-sent: #e2e2e2;
  --message-delivered: #c8e6c9;
  --message-read: #bbdefb;

  /* Text colors */
  --text: #333333;
  --text-dark: #343a40;
  --text-muted: #6c757d;
  --text-light: #f8f9fa;

  /* Grayscale palette */
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #adb5bd;
  --gray-600: #6c757d;
  --gray-700: #495057;
  --gray-800: #343a40;
  --gray-900: #212529;

  /* Border radius – system rule */
  --border-radius-sm: 8px;   /* small elements: inputs, buttons, badges */
  --border-radius: 8px;
  --border-radius-card: 14px; /* cards, containers */
  --border-radius-modal: 16px; /* modals */
  --border-radius-lg: 14px;   /* alias for card */
  --border-radius-xl: 16px;   /* alias for modal */

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-primary: 0 4px 10px rgba(30, 193, 170, 0.25);

  /* Avatar color variations */
  --avatar-bg-1: #e8f5f0; --avatar-text-1: #0fa48b;
  --avatar-bg-2: #f1ebff; --avatar-text-2: #7e57c2;
  --avatar-bg-3: #fff0ee; --avatar-text-3: #e53935;
  --avatar-bg-4: #e8f0ff; --avatar-text-4: #4285f4;
  --avatar-bg-5: #fff8e6; --avatar-text-5: #ff8f00;
  --avatar-bg-6: #e6f9ff; --avatar-text-6: #00acc1;
  --avatar-bg-7: #f9e6ff; --avatar-text-7: #d500f9;
  --avatar-bg-8: #e6ffe6; --avatar-text-8: #43a047;

  /* Search theme colors */
  --search-bg: var(--white);
  --search-border: var(--gray-200);
  --search-text: var(--text-dark);
  --search-highlight-bg: #fff3cd;
  --search-highlight-text: #856404;
}

/* ======================================
   BASE STYLES
   ====================================== */
* {
  box-sizing: border-box;
}

body {
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", sans-serif;
  background-color: var(--background);
  color: var(--text-dark);
  line-height: 1.6;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  position: relative;
}

body.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
  overflow-x: hidden;
  overflow-y: hidden;
  padding: 20px;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background-color: #e6f5f2;
  background-image: linear-gradient(
    160deg,
    #e8f5f0 0%,
    #e2f4f5 40%,
    rgba(30, 193, 170, 0.06) 100%
  );
  background-attachment: fixed;
}

/* ======================================
   LOGIN PAGE STYLES
   ====================================== */

/* Login container – soft-tinted card (not stark white), blends with page */
.login-container {
  background: linear-gradient(180deg, #fafcfb 0%, #f5faf9 100%);
  border-radius: 18px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(30, 193, 170, 0.08);
  overflow-x: hidden;
  overflow-y: auto;
  width: 1000px;
  max-width: 95%;
  max-width: min(1000px, calc(100vw - 30px));
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

/* Single-column login (no trust section): compact card, form centered */
.login-container:not(:has(.login-image)) {
  max-width: min(420px, calc(100vw - 30px));
  justify-content: center;
  border-top: 4px solid var(--primary);
}

.login-container:not(:has(.login-image)) .login-form {
  max-width: 100%;
  border-radius: 18px;
  border-left: none;
  flex: 0 1 auto;
  min-height: 0;
  max-height: calc(100dvh - 30px);
  margin: 0 auto;
  position: relative;
  min-width: 0;
  box-sizing: border-box;
  box-shadow: none;
  background: transparent;
}

/* Login form column */
.login-form {
  flex: 1 1 auto;
  max-width: 420px;
  min-width: 0;
  padding: 40px 36px 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  position: relative;
  border-left: 4px solid var(--primary);
  border-top-right-radius: var(--border-radius-card);
  border-bottom-right-radius: var(--border-radius-card);
  box-shadow: 4px 0 20px -4px rgba(0, 0, 0, 0.06);
  z-index: 1;
}

/* Inner content wrapper – consistent width and spacing */
.login-form-inner {
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
}

.login-container:not(:has(.login-image)) .login-form-inner {
  max-width: 100%;
}

.login-image {
  flex: 1;
  min-width: 0;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0.92) 0%,
    rgba(226, 244, 245, 0.95) 25%,
    var(--accent) 100%
  );
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  min-height: 0;
  margin-left: -8px;
}

/* Login header: logo + tagline */
.login-header {
  margin-bottom: 28px;
}

.logo {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin-right: 12px;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  box-shadow: 0 2px 8px rgba(30, 193, 170, 0.35);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Typography */
h1 {
  color: var(--text);
  font-weight: 700;
  margin-bottom: 10px;
  font-size: 28px;
}

/* Login typography: welcome as hero */
h2.login-welcome {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0;
  margin-bottom: 6px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

/* Tagline under logo */
.login-brand-tagline {
  font-size: 0.75rem;
  color: var(--gray-500);
  letter-spacing: 0.03em;
  margin: 0;
  font-weight: 400;
  line-height: 1.4;
  padding-left: 56px; /* align with text after logo icon */
}

/* Welcome and subtitle */
.login-page .subtitle,
.login-subtitle {
  color: var(--gray-600);
  font-size: 0.9375rem;
  margin-top: 0;
  margin-bottom: 28px;
  line-height: 1.5;
}

.login-form-inner .login-subtitle {
  margin-bottom: 24px;
}

/* Login error alert – soft, on-brand */
.login-alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 0.875rem;
  line-height: 1.45;
}

.login-alert-danger {
  background-color: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Login form: labels above fields, consistent spacing */
.login-form-group {
  display: block;
  margin-bottom: 20px;
}

.login-form-group:last-of-type {
  margin-bottom: 8px;
}

.login-label {
  display: block;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 8px;
  font-size: 0.875rem;
  line-height: 1.4;
}

/* Password field header: flex container – label left, "Forgot password?" right-aligned, vertically centered */
.login-label-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  min-height: 2rem;
  width: 100%;
}

.login-label-row .login-label {
  margin: 0;
  flex: 0 0 auto;
  line-height: 1.5;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.login-label-row .forgot-password {
  flex: 0 0 auto;
  margin-left: auto;
  line-height: 1.5;
  padding: var(--spacing-xs) 0;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Login inputs: clean borders, clear focus */
.login-input.form-control {
  border-radius: 10px;
  padding: 12px 14px;
  height: 44px;
  min-height: 44px;
  border: 1px solid var(--gray-300);
  background-color: var(--gray-100);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-size: 0.9375rem;
  overflow-x: auto !important;
  overflow-y: hidden;
  text-overflow: clip !important;
  white-space: nowrap;
}

.login-input.form-control:focus {
  border-color: var(--primary);
  background-color: var(--white);
  box-shadow: 0 0 0 3px rgba(30, 193, 170, 0.2);
  outline: none;
}

.login-input.form-control::placeholder {
  color: var(--gray-500);
}

/* Form elements (legacy floating – keep for other pages) */
.form-floating {
  margin-bottom: 20px;
}

.form-control {
  border-radius: var(--border-radius);
  padding: 12px 15px;
  height: 55px;
  min-height: 44px;
  border: 1px solid var(--gray-300);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  max-width: 100%;
  box-sizing: border-box;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.25rem rgba(30, 193, 170, 0.1);
  outline: none;
}

.form-floating > label {
  padding: 12px 15px;
}

/* Remember me row */
.login-remember-row {
  margin-top: 20px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
}

.login-form-check.form-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.25rem;
  margin-bottom: 0;
  vertical-align: middle;
}

/* Checkbox vertically centered with label text */
.login-form-check .form-check-input {
  margin: 0;
  flex-shrink: 0;
  align-self: center;
  vertical-align: middle;
  width: 1.125em;
  height: 1.125em;
  margin-top: 0;
}

.login-form-check .form-check-label {
  line-height: 1.25rem;
  cursor: pointer;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  align-self: center;
  display: inline-flex;
  align-items: center;
}

/* Forgot password: aligned under password field, not at right edge */
.login-remember-row .forgot-password {
  flex-shrink: 0;
  margin-left: 0;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.5;
  padding: var(--spacing-xs) 0;
}

/* Sign In button */
.login-btn {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  border: none;
  border-radius: 10px;
  padding: 14px 24px;
  min-height: 48px;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.02em;
  margin-top: 0;
  margin-left: 0;
  margin-right: 0;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  color: var(--white);
  width: 100%;
  display: block;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(30, 193, 170, 0.35);
}

.login-btn:hover {
  background: linear-gradient(180deg, var(--primary-dark) 0%, #158f82 100%);
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 193, 170, 0.4);
}

.login-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(30, 193, 170, 0.3);
}

.forgot-password {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  transition: color 0.2s ease;
}

.forgot-password:hover {
  color: var(--primary-dark);
}

/* Forgot password under password field */
.login-form-group .forgot-password {
  display: inline-block;
  margin-top: var(--spacing-sm);
  font-size: 0.875rem;
}

/* HR cards */
.hr-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 90%;
}

.hr-card {
  background: var(--white);
  padding: 20px;
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.hr-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 15px;
}

.card-indicator {
  width: 10px;
  height: 10px;
  background-color: var(--primary);
  border-radius: 50%;
  display: inline-block;
  margin-right: 10px;
}

/* Login right column: informational cards (non-interactive) */
.hr-features-intro {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin-top: 44px;
  margin-bottom: 18px;
  text-align: center;
  font-weight: 500;
}

/* Right panel: optimal reading width (~60–70 characters) for description text */
.login-image .hr-title,
.login-image .hr-subtitle,
.login-image .hr-features-intro,
.login-image .hr-cards-info {
  max-width: 65ch;
}

/* Right panel: de-emphasized so login form / Welcome Back remains hero */
.login-image .hr-title {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--gray-700);
  line-height: 1.3;
}

.login-image .hr-subtitle {
  font-size: 0.75rem;
  margin-bottom: 16px;
  color: var(--gray-600);
}

.login-image .hr-features-intro {
  margin-top: 20px;
  margin-bottom: 10px;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
}

.login-image .hr-cards-info {
  margin-top: 0;
  margin-bottom: 0;
  gap: 6px;
}

.hr-cards-info {
  margin-top: 0;
  margin-bottom: 0;
  gap: 10px;
}

/* Secondary text in feature cards: darker for accessibility (WCAG contrast) */
.hr-card-info .card-content p,
.login-page .hr-card-info .card-content p {
  color: var(--gray-700);
  font-size: 0.8125rem;
  margin-bottom: 0;
  line-height: 1.35;
}

.hr-card-info {
  cursor: default;
  pointer-events: none;
}

.hr-card-info:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
  background: var(--white);
}

.hr-card-info {
  padding: 10px 12px;
}

/* Login right panel: de-emphasized feature cards – subtle so login stays hero */
.login-image .hr-card-info {
  padding: 6px 8px;
  background-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.login-image .hr-card-info h3 {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--gray-700);
}

.login-image .hr-card-info .hr-card-icon {
  width: 20px;
  height: 20px;
  font-size: 0.6875rem;
  margin-bottom: 4px;
  opacity: 0.85;
}

.login-image .hr-card-info .card-content p {
  font-size: 0.625rem;
  line-height: 1.25;
  color: var(--gray-600);
}

/* Right panel: subtle brand support – checklist only, no cards (enterprise UX) */
.login-trust-intro {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  margin: 0 0 12px 0;
  font-weight: 500;
}

.login-trust-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 65ch;
}

.login-trust-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--gray-600);
  font-weight: 400;
  margin-bottom: 6px;
  line-height: 1.4;
}

.login-trust-list li:last-child {
  margin-bottom: 0;
}

.login-trust-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--primary);
  font-size: 0.625rem;
}

.hr-card-info h3 {
  color: var(--text);
  margin-bottom: 8px;
  font-size: 16px;
}

.hr-card-info .hr-card-icon {
  width: 36px;
  height: 36px;
  font-size: 1rem;
  margin-bottom: 8px;
}

.hr-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background-color: var(--primary-light);
  color: var(--primary);
  font-size: 1.125rem;
  margin-bottom: 12px;
}

.hr-card-icon-secondary {
  background-color: var(--secondary-light);
  color: var(--secondary);
}


/* Reduced so Welcome Back (h2.login-welcome) is the one hero per screen */
.hr-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  text-align: center;
}

.hr-subtitle {
  font-size: 16px;
  color: var(--gray-600);
  margin-bottom: 30px;
  text-align: center;
}

/* ======================================
   LAYOUT COMPONENTS
   ====================================== */

/* App container */
.app-container {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* Sidebar - narrower to give more room to main content (e.g. Birthdays table) */
.sidebar {
  width: 240px;
  background-color: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  z-index: 1000;
}

.sidebar-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--text-dark);
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--primary);
  color: var(--white);
  border-radius: var(--border-radius-sm);
  margin-right: 0.75rem;
  font-weight: 600;
}

.sidebar-brand-text {
  font-weight: 600;
  font-size: 1.1rem;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--gray-600);
  margin-left: auto;
  font-size: 1.25rem;
  cursor: pointer;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md) 0;
}

.nav-item {
  padding: var(--spacing-sm) var(--spacing-md);
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--gray-700);
  text-decoration: none;
  border-radius: var(--border-radius);
  transition: all 0.3s ease;
}

.nav-link:hover {
  background-color: var(--gray-100);
  color: var(--primary);
}

.nav-link.active {
  background-color: var(--primary-bg);
  color: var(--primary);
  font-weight: 500;
}

.nav-link i {
  margin-right: 0.75rem;
  font-size: 1.1rem;
  width: 1.25rem;
  text-align: center;
}

.nav-link .badge {
  margin-left: auto;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 10px;
}

/* Main content area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Topbar */
.topbar {
  background-color: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--gray-600);
  font-size: 1.25rem;
  cursor: pointer;
}

.topbar-title {
  font-weight: 600;
  font-size: 1.1rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* User dropdown */
.user-dropdown {
  position: relative;
}

@media (max-width: 576px) {
  .user-info {
    display: none;
  }
  
  .user-dropdown-toggle {
    min-width: 44px;
    min-height: 44px;
  }
}

.user-dropdown-toggle {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  margin-right: 0.5rem;
  position: relative;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.user-info {
  display: block;
}

.user-name {
  font-weight: 500;
  font-size: 0.875rem;
}

.user-status {
  font-size: 0.75rem;
  color: var(--gray-600);
}

/* Dropdown menu */
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  min-width: 10rem;
  max-width: calc(100vw - 20px);
  padding: 0.5rem 0;
  margin: 0.125rem 0 0;
  background-color: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  display: none;
}

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

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.5rem 1.5rem;
  clear: both;
  font-weight: 400;
  text-align: inherit;
  white-space: nowrap;
  background-color: transparent;
  border: 0;
  text-decoration: none;
  color: var(--gray-700);
  transition: background-color 0.2s ease;
}

.dropdown-item:hover {
  background-color: var(--gray-100);
  color: var(--primary);
}

.dropdown-divider {
  height: 0;
  margin: 0.5rem 0;
  overflow: hidden;
  border-top: 1px solid var(--gray-200);
}

/* ======================================
   CHAT COMPONENTS
   ====================================== */

/* Chat container */
.chat-container {
  display: flex !important; /* CRITICAL: Ensure chat container uses flexbox correctly */
  flex-direction: row; /* Allow mobile breakpoints to override */
  flex: 1;
  overflow: hidden;
}

/* Chat sidebar */
.chat-sidebar {
  width: 300px !important; /* CRITICAL: Force sidebar width at HTML level - prevents collapse even with cached CSS */
  min-width: 300px !important; /* CRITICAL FIX: Prevent sidebar from collapsing to zero */
  max-width: 100%;
  background-color: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  flex-shrink: 0 !important; /* CRITICAL FIX: Prevent flex shrinking */
  flex-basis: 300px !important; /* CRITICAL: Force flex basis for stability */
  transition: all 0.3s ease;
  overflow-x: hidden;
}

.chat-sidebar-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-sidebar-title {
  font-weight: 600;
  font-size: 1rem;
}

.chat-sidebar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ======================================
   ENHANCED SEARCH FUNCTIONALITY
   ====================================== */

/* Chat search container */
.chat-search {
  position: relative;
  border-bottom: 1px solid var(--gray-200);
}

.chat-search-input {
  position: relative;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  background-color: var(--gray-100);
  border-radius: var(--border-radius);
  padding: var(--spacing-sm) 0.75rem;
  margin: 0.75rem;
}

.chat-search-input:focus-within {
  background-color: var(--white);
  box-shadow: 0 0 0 3px rgba(30, 193, 170, 0.1);
  border: 1px solid var(--primary);
}

.chat-search-input input {
  flex: 1;
  border: none;
  background: none;
  padding: 0.375rem 0.5rem 0.375rem 0;
  font-size: 0.875rem;
  color: var(--gray-700);
  transition: all 0.3s ease;
  padding-right: 40px;
}

.chat-search-input input:focus {
  outline: none;
}

.chat-search-input input::placeholder {
  color: var(--gray-500);
  transition: color 0.3s ease;
}

.chat-search-input input:focus::placeholder {
  color: var(--gray-400);
}

.chat-search-input i {
  color: var(--gray-500);
  font-size: 0.875rem;
  margin-right: 0.5rem;
}

/* Search clear button */
.search-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--gray-500);
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  z-index: 10;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
}

.search-clear-btn:hover {
  background-color: var(--gray-200);
  color: var(--gray-700);
  transform: translateY(-50%) scale(1.1);
}

.search-clear-btn:active {
  transform: translateY(-50%) scale(0.95);
}

.search-clear-btn i {
  font-size: 12px;
}

/* Enhanced search container */
.enhanced-search-container {
  position: relative;
  z-index: 1000;
}

/* Search dropdown */
.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-width: 100%;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-top: none;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  z-index: 1001;
  display: none;
  animation: slideDown 0.2s ease;
  min-height: 200px;
  max-height: 80vh;
  overflow-x: hidden;
}

.search-dropdown.show {
  display: block;
}

/* Search filters */
.search-filters {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
  flex-shrink: 0;
}

.filter-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  border: none;
  background: none;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--gray-600);
  font-size: 0.875rem;
  gap: 6px;
  position: relative;
}

.filter-tab:hover {
  background: var(--gray-100);
  color: var(--primary);
}

.filter-tab.active {
  background: var(--primary);
  color: white;
  font-weight: 500;
}

.filter-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary-dark);
}

.filter-tab span {
  display: none;
}

/* Search content */
.search-content {
  display: flex;
  flex-direction: column;
  min-height: 150px;
}

/* Results list */
.search-results-list {
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

/* Section headers */
.search-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 5;
}

.result-count {
  margin-left: auto;
  background: var(--gray-200);
  color: var(--gray-600);
  padding: 2px 6px;
  border-radius: 12px;
  font-size: 0.75rem;
  min-width: 20px;
  text-align: center;
}

/* Search result items */
.search-result-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  transition: all 0.2s ease;
  gap: 12px;
  position: relative;
  min-height: 60px;
}

.search-result-item:hover,
.search-result-item.selected {
  background: var(--primary-bg);
  border-left: 3px solid var(--primary);
  padding-left: 13px;
  transform: translateX(2px);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:active {
  transform: translateX(1px);
  background: var(--primary-light);
}

/* Loading state */
.search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 12px;
  color: var(--gray-600);
  flex-shrink: 0;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-300);
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Result avatars */
.result-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  position: relative;
  flex-shrink: 0;
}

.result-avatar.avatar-individual {
  background: var(--primary-bg);
  color: var(--primary);
}

.result-avatar.avatar-group {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
}

.result-avatar.message-result {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* Result content */
.result-content {
  flex: 1;
  min-width: 0;
}

.result-title {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-dark);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-subtitle {
  font-size: 0.75rem;
  color: var(--gray-600);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-actions {
  color: var(--gray-400);
  font-size: 0.875rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.search-result-item:hover .result-actions {
  opacity: 1;
}

/* No results message */
.no-results-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-600);
  display: none;
  flex-shrink: 0;
}

.no-results-icon {
  font-size: 48px;
  color: var(--gray-400);
  margin-bottom: 16px;
  animation: bounce 2s ease-in-out infinite;
}

.no-results-text h4 {
  margin: 0 0 8px 0;
  font-size: 1.1rem;
  color: var(--gray-700);
}

.no-results-text p {
  margin: 0;
  font-size: 0.9rem;
}

/* Search suggestions */
.search-suggestions {
  display: none;
  flex-direction: column;
  min-height: 100px;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-top: none;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
  animation: slideDown 0.2s ease;
}

.search-suggestions.show {
  display: flex;
}

.suggestions-header {
  padding: 8px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-600);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.suggestions-list {
  flex: 1;
}

.suggestion-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  gap: 12px;
  transition: background-color 0.2s ease;
  min-height: 44px;
}

.suggestion-item:hover,
.suggestion-item.selected {
  background: var(--gray-100);
}

.suggestion-item:active {
  background: var(--primary-bg);
}

.suggestion-item i {
  color: var(--gray-400);
  width: 16px;
  flex-shrink: 0;
}

.suggestion-item span {
  flex: 1;
  font-size: 0.875rem;
  color: var(--gray-700);
}

.suggestion-remove {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.suggestion-item:hover .suggestion-remove {
  opacity: 1;
}

.suggestion-remove:hover {
  background: var(--gray-200);
  color: var(--gray-600);
}

/* Search highlights */
.search-highlight {
  background: linear-gradient(135deg, #fff3cd, #ffeaa7);
  color: #856404;
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(133, 100, 4, 0.2);
  animation: highlight 0.3s ease;
}

/* Search status */
.search-status {
  padding: 8px 12px;
  font-size: 0.75rem;
  color: var(--gray-600);
  background-color: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  display: none;
  flex-shrink: 0;
}

.search-status.show {
  display: block;
}

.search-status.searching {
  color: var(--primary);
}

.search-status.searching::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
  margin-right: 8px;
}

/* Search result styling */
.chat-contact.search-result {
  background: linear-gradient(135deg, rgba(30, 193, 170, 0.05), rgba(30, 193, 170, 0.02));
  border-left: 4px solid var(--primary);
  position: relative;
  animation: searchResult 0.3s ease;
  box-shadow: 0 2px 8px rgba(30, 193, 170, 0.1);
}

.chat-contact.search-result::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), transparent);
  animation: shimmer 2s ease-in-out infinite;
}

.chat-contact.search-result:hover {
  background: linear-gradient(135deg, rgba(30, 193, 170, 0.1), rgba(30, 193, 170, 0.05));
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(30, 193, 170, 0.2);
}

/* Search active state */
.chat-contacts.search-active {
  background-color: var(--gray-50);
  border-radius: var(--border-radius);
  padding: 5px;
}

.chat-contacts.search-active .chat-contact:not(.search-result) {
  opacity: 0.6;
  filter: grayscale(20%);
}

/* No search results */
.no-search-results {
  display: none;
  padding: 60px 30px;
  text-align: center;
  color: var(--gray-600);
  animation: fadeInUp 0.4s ease;
}

.no-search-results h4 {
  margin: 0 0 12px 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--gray-700);
}

.no-search-results p {
  margin: 0 0 8px 0;
  font-size: 1rem;
  color: var(--gray-600);
}

.no-search-results small {
  font-size: 0.85rem;
  color: var(--gray-500);
}

/* ======================================
   CHAT CONTACTS
   ====================================== */

.chat-contacts {
  flex: 1;
  overflow-y: auto;
}

.chat-contact {
  display: flex;
  align-items: center;
  padding: 0.875rem;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  transition: all 0.3s ease;
  position: relative;
}

.chat-contact:hover {
  background-color: var(--gray-100);
  transform: translateX(2px);
}

.chat-contact.active {
  background-color: var(--primary-bg);
  border-left: 3px solid var(--primary);
}

/* .chat-contact.unread::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--primary);
} */

.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  margin-right: 0.75rem;
  position: relative;
  flex-shrink: 0;
}

.contact-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-preview {
  font-size: 0.75rem;
  color: var(--gray-600);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-left: 0.5rem;
}

.contact-time {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-bottom: 0.25rem;
}

.contact-badge {
  font-size: 0.7rem;
  color: var(--white);
  background-color: var(--primary);
  border-radius: 10px;
  padding: 0.125rem 0.375rem;
  min-width: 21px;
  text-align: center;
  animation: badgePulse 0.3s ease;
}

/* ======================================
   CHAT MAIN AREA
   ====================================== */

.chat-main {
  flex: 1 !important; /* CRITICAL: Prevent chat-main from shrinking sidebar */
  min-width: 0 !important; /* CRITICAL: Allow proper flex shrinking */
  display: flex;
  flex-direction: column;
  background-color: var(--gray-100);
}

/* Chat header */
.chat-header {
  padding: var(--spacing-md);
  background-color: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
  margin-left: 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.chat-header-name {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  line-height: 1.2;
}

.chat-header-name[title] {
  cursor: help;
}

.chat-header-status {
  display: flex;
  align-items: center;
  font-size: 0.75rem;
  color: var(--gray-600);
  line-height: 1.2;
}

.chat-header-status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.375rem;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.status-text {
  font-weight: 500;
  color: var(--gray-700);
  margin-right: 0.25rem;
  transition: color 0.2s ease;
}

.last-seen-info {
  color: var(--gray-500);
  font-size: 0.7rem;
  margin-left: 0.25rem;
  white-space: nowrap;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-header-action {
  width: 32px;
  height: 32px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: var(--gray-100);
  color: var(--gray-700);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

@media (max-width: 768px) {
  .chat-header-action {
    width: 44px;
    height: 44px;
  }
}

.chat-header-action:hover {
  background-color: var(--gray-200);
}

/* Mobile "Back to conversations" – hidden on desktop */
.chat-back-to-list {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  flex-shrink: 0;
  margin-right: 0.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background-color: var(--gray-100);
  color: var(--gray-700);
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.chat-back-to-list:hover {
  background-color: var(--gray-200);
  color: var(--gray-900);
}

/* Connection status indicator */
.connection-status {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.connection-status.online {
  background-color: var(--success);
  color: white;
}

.connection-status.offline {
  background-color: var(--danger);
  color: white;
}

/* ======================================
   STATUS INDICATORS AND AVATARS
   ====================================== */

/* Status indicators */
.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--white);
  position: absolute;
  bottom: -2px;
  right: -2px;
  z-index: 10;
}

.status-online { background-color: var(--status-online); }
.status-offline { background-color: var(--status-offline); }
.status-away { background-color: var(--status-away); }
.status-busy { background-color: var(--status-busy); }
.status-dnd { background-color: var(--status-dnd); }

/* Contact avatar status indicators */
.contact-avatar .status-indicator {
  width: 12px;
  height: 12px;
  bottom: -1px;
  right: -1px;
}

/* Message avatar status indicators */
.message-avatar .status-indicator {
  width: 10px;
  height: 10px;
  bottom: -1px;
  right: -1px;
}

/* User avatar status indicators */
.user-avatar .status-indicator {
  width: 11px;
  height: 11px;
  bottom: -1px;
  right: -1px;
}

/* Avatar color classes */
.avatar-color-1 { background-color: var(--avatar-bg-1) !important; color: var(--avatar-text-1) !important; }
.avatar-color-2 { background-color: var(--avatar-bg-2) !important; color: var(--avatar-text-2) !important; }
.avatar-color-3 { background-color: var(--avatar-bg-3) !important; color: var(--avatar-text-3) !important; }
.avatar-color-4 { background-color: var(--avatar-bg-4) !important; color: var(--avatar-text-4) !important; }
.avatar-color-5 { background-color: var(--avatar-bg-5) !important; color: var(--avatar-text-5) !important; }
.avatar-color-6 { background-color: var(--avatar-bg-6) !important; color: var(--avatar-text-6) !important; }
.avatar-color-7 { background-color: var(--avatar-bg-7) !important; color: var(--avatar-text-7) !important; }
.avatar-color-8 { background-color: var(--avatar-bg-8) !important; color: var(--avatar-text-8) !important; }

/* Group avatar base styles */
.avatar-group {
  background: linear-gradient(135deg, var(--avatar-bg-1), var(--avatar-bg-4)) !important;
  color: white !important;
  position: relative;
  overflow: hidden;
}

.avatar-group span {
  position: relative;
  z-index: 2;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Individual group color schemes */
.avatar-group-1 { background: linear-gradient(135deg, #1E88E5, #42A5F5) !important; color: #FFFFFF !important; }
.avatar-group-2 { background: linear-gradient(135deg, #43A047, #66BB6A) !important; color: #FFFFFF !important; }
.avatar-group-3 { background: linear-gradient(135deg, #FF8A65, #FFAB91) !important; color: #FFFFFF !important; }
.avatar-group-4 { background: linear-gradient(135deg, #8E24AA, #AB47BC) !important; color: #FFFFFF !important; }
.avatar-group-5 { background: linear-gradient(135deg, #E53935, #EF5350) !important; color: #FFFFFF !important; }
.avatar-group-6 { background: linear-gradient(135deg, #FFB300, #FFC107) !important; color: #212121 !important; }
.avatar-group-7 { background: linear-gradient(135deg, #26A69A, #4DB6AC) !important; color: #FFFFFF !important; }
.avatar-group-8 { background: linear-gradient(135deg, #D81B60, #E91E63) !important; color: #FFFFFF !important; }

/* Group avatar effects */
.avatar-group-1,
.avatar-group-2,
.avatar-group-3,
.avatar-group-4,
.avatar-group-5,
.avatar-group-6,
.avatar-group-7,
.avatar-group-8 {
  transition: all 0.3s ease;
  position: relative;
}

.avatar-group-1::before,
.avatar-group-2::before,
.avatar-group-3::before,
.avatar-group-4::before,
.avatar-group-5::before,
.avatar-group-6::before,
.avatar-group-7::before,
.avatar-group-8::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.1) 20%, transparent 21%),
                    radial-gradient(circle at 70% 80%, rgba(255, 255, 255, 0.08) 15%, transparent 16%);
  border-radius: inherit;
  pointer-events: none;
}

.avatar-group-6 span {
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

/* Chat header status styles */
.chat-header-status-indicator.status-online { background-color: var(--status-online); }
.chat-header-status-indicator.status-offline { background-color: var(--status-offline); }
.chat-header-status-indicator.status-away { background-color: var(--status-away); }
.chat-header-status-indicator.status-busy { background-color: var(--status-busy); }
.chat-header-status-indicator.status-dnd { background-color: var(--status-dnd); }

/* Individual user status styling */
.chat-header[data-is-group="false"] .status-text.status-online,
.chat-header[data-is-group="false"] .status-text.status-away,
.chat-header[data-is-group="false"] .status-text.status-busy,
.chat-header[data-is-group="false"] .status-text.status-dnd,
.chat-header[data-is-group="false"] .status-text.status-offline {
  color: var(--gray-700) !important;
  background-color: transparent !important;
}

/* Group status styling */
.chat-header[data-is-group="true"] .status-text {
  color: var(--gray-700) !important;
  font-weight: 500;
}

.chat-header[data-is-group="true"] .chat-header-status-indicator,
.chat-header[data-is-group="true"] .status-indicator {
  display: none !important;
}

.chat-header[data-is-group="true"] .last-seen-info {
  color: var(--gray-500);
}

/* ======================================
   CHAT MESSAGES
   ====================================== */

/* Chat body */
.chat-body {
    padding: 1rem;
    gap: 1rem;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
    overflow-y: auto;
    height: 100%;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-400) transparent;
}

.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.chat-body::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

.message-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    position: relative;
}

.message-group .chat-message {
    margin-bottom: 0;
}

.message-group .chat-message:not(:last-child) .message-avatar {
    opacity: 0;
}

.message-group .chat-message:not(:last-child) .message-meta {
    display: none;
}

/* Date headers */
.chat-day {
    text-align: center;
    margin: 1.5rem 0;
    position: relative; /* Changed from sticky to relative */
    z-index: 1; /* Lower z-index so it doesn't overlap messages */
    clear: both; /* Ensure it doesn't interfere with message flow */
}

.chat-day::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--gray-300);
    z-index: -1; /* Place the line behind the text */
}

.chat-day-text {
    background: var(--white);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative; /* Keep text above the line */
    display: inline-block; /* Only take up as much space as needed */
}

/* Empty messages state */
.chat-empty-messages {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  color: var(--gray-500);
  text-align: center;
  min-height: 150px;
}

.chat-empty-messages p {
  background-color: var(--gray-100);
  padding: 1rem;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}

/* Message spacing */
.chat-day + .chat-message {
    margin-top: 1rem; /* Space after a date header */
}

.chat-message + .chat-day {
    margin-top: 2rem; /* More space before a date header */
}

.chat-message:last-child {
  margin-bottom: var(--spacing-lg);
}

/* Chat messages */
.chat-message {
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    max-width: 100%;
    animation: messageSlideIn 0.3s ease-out;
    transform-origin: left;
    position: relative; /* Ensure proper stacking context */
    z-index: 2;
}

.chat-message-outgoing {
  flex-direction: row-reverse;
}

.chat-message-outgoing .message-content {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
  margin-right: 0.75rem;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.message-avatar img,
.message-avatar .message-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.chat-message-outgoing .message-avatar {
  margin-right: 0;
  margin-left: 0.75rem;
}

.message-content {
    flex: 1 !important; /* CRITICAL: Force message content flex behavior - prevents vertical text rendering */
    min-width: 0 !important; /* CRITICAL FIX: Allows flex items to shrink below content size */
    max-width: 70% !important; /* CRITICAL: Force max width for proper layout */
}

.message-bubble {
    background: white;
    border-radius: 18px 18px 18px 4px;
    padding: 12px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    word-wrap: break-word !important; /* CRITICAL: Force message bubble text wrapping - prevents text overflow */
    overflow-wrap: break-word !important; /* CRITICAL FIX: Prevents text overflow */
    word-break: break-word !important; /* CRITICAL: Additional word break for long strings */
    position: relative;
    min-width: 0 !important; /* CRITICAL FIX: Allow bubble to shrink in flex container */
}

.chat-message-outgoing .message-bubble {
    background: var(--primary-light);
    border-radius: 18px 18px 4px 18px;
    margin-left: auto;
}

.message-text {
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.message-text p {
    margin: 0;
}

.message-text p + p {
    margin-top: 8px;
}

.message-text p:last-child {
  margin-bottom: 0;
}

.message-text a {
  color: var(--primary);
  text-decoration: none;
}

.message-text a:hover {
  text-decoration: underline;
}

.message-text img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius-sm);
  margin: 5px 0;
}

.message-text ul,
.message-text ol {
  margin-top: 5px;
  margin-bottom: 5px;
  padding-left: 20px;
}

.message-text ul li,
.message-text ol li {
  margin-bottom: 3px;
}

.message-text blockquote {
  border-left: 3px solid var(--primary-light);
  padding-left: 10px;
  margin: 8px 0;
  color: var(--gray-700);
}

.message-text code {
  background-color: var(--gray-100);
  padding: 2px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
}

.message-text pre {
  background-color: var(--gray-100);
  padding: 8px;
  border-radius: var(--border-radius-sm);
  font-family: monospace;
  overflow-x: auto;
  margin: 8px 0;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.message-time {
    font-size: 0.75rem;
    color: var(--gray-500);
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.chat-message:hover .message-time {
    opacity: 1;
}

.message-status {
  display: flex;
  align-items: center;
}

.message-actions {
    opacity: 0;
    transition: opacity 0.2s ease;
    margin-top: 4px;
}

.chat-message:hover .message-actions {
    opacity: 1;
}

.message-action-button {
    background: none;
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.message-action-button:hover {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
}

/* Better spacing for consecutive messages from same user */
.chat-message + .chat-message[data-sender-id] {
    margin-top: 0.5rem;
}

.chat-message + .chat-message[data-sender-id]:not([data-sender-id=""]) {
    margin-top: 1rem;
}

.message-status i {
  font-size: 0.7rem;
  margin-left: 4px;
  opacity: 0.7;
}

.message-status .status-read {
  color: var(--primary);
  opacity: 1;
}

/* ======================================
   SIMPLE LOADING UI STYLES
   Add to your hrstyle.css file
   ====================================== */

/* Option 1: Simple Scrollbar Progress */
.simple-loading-bar {
    position: relative;
    padding: 12px 0;
    margin: 10px 0;
    text-align: center;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 6px;
}

.loading-progress {
    height: 3px;
    background: linear-gradient(90deg, #1ec1aa, #4fb0c9);
    border-radius: 2px;
    width: 0%;
    animation: progressBar 2s ease-in-out infinite;
    margin-bottom: 8px;
}

.loading-text {
    font-size: 12px;
    color: #6c757d;
    font-weight: 500;
}

@keyframes progressBar {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* Option 2: Minimal Dot Loader */
.minimal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 0;
    gap: 8px;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #1ec1aa;
    animation: dotPulse 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Option 3: Ultra Simple Text Only */
.text-loading {
    text-align: center;
    padding: 10px 0;
    font-size: 13px;
    color: #6c757d;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.text-loading .loading-text {
    animation: textFade 2s ease-in-out infinite;
}

@keyframes textFade {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Enhanced Simple Progress Bar (Recommended) */
.enhanced-simple-loading {
    position: relative;
    padding: 8px 20px;
    margin: 8px 0;
    background: #f8f9fa;
    border-radius: 20px;
    border: 1px solid #e9ecef;
}

.enhanced-simple-loading .loading-progress {
    height: 2px;
    background: #1ec1aa;
    border-radius: 1px;
    width: 0%;
    animation: smoothProgress 1.8s ease-in-out infinite;
    margin-bottom: 6px;
}

.enhanced-simple-loading .loading-text {
    font-size: 11px;
    color: #495057;
    text-align: center;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes smoothProgress {
    0% { 
        width: 0%; 
        transform: translateX(-100%);
    }
    50% { 
        width: 100%; 
        transform: translateX(0%);
    }
    100% { 
        width: 100%; 
        transform: translateX(100%);
    }
}

/* Pulse Line Loader (Very Minimal) */
.pulse-line-loading {
    padding: 12px 0;
    text-align: center;
}

.pulse-line {
    height: 1px;
    background: #1ec1aa;
    margin: 0 auto 8px;
    width: 60%;
    animation: pulseLine 1.5s ease-in-out infinite;
}

@keyframes pulseLine {
    0%, 100% { 
        opacity: 0.3; 
        width: 30%;
    }
    50% { 
        opacity: 1; 
        width: 80%;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .simple-loading-bar,
    .minimal-loading,
    .text-loading,
    .enhanced-simple-loading {
        margin: 6px 0;
        padding: 8px 15px;
    }
    
    .loading-text {
        font-size: 11px;
    }
    
    .loading-dots span {
        width: 5px;
        height: 5px;
    }
}

/* Remove complex animations for better performance */
@media (prefers-reduced-motion: reduce) {
    .loading-progress,
    .loading-dots span,
    .loading-text,
    .pulse-line {
        animation: none;
    }
    
    .loading-progress {
        width: 50%;
    }
    
    .loading-dots span {
        opacity: 0.7;
    }
}

/* Message attachments */
.message-attachment {
    margin-top: 8px;
    background: var(--gray-100);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 300px;
}

.attachment-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Req 8: Inline image thumbnail + broken-image fallback */
.attachment-thumbnail-wrap {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
}

.attachment-thumbnail {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.attachment-thumbnail-fallback {
    width: 80px;
    height: 80px;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.attachment-info {
    flex: 1;
    min-width: 0;
}

.attachment-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-dark);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-size {
    font-size: 0.75rem;
    color: var(--gray-600);
}

.attachment-action {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.attachment-action:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--gray-600);
  font-style: italic;
  opacity: 0;
  animation: fadeInTyping 0.3s ease forwards;
  margin-bottom: var(--spacing-md);
}

.typing-dots {
  display: flex;
  align-items: center;
  margin-left: 0.5rem;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--gray-500);
  margin: 0 0.125rem;
  animation: typing-animation 1.5s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Message actions */
.message-actions {
  display: flex;
  margin-top: 0.25rem;
}

.message-action-button {
  background: none;
  border: none;
  color: var(--gray-500);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  display: flex;
  align-items: center;
  border-radius: var(--border-radius-sm);
  transition: all 0.2s ease;
}

.message-action-button:hover {
  background-color: var(--gray-200);
  color: var(--gray-700);
}

.message-action-button i {
  margin-right: 0.25rem;
  font-size: 0.75rem;
}

/* Threaded replies */
.threaded-replies {
  margin-left: 2.5rem;
  padding-left: 1rem;
  border-left: 2px solid var(--gray-300);
}

.threaded-reply {
  margin-top: 0.75rem;
}

.reply-toggle {
  color: var(--primary);
  font-size: 0.75rem;
  margin-top: 0.25rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: color 0.2s ease;
}

.reply-toggle:hover {
  color: var(--primary-dark);
}

.reply-toggle i {
  margin-right: 0.25rem;
}

.reply-count {
  background-color: var(--primary-bg);
  color: var(--primary);
  padding: 0.125rem 0.375rem;
  border-radius: 10px;
  font-size: 0.7rem;
  margin-left: 0.25rem;
}

/* Message highlighting */
.highlighted-message {
  background: var(--warning) !important;
  animation: highlightPulse 2s ease-in-out;
}

/* ======================================
   CHAT FOOTER AND INPUT
   ====================================== */

.chat-footer {
  position: static;
  padding: var(--spacing-md);
  background-color: var(--white);
  border-top: 1px solid var(--gray-200);
}

.message-input-container {
    width: 100%;
}

.message-input-actions {
    padding: 8px;
    display: flex;
    align-items: center;
    border-right: 1px solid #f0f0f0;
}

.tox-editor-container {
    visibility: visible !important;
    opacity: 1 !important;
}

/* Fallback textarea styling */
#fallbackTextarea {
    flex: 1;
    min-height: 100px;
    border: none;
    padding: 10px 15px;
    font-family: "Poppins", sans-serif;
    font-size: 14px;
    resize: none;
    line-height: 1.4;
    outline: none;
}

.message-input-action {
  width: 32px;
  height: 32px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: var(--gray-100);
  color: var(--gray-600);
  border: none;
  cursor: pointer;
  margin-right: 0.375rem;
  transition: all 0.3s ease;
}

@media (max-width: 768px) {
  .message-input-action {
    width: 44px;
    height: 44px;
  }
}

.message-input-action:hover {
  background-color: var(--gray-200);
}

.message-input {
  flex: 1;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
}

.message-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 193, 170, 0.1);
}

.message-send {
    background-color: var(--primary, #1ec1aa);
    border: none;
    width: 40px;
    height: 40px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    margin-right: 10px;
    cursor: pointer;
    color: white;
    transition: all 0.2s ease;
}

@media (max-width: 768px) {
  .message-send {
    width: 44px;
    height: 44px;
  }
}

.message-send:hover {
    background-color: var(--primary-dark, #19a999);
    transform: scale(1.05);
}

/* Rich text editor styles */
.rich-text-container {
    display: flex;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: relative;
    align-items: flex-start;
}

#richTextEditor {
    flex: 1;
    min-height: 100px;
    overflow: hidden;
}

.rich-text-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 193, 170, 0.1);
}

.rich-text-container .message-input-actions {
  display: flex;
  flex-direction: column;
  padding: 8px;
  border-right: 1px solid var(--gray-200);
}

/* TinyMCE editor styles */
.tox.tox-tinymce {
  border: none !important;
  border-radius: 0 !important;
  flex-grow: 1;
  min-height: 100px !important;
  max-height: 200px !important;
}

.tox-toolbar__group {
  padding: 0 3px !important;
}

.tox .tox-toolbar__primary {
  background: var(--gray-100) !important;
  border-top: 1px solid var(--gray-200) !important;
}

.tox .tox-edit-area__iframe {
  background-color: var(--white) !important;
}

.tox .tox-tbtn {
  height: 28px !important;
  width: 28px !important;
  margin: 0 1px !important;
}

.tox .tox-tbtn svg {
  height: 16px !important;
  width: 16px !important;
}

.editor-info {
  text-align: right;
  padding: 5px 0;
  font-size: 12px;
  color: var(--gray-600);
}

/* Attachment preview */
#attachmentPreview {
  margin-bottom: 10px;
  transition: all 0.3s ease;
}

.attachment-preview {
  display: flex;
  align-items: center;
  background-color: var(--gray-100);
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.attachment-preview i {
  margin-right: 8px;
  color: var(--primary);
}

.attachment-preview span {
  flex-grow: 1;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-preview .btn-close {
  font-size: 10px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.attachment-preview .btn-close:hover {
  opacity: 1;
}

/* ======================================
   APP MENU AND MODALS
   ====================================== */

/* App launcher */
.app-launcher {
  width: 36px;
  height: 36px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: var(--primary-bg);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.3s ease;
}

@media (max-width: 768px) {
  .app-launcher {
    width: 44px;
    height: 44px;
  }
}

.app-launcher:hover {
  background-color: var(--primary-light);
}

.app-launcher i {
  font-size: 1.25rem;
}

/* App menu */
.app-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
  opacity: 0;
  overflow: hidden;
}

.app-menu.show {
  display: flex;
  opacity: 1;
}

.app-menu-content {
  width: 90%;
  max-width: 900px;
  max-width: min(900px, calc(100vw - 20px));
  background-color: var(--white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.app-menu.show .app-menu-content {
  transform: translateY(0);
}

.app-menu-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-menu-title {
  font-weight: 600;
  font-size: 1.25rem;
}

.app-menu-close {
  background: none;
  border: none;
  color: var(--gray-600);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.app-menu-close:hover {
  color: var(--gray-900);
}

.app-menu-body {
  padding: var(--spacing-lg);
  overflow-y: auto;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--spacing-lg);
}

@media (max-width: 400px) {
  .app-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--spacing-md);
  }
}

.app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--spacing-lg);
  border-radius: var(--border-radius);
  background-color: var(--gray-100);
  transition: all 0.3s ease;
  text-decoration: none;
  color: var(--text-dark);
  text-align: center;
}

.app-item:hover {
  background-color: var(--primary-bg);
  transform: translateY(-5px);
  box-shadow: var(--shadow);
}

.app-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--white);
  color: var(--primary);
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-md);
  font-size: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.app-item:hover .app-icon {
  transform: scale(1.1);
}

.app-name {
  font-weight: 500;
  font-size: 0.9375rem;
  margin-bottom: 0.5rem;
}

.app-description {
  font-size: 0.75rem;
  color: var(--gray-600);
}

.recent-apps {
  margin-bottom: 2rem;
}

.section-title {
  font-weight: 500;
  font-size: 1rem;
  margin-bottom: var(--spacing-md);
  color: var(--gray-700);
}

/* App menu – responsive overrides (must follow base rules) */
@media (max-width: 768px) {
  .app-menu-content {
    width: 94%;
    max-height: 88vh;
  }
  .app-menu-header {
    padding: 1rem;
  }
  .app-menu-body {
    padding: var(--spacing-md);
  }
  .app-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--spacing-md);
  }
}

@media (max-width: 576px) {
  .app-menu-header {
    padding: 0.875rem;
  }
  .app-menu-title {
    font-size: 1.125rem;
  }
  .app-menu-body {
    padding: var(--spacing-md);
  }
  .app-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--spacing-md);
  }
  .app-item {
    min-height: 44px;
    padding: var(--spacing-md);
  }
  .app-icon {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }
  .app-name {
    font-size: 0.875rem;
  }
  .app-description {
    font-size: 0.6875rem;
  }
  .recent-apps {
    margin-bottom: 1.5rem;
  }
}

@media (max-width: 400px) {
  .app-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--spacing-sm);
  }
  .app-item {
    padding: var(--spacing-sm);
  }
  .app-icon {
    width: 44px;
    height: 44px;
    font-size: 1.125rem;
  }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1050;
}

.sidebar-overlay.show {
  display: block;
}

/* ======================================
   CUSTOM TOAST NOTIFICATIONS - HR THEME
   ====================================== */

/* Toast container positioning */
.toast-container {
  position: fixed !important;
  top: 20px !important;
  right: 20px !important;
  bottom: auto !important;
  z-index: 9999;
}

/* Main toast styling */
#chatToast {
  min-width: 350px;
  max-width: 450px;
  background-color: var(--white) !important;
  border: none;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  animation: slideInRight 0.3s ease-out;
}

/* Toast header with theme colors */
#chatToast .toast-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 12px 16px;
  border-bottom: none;
  border-radius: 12px 12px 0 0;
}

#chatToast .toast-header strong {
  font-weight: 600;
  font-size: 0.95rem;
}

/* Close button styling */
#chatToast .btn-close {
  background: transparent;
  opacity: 0.8;
  filter: brightness(0) invert(1);
  padding: 0.5rem;
}

#chatToast .btn-close:hover {
  opacity: 1;
}

/* Toast body */
#chatToast .toast-body {
  padding: 14px 16px;
  font-size: 0.9rem;
  color: var(--text-dark);
  background-color: var(--white);
  border-radius: 0 0 12px 12px;
}

/* Different toast types */
#chatToast.bg-success .toast-header {
  background: linear-gradient(135deg, #28a745, #218838);
}

#chatToast.bg-warning .toast-header {
  background: linear-gradient(135deg, #ffc107, #e0a800);
}

#chatToast.bg-danger .toast-header {
  background: linear-gradient(135deg, #dc3545, #c82333);
}

#chatToast.bg-info .toast-header {
  background: linear-gradient(146deg, #1ec1a7, #36909f);
}

#chatToast .toast-header .btn-close {
  background: transparent;
  opacity: 1;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Create custom X icon */
#chatToast .toast-header .btn-close::before,
#chatToast .toast-header .btn-close::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 2px;
  background-color: white;
  border-radius: 1px;
}

#chatToast .toast-header .btn-close::before {
  transform: rotate(45deg);
}

#chatToast .toast-header .btn-close::after {
  transform: rotate(-45deg);
}

#chatToast .toast-header .btn-close:hover {
  opacity: 0.8;
}

/* Remove the default Bootstrap close button background */
#chatToast .toast-header .btn-close {
  background-image: none !important;
  border: none;
}

/* Animation for toast entrance */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Fade out animation */
.toast.hide {
  animation: fadeOutRight 0.3s ease-out;
}

@keyframes fadeOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Responsive adjustments */
@media (max-width: 576px) {
  .toast-container {
    top: 10px !important;
    right: 10px !important;
    left: 10px !important;
  }
  
  #chatToast {
    min-width: auto;
    max-width: 100%;
  }
}

/* ======================================
   LOADING STATES
   ====================================== */

.chat-skeleton-loader {
  padding: 20px;
  opacity: 0.7;
}

.skeleton-message {
  height: 60px;
  margin-bottom: 20px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 10px;
}

.chat-main.loading .chat-body {
  overflow: hidden;
}

.chat-header.loading .chat-header-name,
.chat-header.loading .chat-header-status {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 4px;
  color: transparent;
}

.chat-header.loading .chat-header-name {
  width: 120px;
  height: 16px;
  margin-bottom: 4px;
}

.chat-header.loading .chat-header-status {
  width: 80px;
  height: 12px;
}

/* Upload progress */
.upload-progress {
  display: flex;
  align-items: center;
  background-color: var(--gray-100);
  border-radius: var(--border-radius);
  padding: 10px 15px;
  margin: 10px 0;
  box-shadow: var(--shadow-sm);
  max-width: 70%;
  margin-left: auto;
  margin-right: auto;
}

.upload-progress-info {
  flex: 1;
  margin-right: 10px;
}

.upload-filename {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.upload-progress-bar {
  height: 6px;
  background-color: var(--gray-300);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 5px;
}

.upload-progress-fill {
  height: 100%;
  background-color: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.upload-progress-text {
  font-size: 0.75rem;
  color: var(--gray-600);
  text-align: right;
}

.upload-cancel-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--gray-300);
  border: none;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-cancel-btn:hover {
  background-color: var(--danger);
  color: var(--white);
}

/* ======================================
   THREAD SIDEBAR PANEL
   ====================================== */

/* Thread panel container */
.thread-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 400px;
    max-width: 100vw;
    background-color: var(--white);
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
    display: none;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1100;
    overflow: hidden;
}

.thread-panel.show {
    display: flex !important;
    transform: translateX(0);
}

/* Add overlay when thread is open */
.thread-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1099;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.thread-overlay.show {
    display: block !important;
    opacity: 1;
}

/* Thread panel header */
.thread-panel-header {
  padding: var(--spacing-md);
  background-color: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
}

.thread-panel-title {
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 0.9375rem;
  gap: 0.5rem;
}

.thread-panel-title i {
  color: var(--primary);
}

.thread-panel-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: var(--gray-100);
    color: var(--gray-700);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 10;
}

.thread-panel-close:hover {
    background-color: var(--danger);
    color: var(--white);
    transform: scale(1.1);
}

.thread-panel-close:active {
    transform: scale(0.95);
}

body.thread-open {
    overflow: hidden;
}

/* Thread panel body */
.thread-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
  background-color: var(--gray-100);
}

/* Thread empty state */
.thread-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--gray-500);
}

.thread-empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--gray-400);
}

/* Thread original message */
.thread-original-message {
  background-color: var(--white);
  border-radius: var(--border-radius);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary);
}

.thread-original-header {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}

.thread-original-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
  margin-right: 0.5rem;
}

.thread-original-info {
  flex: 1;
}

.thread-original-name {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.125rem;
}

.thread-original-time {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.thread-original-content {
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Thread replies section */
.thread-replies-section {
  margin-top: var(--spacing-md);
}

.thread-replies-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: var(--spacing-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Thread reply messages */
.thread-reply-message {
  display: flex;
  margin-bottom: var(--spacing-md);
  animation: fadeIn 0.3s ease;
}

.thread-reply-message[data-reply-id] {
    position: relative;
}

.thread-reply-message[data-reply-id]:after {
    content: attr(data-reply-id);
    position: absolute;
    top: -10px;
    right: 5px;
    font-size: 8px;
    color: #ccc;
    display: none; /* Enable for debugging */
}

.thread-reply-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.675rem;
  margin-right: 0.5rem;
  flex-shrink: 0;
  overflow: hidden;
}

.thread-reply-avatar img,
.thread-reply-avatar .thread-reply-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.thread-reply-content {
  flex: 1;
}

.thread-reply-bubble {
  background-color: var(--white);
  border-radius: var(--border-radius);
  padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow-sm);
}

.thread-reply-header {
  display: flex;
  align-items: center;
  margin-bottom: 0.25rem;
}

.thread-reply-name {
  font-weight: 600;
  font-size: 0.75rem;
  margin-right: 0.5rem;
}

.thread-reply-time {
  font-size: 0.675rem;
  color: var(--gray-500);
}

.thread-reply-text {
  font-size: 0.8125rem;
  line-height: 1.4;
}

/* Thread panel footer */
.thread-panel-footer {
  padding: var(--spacing-md);
  background-color: var(--white);
  border-top: 1px solid var(--gray-200);
}

.thread-input-container {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.thread-input {
  flex: 1;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.thread-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 193, 170, 0.1);
}

.thread-send-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: var(--primary);
  color: var(--white);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.thread-send-btn:hover {
  background-color: var(--primary-dark);
  transform: scale(1.05);
}

.thread-send-btn:active {
  transform: scale(0.95);
}

/* Loading state for thread */
.thread-loading {
    pointer-events: none;
}

.thread-panel.loading {
    pointer-events: none;
}

.thread-panel.loading .thread-panel-footer {
    opacity: 0.5;
    pointer-events: none;
}

.thread-loading i {
  font-size: 1.5rem;
  animation: spin 1s linear infinite;
}

/* Remove old inline thread styles from messages */
.threaded-replies {
  display: none !important;
}

.reply-toggle {
  display: none !important;
}

.threaded-replies,
.reply-toggle,
.thread-reply-input,
.thread-reply-btn {
  display: none !important;
}

/* Update message actions to only show reply button */
.message-actions {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.chat-message:hover .message-actions {
  opacity: 1;
}

/* Mobile/touch: show reply button without hover (hover doesn't work on touch) */
@media (max-width: 768px) {
  .chat-message .message-actions {
    opacity: 1;
  }
  .message-action-button {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 12px;
  }
}

/* Reply count badge */
.reply-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background-color: var(--primary-bg);
    color: var(--primary);
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.reply-count-badge:hover {
    background-color: var(--primary);
    color: var(--white);
    transform: scale(1.05);
}

.reply-count-badge i {
    font-size: 0.65rem;
}

.reply-count-badge .count {
    font-weight: 600;
    margin: 0 2px;
}

.reply-count-badge .text {
    font-size: 0.65rem;
}

/* Optimistic reply styling */
.optimistic-reply {
    opacity: 0.7;
    border-left: 2px solid var(--warning);
    animation: sending 1.5s ease-in-out infinite;
}

/* Thread loading and error states */
.thread-loading,
.thread-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: var(--gray-600);
}

.thread-error {
    color: var(--danger);
}

.thread-loading i,
.thread-error i {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.thread-loading i {
    animation: spin 1s linear infinite;
}

/* ======================================
   ANIMATIONS
   ====================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInTyping {
  to { opacity: 1; }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes typing-animation {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes toast-in-right {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes loading {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

@keyframes spin {
  0% { 
    transform: rotate(0deg); 
  }
  100% { 
    transform: rotate(360deg); 
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes highlight {
  0% {
    background-color: var(--primary-light);
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes searchResult {
  from {
    transform: translateX(-10px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    width: 0;
  }
  to {
    width: 3px;
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes groupAvatarAppear {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes highlightPulse {
  0% { 
    background-color: var(--warning) !important; 
  }
  50% { 
    background-color: transparent !important; 
  }
  100% { 
    background-color: var(--warning) !important; 
  }
}

@keyframes badgePulse {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes sending {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0.4; }
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0.4; }
}

/* Group avatar animation */
.avatar-group-1,
.avatar-group-2,
.avatar-group-3,
.avatar-group-4,
.avatar-group-5,
.avatar-group-6,
.avatar-group-7,
.avatar-group-8 {
  animation: groupAvatarAppear 0.3s ease-out;
}

/* Hover effects for group avatars */
.chat-contact:hover .avatar-group-1,
.chat-contact:hover .avatar-group-2,
.chat-contact:hover .avatar-group-3,
.chat-contact:hover .avatar-group-4,
.chat-contact:hover .avatar-group-5,
.chat-contact:hover .avatar-group-6,
.chat-contact:hover .avatar-group-7,
.chat-contact:hover .avatar-group-8 {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Active conversation highlights */
.chat-contact.active .avatar-group-1,
.chat-contact.active .avatar-group-2,
.chat-contact.active .avatar-group-3,
.chat-contact.active .avatar-group-4,
.chat-contact.active .avatar-group-5,
.chat-contact.active .avatar-group-6,
.chat-contact.active .avatar-group-7,
.chat-contact.active .avatar-group-8 {
  box-shadow: 0 0 0 3px rgba(30, 193, 170, 0.3);
  transform: scale(1.02);
}

/* Status indicators for group avatars (hidden) */
.avatar-group-1 .status-indicator,
.avatar-group-2 .status-indicator,
.avatar-group-3 .status-indicator,
.avatar-group-4 .status-indicator,
.avatar-group-5 .status-indicator,
.avatar-group-6 .status-indicator,
.avatar-group-7 .status-indicator,
.avatar-group-8 .status-indicator {
  display: none;
}

/* ======================================
   RESPONSIVE DESIGN
   ====================================== */

/* Prevent horizontal scrollbar globally */
body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Ensure all containers respect viewport */
.app-container,
.main-content,
.chat-container {
  max-width: 100%;
  overflow-x: hidden;
}

/* Global image responsiveness */
img {
  max-width: 100%;
  height: auto;
}

/* Large Desktop (1920px+) */
@media (min-width: 1920px) {
  .app-container {
    max-width: 1920px;
    margin: 0 auto;
  }
  .main-content {
    max-width: 100%;
  }
  .chat-sidebar {
    width: 350px;
  }
  .message-content {
    max-width: 55%;
  }
  .login-container {
    max-width: 1200px;
  }
}

/* Desktop (1440px to 1919px) */
@media (min-width: 1440px) and (max-width: 1919px) {
  .app-container {
    max-width: 100%;
  }
  .chat-sidebar {
    width: 320px;
  }
  .message-content {
    max-width: 60%;
  }
  .login-container {
    max-width: 1100px;
  }
}

/* Extra Large Devices (1200px to 1439px) */
@media (min-width: 1200px) and (max-width: 1439px) {
  .chat-sidebar {
    width: 320px;
  }
  .message-content {
    max-width: 60%;
  }
}

/* Small Laptop (1024px to 1199px) */
@media (min-width: 1024px) and (max-width: 1199px) {
  .sidebar {
    width: 240px;
  }
  .chat-sidebar {
    width: 280px;
  }
  .message-content {
    max-width: 70%;
  }
  .thread-panel {
    width: 320px;
  }
  .login-container {
    max-width: 900px;
  }
}

/* Large Devices (992px to 1199px) */
@media (max-width: 1200px) {
  .user-info {
    display: none;
  }
  .message-content {
    max-width: 75%;
  }
  .thread-panel {
    width: 300px;
  }
}

/* Medium Devices (768px to 991px) */
@media (max-width: 992px) {
  .sidebar {
    width: 80px;
  }
  .sidebar-brand-text {
    display: none;
  }
  .nav-link span {
    display: none;
  }
  .nav-link {
    justify-content: center;
  }
  .chat-sidebar {
    width: 260px;
    max-width: 100%;
  }
  .chat-header-actions {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .chat-header-action {
    margin-bottom: 0.25rem;
    min-width: 44px;
    min-height: 44px;
  }
  .login-container {
    flex-direction: column;
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    max-height: none;
    max-width: 600px;
    width: 100%;
    margin: 15px auto;
    align-items: stretch;
    min-width: 0;
    overflow-x: hidden;
  }
  .login-form,
  .login-image {
    min-width: 0;
    max-width: 100%;
  }
  .login-form {
    max-width: none;
    padding: 30px 30px 48px;
    flex-shrink: 0;
    justify-content: center;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: none;
    z-index: auto;
  }
  .login-image {
    padding: 30px 20px;
    text-align: center;
    flex-shrink: 0;
    justify-content: center;
    margin-left: 0;
    background: linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.92) 0%,
      rgba(226, 244, 245, 0.95) 12%,
      var(--accent) 100%
    );
  }
  .login-image .login-trust-intro {
    text-align: center;
  }
  .login-image .login-trust-list {
    margin-left: auto;
    margin-right: auto;
  }
  .login-page .login-welcome {
    font-size: 1.5rem;   /* keep hero on tablet */
    text-align: center;
  }
  .login-page .login-brand-tagline {
    text-align: center;
  }
  .hr-title {
    font-size: 20px;
  }
  .hr-subtitle {
    margin-bottom: 25px;
  }
  .hr-cards {
    grid-template-columns: 1fr;
    max-width: 100%;
    gap: 15px;
  }
  .hr-card {
    margin-bottom: 15px;
    min-width: 0;
  }
  .hr-card h3,
  .hr-card p {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  .thread-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 100%;
    max-width: 400px;
    z-index: 1200;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
  }
}

/* Small Devices (576px to 767px) */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
    overflow-x: hidden;
  }
  .sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1100;
    width: 250px;
    max-width: 80vw;
  }
  .sidebar.show {
    display: flex;
  }
  .mobile-toggle {
    display: block;
    min-width: 44px;
    min-height: 44px;
  }
  .chat-container {
    flex-direction: column !important;
    overflow-x: hidden;
    min-width: 0;
    width: 100%;
  }
  .chat-back-to-list {
    display: flex;
  }
  .chat-sidebar {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100vw;
    height: 300px;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
  }
  .chat-main {
    height: calc(100vh - 300px - 60px);
    min-height: 0;
    overflow: hidden;
  }
  /* Mobile: show only conversation list when "Back" was pressed */
  .chat-container.chat-mobile-show-list .chat-sidebar {
    height: 100%;
    min-height: 50vh;
    flex: 1;
  }
  .chat-container.chat-mobile-show-list .chat-main {
    display: none !important;
  }
  .app-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .message-content {
    max-width: 85%;
  }
  .message-input-actions {
    margin-right: 0.5rem;
  }
  .message-input-action {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin-right: 0.5rem;
  }
  .message-send {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin-left: 0.5rem;
  }
  body.login-page {
    padding: 10px;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
  }
  body {
    padding: 15px;
  }
  .login-container {
    flex: 0 0 auto;
    max-width: 100%;
    width: 100%;
    border-radius: var(--border-radius-card);
    margin: 10px auto 20px;
    min-height: 0;
    max-height: none;
    min-width: 0;
    overflow-x: hidden;
  }
  .login-form,
  .login-image {
    min-width: 0;
  }
  .login-form {
    max-width: none;
    padding: 25px 20px 40px;
  }
  .logo {
    justify-content: center;
    margin-bottom: 20px;
  }
  .login-page h1,
  .login-page h2.login-welcome {
    font-size: 1.375rem;   /* hero still dominant on mobile */
    text-align: center;
  }
  h1 {
    font-size: 24px;
    text-align: center;
  }
  .login-page .subtitle,
  .login-subtitle {
    text-align: center;
    margin-bottom: 20px;
  }
  .subtitle {
    text-align: center;
    margin-bottom: 20px;
  }
  .login-page .login-brand-tagline {
    text-align: center;
  }
  .login-form-group {
    margin-bottom: var(--spacing-lg);
  }
  .form-floating {
    margin-bottom: 15px;
  }
  .login-page .login-input.form-control,
  .login-page .form-control {
    height: 50px;
    min-height: 48px;
    padding: 12px 14px;
    font-size: 16px;
  }
  .form-control {
    height: 50px;
    min-height: 48px;
    padding: 12px 14px;
  }
  .login-btn {
    padding: 12px 16px;
    min-height: 48px;
    font-size: 1rem;
  }
  .login-image .hr-title {
    font-size: 1.35rem;
    text-align: center;
  }
  .login-image .hr-subtitle {
    font-size: 0.875rem;
    text-align: center;
  }
  .login-image .hr-features-intro {
    font-size: 0.8125rem;
    text-align: center;
  }
  .login-image .hr-card-info h3,
  .login-image .hr-card-info .card-content p {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  .login-image .login-trust-intro {
    text-align: center;
  }
  .login-image .login-trust-list {
    margin-left: auto;
    margin-right: auto;
  }
  .chat-header-status {
    flex-direction: column;
    align-items: flex-start;
  }
  .last-seen-info {
    margin-left: 0;
    margin-top: 0.125rem;
  }
  .contact-avatar .status-indicator {
    width: 10px;
    height: 10px;
    border-width: 1px;
  }
  .message-avatar .status-indicator {
    width: 8px;
    height: 8px;
    border-width: 1px;
  }
  .user-avatar .status-indicator {
    width: 9px;
    height: 9px;
    border-width: 1px;
  }
  .tox .tox-toolbar__primary {
    flex-wrap: wrap !important;
  }
  .tox-toolbar__group {
    margin: 0 !important;
  }
  .tox .tox-tbtn {
    min-width: 44px !important;
    min-height: 44px !important;
    width: 44px !important;
    height: 44px !important;
  }
  .rich-text-container .message-input-actions {
    padding: 4px;
  }
  .avatar-group-1,
  .avatar-group-2,
  .avatar-group-3,
  .avatar-group-4,
  .avatar-group-5,
  .avatar-group-6,
  .avatar-group-7,
  .avatar-group-8 {
    transform: none;
  }
  .chat-contact:hover .avatar-group-1,
  .chat-contact:hover .avatar-group-2,
  .chat-contact:hover .avatar-group-3,
  .chat-contact:hover .avatar-group-4,
  .chat-contact:hover .avatar-group-5,
  .chat-contact:hover .avatar-group-6,
  .chat-contact:hover .avatar-group-7,
  .chat-contact:hover .avatar-group-8 {
    transform: none;
    box-shadow: none;
  }
  .filter-tab span {
    display: inline;
  }
  /* Search responsive */
  .search-dropdown {
    max-height: 70vh;
    border-radius: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  }
  .search-results-list {
    max-height: 50vh;
  }
  .search-clear-btn {
    width: 32px;
    height: 32px;
    right: 10px;
  }
  .search-result-item {
    padding: 15px;
    font-size: 16px;
    min-height: 70px;
  }
  .result-title {
    font-size: 0.95rem;
  }
  .filter-tab {
    padding: 14px 8px;
    font-size: 0.8rem;
  }
  .no-results-icon {
    font-size: 40px;
  }
  .no-results-text h4 {
    font-size: 1rem;
  }
  .thread-panel {
    max-width: 100vw;
    width: 100vw;
    right: 0;
    left: 0;
  }
  .thread-overlay {
    display: block !important;
  }
}

/* Extra Small Devices (Portrait Phones, less than 576px) */
@media (max-width: 576px) {
  .topbar {
    padding: 0.5rem 1rem;
  }
  .chat-header {
    padding: 0.75rem;
  }
  .chat-body {
    padding: 0.75rem;
  }
  .chat-footer {
    padding: 0.75rem;
  }
  .message-content {
    max-width: 85%;
  }
  .chat-contacts {
    max-height: 250px;
  }
  .chat-contact {
    padding: 0.625rem;
  }
  .app-grid {
    grid-template-columns: 1fr;
  }
  .chat-header-actions > * {
    margin-left: 0.25rem;
  }
  .chat-header-action {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  .chat-header-actions {
    gap: 0.5rem;
  }
  .threaded-replies {
    margin-left: 1.5rem;
    padding-left: 0.5rem;
  }
  .login-form {
    padding: 20px;
  }
  .login-form-inner {
    max-width: 100%;
  }
  .login-page .login-welcome {
    font-size: 1.25rem;
  }
  .login-page .login-brand-tagline {
    font-size: 0.75rem;
    padding-left: 0;
  }
  .login-page .subtitle,
  .login-subtitle {
    font-size: 0.875rem;
  }
  .login-page .login-input.form-control,
  .login-page .form-control {
    min-height: 48px;
    padding: 12px 14px;
  }
  .login-page .login-btn {
    min-height: 48px;
  }
  .login-remember-row {
    flex-wrap: wrap;
    gap: 10px;
  }
  .login-page .login-remember-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .login-page .login-remember-row .forgot-password {
    align-self: flex-start;
  }
  .logo-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  .logo-text {
    font-size: 18px;
  }
  .d-flex.align-items-center.justify-content-between {
    flex-direction: column;
    align-items: flex-start;
  }
  .form-check {
    margin-bottom: 10px;
  }
  .login-image {
    padding: 20px 16px;
  }
  .hr-title {
    font-size: 20px;
  }
  .login-image .hr-title {
    font-size: 1rem;
  }
  .hr-subtitle {
    font-size: 14px;
  }
  .login-image .hr-subtitle {
    font-size: 0.8125rem;
  }
  .login-image .hr-features-intro {
    font-size: 0.75rem;
  }
  .login-image .hr-card-info {
    padding: 8px 10px;
  }
  .login-image .hr-card-info h3 {
    font-size: 0.75rem;
  }
  .login-image .hr-card-info .card-content p {
    font-size: 0.6875rem;
  }
  .chat-header-info {
    min-width: 0;
    flex: 1;
  }
  .chat-header-name {
    font-size: 0.875rem;
    max-width: 150px;
  }
  .chat-header-status {
    font-size: 0.7rem;
  }
  .last-seen-info {
    font-size: 0.65rem;
  }
  .contact-avatar .status-indicator,
  .message-avatar .status-indicator,
  .user-avatar .status-indicator {
    border-width: 1px;
  }
  .tox .tox-toolbar__primary {
    display: flex;
    flex-wrap: wrap !important;
  }
  .tox-toolbar__group {
    flex-wrap: wrap !important;
  }
  .tox .tox-tbtn {
    height: 44px !important;
    width: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
  .editor-info {
    font-size: 10px;
  }
  /* Search mobile responsive */
  .search-dropdown {
    max-height: 75vh;
  }
  .search-results-list {
    max-height: 55vh;
  }
  .search-status {
    padding: 6px 12px;
    font-size: 0.7rem;
  }
  .search-result-item {
    padding: 12px;
    min-height: 64px;
  }
  .result-title {
    font-size: 0.9rem;
  }
  .suggestions-header {
    display: none;
  }
  .suggestion-item {
    padding: 14px 16px;
    min-height: 50px;
  }
}

/* Very Small Devices (Small Phones, less than 400px) */
@media (max-width: 400px) {
  .topbar,
  .chat-header,
  .chat-body,
  .chat-footer {
    padding: 0.5rem;
  }
  .message-content {
    max-width: 95%;
  }
  .search-dropdown {
    max-height: calc(100vh - 200px);
    width: calc(100vw - 20px);
    left: 10px;
    right: 10px;
  }
  .message-avatar {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 600;
      font-size: 0.75rem;
      flex-shrink: 0;
      position: relative;
  }
  .chat-header-action {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 0.875rem;
  }
  .login-form {
    padding: 15px;
  }
  .login-page .login-welcome {
    font-size: 1.125rem;   /* hero on very small */
  }
  .login-page .login-brand-tagline {
    font-size: 0.625rem;
  }
  .login-page .subtitle,
  .login-subtitle {
    font-size: 0.8125rem;
  }
  .login-page .login-input.form-control,
  .login-page .form-control {
    height: 44px;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 16px;
  }
  .login-page .login-btn {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 0.9375rem;
  }
  .logo {
    margin-bottom: 15px;
  }
  .logo-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  .logo-text {
    font-size: 16px;
  }
  h1 {
    font-size: 22px;
  }
  .login-page h1.hr-title {
    font-size: 1.125rem;
  }
  .subtitle {
    font-size: 14px;
  }
  .form-control {
    height: 44px;
    min-height: 44px;
    padding: 8px 10px;
  }
  .login-image {
    padding: 16px 12px;
  }
  .login-image .hr-title {
    font-size: 1.125rem;
  }
  .login-image .hr-subtitle {
    font-size: 0.75rem;
  }
  .login-image .hr-features-intro {
    font-size: 0.6875rem;
  }
  .hr-cards {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .hr-card {
    min-width: 0;
  }
  .login-image .hr-card-info {
    padding: 6px 8px;
  }
  .login-image .hr-card-info h3 {
    font-size: 0.6875rem;
  }
  .login-image .hr-card-info .card-content p {
    font-size: 0.625rem;
  }
  .login-image .login-trust-intro {
    font-size: 0.625rem;
  }
  .login-image .login-trust-list li {
    font-size: 0.75rem;
  }
}

/* ======================================
   ACCESSIBILITY & THEME SUPPORT
   ====================================== */

/* Better focus management for accessibility */
.search-result-item:focus,
.suggestion-item:focus,
.filter-tab:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.filter-tab:active {
  transform: scale(0.98);
}

.suggestion-item:active {
  background: var(--primary-bg);
}

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
  :root {
    --search-bg: #2d3748;
    --search-border: #4a5568;
    --search-text: #e2e8f0;
    --search-highlight-bg: #553c18;
    --search-highlight-text: #f6e05e;
  }
  
  .search-suggestions {
    background-color: var(--search-bg);
    border-color: var(--search-border);
    color: var(--search-text);
  }
  
  .search-highlight {
    background-color: var(--search-highlight-bg);
    color: var(--search-highlight-text);
  }
  
  .no-results-icon {
    color: #4a5568;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .search-highlight {
    background-color: #ffff00;
    color: #000000;
    border: 1px solid #000000;
  }
  
  .search-suggestion-item:hover,
  .search-suggestion-item.selected {
    background-color: #0066cc;
    color: #ffffff;
  }
  
  .chat-contact.search-result {
    border-left-width: 6px;
    border-left-color: #000000;
  }
}

/* Reduce Motion for Accessibility */
@media (prefers-reduced-motion: reduce) {
  .search-suggestions,
  .search-clear-btn,
  .search-result,
  .search-highlight,
  .no-search-results {
    animation: none;
    transition: none;
  }
  
  .no-results-icon {
    animation: none;
  }
}

/* Print Styles */
@media print {
  .search-suggestions,
  .search-clear-btn,
  .search-status {
    display: none !important;
  }
  
  .search-highlight {
    background-color: #ffffcc;
    color: #000000;
    border: 1px solid #cccccc;
  }
}

.related-group-result {
    background-color: rgba(30, 193, 170, 0.05); /* Slight background tint */
    border-left: 2px solid #1ec1aa; /* Left border accent */
}

.related-group-result:hover {
    background-color: rgba(30, 193, 170, 0.1); /* Darker on hover */
}

/* ======================================
   UTILITY CLASSES
   ====================================== */

/* Display utilities */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }

/* Text utilities */
.text-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.text-center { text-align: center !important; }
.text-primary { color: var(--primary) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-sm { font-size: 0.875rem !important; }
.text-xs { font-size: 0.75rem !important; }

/* Font weight utilities */
.font-weight-bold { font-weight: 700 !important; }
.font-weight-semibold { font-weight: 600 !important; }
.font-weight-medium { font-weight: 500 !important; }

/* Spacing utilities */
.m-0 { margin: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.ms-auto { margin-left: auto !important; }
.p-0 { padding: 0 !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }

/* Size utilities */
.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

/* Border utilities */
.rounded { border-radius: var(--border-radius) !important; }
.rounded-circle { border-radius: 50% !important; }

/* Background utilities */
.bg-primary { background-color: var(--primary) !important; }
.bg-danger { background-color: var(--danger) !important; }
.bg-light { background-color: var(--light) !important; }

/* Shadow utilities */
.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow { box-shadow: var(--shadow) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }

/* Touch Target Utilities - Ensure all interactive elements meet 44px minimum */
button:not(.btn-sm):not(.btn-xs),
.button:not(.btn-sm):not(.btn-xs),
.btn:not(.btn-sm):not(.btn-xs),
a.btn:not(.btn-sm):not(.btn-xs),
input[type="button"]:not(.btn-sm):not(.btn-xs),
input[type="submit"]:not(.btn-sm):not(.btn-xs) {
  min-height: 44px;
  min-width: 44px;
}

@media (max-width: 768px) {
  button,
  .button,
  .btn,
  a.btn,
  input[type="button"],
  input[type="submit"],
  .btn-sm {
    min-height: 44px;
    min-width: 44px;
  }
}

/* 
   HR Management System - CSS Updates
   Add these styles to your hrstyle.css file
*/

/* Repositioned status indicator for profile avatar */
    .profile-avatar {
        position: relative;
    }

    .profile-avatar .status-indicator {
        position: absolute;
        bottom: 5px;
        right: 5px;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        border: 2px solid white;
        z-index: 10;
    }

    /* Status indicators */
    .status-indicator {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        border: 2px solid var(--white);
    }

    .status-online { background-color: var(--status-online); }
    .status-offline { background-color: var(--status-offline); }
    .status-away { background-color: var(--status-away); }
    .status-busy { background-color: var(--status-busy); }
    .status-dnd { background-color: var(--status-dnd); }

    /* Profile card improvements */
    .card {
        border-radius: var(--border-radius);
        border: none;
        box-shadow: var(--shadow);
        margin-bottom: 1.5rem;
        overflow: hidden;
    }

    .card-header {
        background-color: var(--white);
        border-bottom: 1px solid var(--gray-200);
        padding: 1rem;
        font-weight: 600;
    }

    .card-body {
        padding: 1.5rem;
    }

    .profile-cover-bg {
        background: linear-gradient(135deg, var(--primary), var(--secondary));
        height: 120px;
        border-radius: var(--border-radius) var(--border-radius) 0 0;
    }

    .profile-avatar-container {
        position: relative;
        margin-bottom: 1.5rem;
    }

    .profile-avatar {
        width: 140px;
        height: 140px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 2.5rem;
        font-weight: 600;
        border: 5px solid white;
        margin-top: -70px;
        margin-left: auto;
        margin-right: auto;
        position: relative;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    }

    /* Avatar gallery */
    .avatar-item {
        width: 100%;
        aspect-ratio: 1;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-weight: 600;
        transition: all 0.2s ease;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
        margin-bottom: 10px;
    }

    .avatar-item:hover {
        transform: scale(1.05);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    }

    /* Profile quick info */
    .profile-quick-info {
        background-color: var(--gray-100);
        border-radius: var(--border-radius);
        margin: 0 -24px 1.5rem;
    }

    .profile-quick-info .col-4 {
        padding: 12px 0;
    }

    .profile-quick-info h6 {
        font-weight: 600;
        color: var(--primary);
        margin-bottom: 0.25rem;
    }

    .profile-quick-info small {
        font-size: 0.8rem;
        color: var(--text-muted);
    }

    /* Improved form controls */
    .form-label {
        font-weight: 500;
        margin-bottom: 0.5rem;
        color: var(--gray-700);
    }

    .form-control, .form-select {
        border-radius: var(--border-radius);
        padding: 0.75rem 1rem;
        border: 1px solid var(--gray-300);
        transition: all 0.2s ease;
    }

    .form-control:focus, .form-select:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 0.25rem rgba(30, 193, 170, 0.1);
    }

    /* Button styling */
    .btn-primary {
        background-color: var(--primary);
        border-color: var(--primary);
    }

    .btn-primary:hover {
        background-color: var(--primary-dark);
        border-color: var(--primary-dark);
    }

/* Table styling */
.table-responsive {
        border-radius: var(--border-radius);
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
    }
    
.table-responsive table {
    min-width: 100%;
    width: max-content;
}

    .table {
        margin-bottom: 0;
    }

    .table thead th {
        font-weight: 600;
        border-top: none;
        background-color: var(--gray-100);
    }

    .table tbody td {
        vertical-align: middle;
    }

    /* Toasts */
    .toast {
        border: none;
        border-radius: var(--border-radius);
        box-shadow: var(--shadow-lg);
    }

    .toast-header {
        border-bottom: none;
    }

/* Modals */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 100%;
    overflow-x: hidden;
}

.modal-dialog {
    max-width: 90%;
    margin: 1rem auto;
}

.modal-body {
    max-height: calc(90vh - 200px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

    .modal-header {
        border-bottom: 1px solid var(--gray-200);
        background-color: var(--white);
    }

    .modal-footer {
        border-top: 1px solid var(--gray-200);
    }
    
    /* User avatar styles */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary, #3f51b5); /* Default primary color if variable not defined */
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    position: relative;
    overflow: hidden; /* Ensures image stays within circle */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Avatar image - shown when user has an avatar */
.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Makes image cover entire circle */
    position: absolute;
    top: 0;
    left: 0;
}

/* Status indicator - online/offline dot */
.status-indicator {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid white;
    bottom: 0;
    right: 0;
    z-index: 2; /* Ensures it displays above the avatar */
}

.status-online {
    background-color: #4CAF50; /* Green for online */
}

.status-away {
    background-color: #FFC107; /* Yellow for away */
}

.status-busy {
    background-color: #F44336; /* Red for busy/do not disturb */
}

.status-offline {
    background-color: #9E9E9E; /* Grey for offline */
}

/* Animation for image loading */
@keyframes avatarFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.user-avatar img {
    animation: avatarFadeIn 0.3s ease-in-out;
}

/* Sound Settings Styling */
.sound-title {
    font-weight: 600;
    margin-bottom: 15px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
}

.volume-section {
    background-color: var(--gray-100);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
}

.volume-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.volume-title {
    font-weight: 600;
    font-size: 1rem;
    margin: 0;
    display: flex;
    align-items: center;
}

.volume-value {
    font-weight: 600;
    color: var(--primary);
    width: 45px;
    text-align: center;
    font-size: 1rem;
}

.volume-slider-container {
    position: relative;
    padding: 0 10px;
}

.volume-slider {
    position: relative;
    z-index: 2;
}

.volume-slider-progress {
    position: absolute;
    height: 8px;
    background-color: var(--primary);
    border-radius: 4px;
    pointer-events: none;
    top: 50%;
    transform: translateY(-50%);
    left: 10px;
    width: 50%; /* Initial value, will be updated with JS */
}

.volume-level-indicators {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    padding: 0 10px;
}

.volume-level-indicator {
    font-size: 0.75rem;
    color: var(--gray-600);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.volume-level-indicator i {
    margin-bottom: 3px;
}

.dnd-section {
    background-color: var(--gray-100);
    border-radius: 12px;
    padding: 20px;
}

.dnd-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0;
    display: flex;
    align-items: center;
}

.custom-select {
    height: 45px;
    border-radius: 8px;
    border: 1px solid var(--gray-300);
    padding: 0 15px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.custom-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem rgba(30, 193, 170, 0.1);
}

.time-input-container .input-group-text {
    background-color: var(--primary-bg);
    color: var(--primary);
    border-color: var(--gray-300);
}

.form-range::-webkit-slider-thumb {
    background-color: var(--primary);
}
.form-range::-moz-range-thumb {
    background-color: var(--primary);
}
.form-range::-ms-thumb {
    background-color: var(--primary);
}

/* Form switch customization */
.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}
/* TinyMCE specific fixes */
.tox.tox-tinymce {
    border: none !important;
    background-color: #fff;
    min-height: 100px !important;
}

.tox .tox-edit-area {
    border-top: 1px solid #e9ecef !important;
}

.tox .tox-edit-area__iframe {
    background-color: #fff !important;
}

.tox .tox-toolbar__primary {
    background-color: #f8f9fa !important;
    border-top: 1px solid #e9ecef !important;
}

.tox .tox-tbtn {
    height: 28px !important;
    width: 28px !important;
    margin: 0 1px !important;
}

.tox .tox-tbtn svg {
    height: 16px !important;
    width: 16px !important;
}

/* Message status container */
.message-status {
  display: flex;
  align-items: center;
  margin-left: 4px;
  transition: all 0.2s ease;
}

/* Base tick style */
.message-status i {
  font-size: 12px;
  color: var(--gray-500);
  opacity: 0.8;
  transition: all 0.3s ease;
}

/* Single tick (sent) */
.message-status .fa-check {
  color: var(--gray-500);
}

/* Double tick (delivered) */
.message-status .fa-check-double {
  color: var(--gray-500);
}

/* Double tick with blue color (read) */
.message-status .fa-check-double.status-read,
.message-status .fa-check-double.text-primary {
  color: #0084ff !important; /* WhatsApp blue for read receipts */
  opacity: 1;
}

/* Group Chat Read Receipts: Blue ticks when all members read */
.message-status .text-primary {
  color: #0084ff !important; /* WhatsApp blue */
}

/* Animation for status change */
@keyframes statusChange {
  0% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.8;
  }
}

/* Apply animation when status changes */
.message-status i.status-changing {
  animation: statusChange 0.3s ease-out;
}

/* Position adjustments for message meta containing status */
.message-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  font-size: 0.75rem;
  color: var(--gray-500);
  justify-content: flex-end; /* Align items to the right for outgoing messages */
}

/* Make status more visible on hover */
.chat-message:hover .message-status i {
  opacity: 1;
}

/* Adjust time and status spacing for better alignment */
.message-time {
  margin-right: 3px;
}

/* Styling for pending message status (while sending) */
.message-status .fa-clock {
  color: var(--gray-400);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.5;
  }
}

/* Fix for badge pulse animation when new message appears */
.badge-pulse {
  animation: badgePulse 0.5s ease;
}

/* Message Info Modal (Read Receipts) */
#messageInfoModal .modal-content {
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

#messageInfoModal .modal-header {
  border-bottom: 1px solid #e9ecef;
  padding: 1rem 1.5rem;
}

#messageInfoModal .modal-title {
  font-weight: 600;
  color: #333;
}

#messageInfoModal .modal-body {
  padding: 1.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

.read-receipts-list {
  margin: 0;
}

.receipt-section {
  margin-bottom: 1.5rem;
}

.receipt-section:last-child {
  margin-bottom: 0;
}

.receipt-section h6 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e9ecef;
}

.receipt-section .list-group {
  border-radius: 6px;
  overflow: hidden;
}

.receipt-section .list-group-item {
  border: none;
  border-bottom: 1px solid #f0f0f0;
  padding: 0.75rem 1rem;
  transition: background-color 0.2s ease;
}

.receipt-section .list-group-item:hover {
  background-color: #f8f9fa;
}

.receipt-section .list-group-item:last-child {
  border-bottom: none;
}

.receipt-section .list-group-item img {
  object-fit: cover;
}

.receipt-section .font-weight-medium {
  font-weight: 500;
  color: #333;
  margin-bottom: 0.25rem;
}

.receipt-section .text-muted {
  font-size: 0.8125rem;
  color: #6c757d;
}

/* Make message status clickable */
.message-status {
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.message-status:hover {
  opacity: 0.8;
}

/* Modal backdrop */
.modal.show {
  display: block;
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040;
  width: 100vw;
  height: 100vh;
  background-color: #000;
  opacity: 0.5;
}

body.modal-open {
  overflow: hidden;
}

@keyframes badgePulse {
  0% {
    transform: scale(0.8);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}