/* ==========================================================================
   GLYDE® Buddy Pro - Main Stylesheet
   Refactored for maintainability, consistency, and performance.
   Based on Microsoft Fluent 2 Design System.
   ========================================================================== */

/* -------------------------------------------------------------------------- */
/* 1. Variables & Design Tokens                                               */
/* -------------------------------------------------------------------------- */
:root {
  /* -- Typography -- */
  --font-family: 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Roboto',
    'Helvetica Neue', sans-serif;

  --font-size-100: 12px;
  --font-size-200: 14px; /* Base Body */
  --font-size-300: 16px; /* Headers */
  --font-size-400: 20px; /* Titles */
  --font-size-500: 24px;
  --font-size-600: 28px;

  --line-height-100: 16px;
  --line-height-200: 20px;
  --line-height-300: 24px;
  --line-height-400: 28px;
  --line-height-500: 32px;
  --line-height-600: 36px;

  /* -- Spacing (8px grid) -- */
  --spacing-xs: 4px;
  --spacing-s: 8px;
  --spacing-m: 12px;
  --spacing-l: 16px;
  --spacing-xl: 20px;
  --spacing-xxl: 24px;
  --spacing-xxxl: 32px;
  --spacing-huge: 40px;
  --spacing-massive: 48px;

  /* -- Colors: Neutrals (Fluent 2) -- */
  --colorNeutralForeground1: #242424;
  --colorNeutralForeground2: #424242;
  --colorNeutralForeground3: #616161;
  --colorNeutralForeground4: #808080;

  --colorNeutralBackground1: #ffffff;
  --colorNeutralBackground1Hover: #f5f5f5;
  --colorNeutralBackground1Pressed: #ebebeb;
  --colorNeutralBackground1Selected: #ebebeb;
  --colorNeutralBackground2: #fafafa;
  --colorNeutralBackground3: #f5f5f5;
  --colorNeutralBackground4: #ebebeb;

  --colorNeutralStroke1: #d1d1d1;
  --colorNeutralStroke2: #e0e0e0;

  /* Extended Neutral Palette */
  --color-neutral-grey-4: #fafafa;
  --color-neutral-grey-8: #f5f5f5;
  --color-neutral-grey-12: #ebebeb;
  --color-neutral-grey-16: #e0e0e0;
  --color-neutral-grey-20: #d1d1d1;
  --color-neutral-grey-24: #c7c7c7;
  --color-neutral-grey-28: #b3b3b3;
  --color-neutral-grey-32: #a6a6a6;
  --color-neutral-grey-36: #999999;
  --color-neutral-grey-40: #8a8a8a;
  --color-neutral-grey-44: #7a7a7a;
  --color-neutral-grey-48: #6b6b6b;
  --color-neutral-grey-52: #616161;
  --color-neutral-grey-56: #5c5c5c;
  --color-neutral-grey-60: #525252;
  --color-neutral-grey-64: #474747;
  --color-neutral-grey-68: #3d3d3d;
  --color-neutral-grey-72: #333333;
  --color-neutral-grey-76: #292929;
  --color-neutral-grey-80: #242424;
  --color-neutral-grey-84: #1f1f1f;
  --color-neutral-grey-88: #1a1a1a;
  --color-neutral-grey-92: #0f0f0f;
  --color-neutral-grey-96: #0a0a0a;

  /* -- Colors: Brand & Accents -- */
  --color-brand-primary: #6264a7; /* Teams Purple */
  --color-brand-primary-hover: #7b7dbe;
  --color-brand-primary-pressed: #4e5085;
  --color-brand-light: #e7e7f4;
  --color-brand-lighter: #f4f4fb;
  --color-brand-vibrant: #8b8dd6;
  --color-brand-glow: rgba(98, 100, 167, 0.3);

  /* Gradients */
  --gradient-brand: linear-gradient(135deg, #6264a7 0%, #8b8dd6 100%);
  --gradient-brand-hover: linear-gradient(135deg, #7b7dbe 0%, #9c9ee6 100%);
  --gradient-subtle: linear-gradient(180deg, rgba(98, 100, 167, 0.05) 0%, rgba(98, 100, 167, 0) 100%);
  --gradient-card-shine: linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0) 50%);

  /* Semantic Colors */
  --color-success: #10a210;
  --color-success-light: #d4f5d4;
  --color-success-vibrant: #13cf13;

  --color-warning: #f7630c;
  --color-warning-light: #ffe7d4;
  --color-warning-vibrant: #ff8c42;

  --color-danger: #e73c3e;
  --color-danger-light: #ffe0e0;
  --color-danger-vibrant: #ff5a5c;

  --color-info: #0086f0;
  --color-info-light: #d4e8ff;
  --color-info-vibrant: #4a9eff;

  /* Accent Colors */
  --color-accent-purple: #8b8dd6;
  --color-accent-blue: #4a9eff;
  --color-accent-teal: #00d4aa;
  --color-accent-orange: #ff8c42;

  /* -- Surface & Layout -- */
  --color-surface-primary: var(--colorNeutralBackground1);
  --color-surface-secondary: var(--color-neutral-grey-4);
  --color-surface-tertiary: var(--color-neutral-grey-8);
  --color-background: var(--color-neutral-grey-4);

  --card-background: #ffffff;
  --card-border: 1px solid rgba(16, 24, 40, 0.08);

  /* -- Text Colors -- */
  --color-text-primary: var(--color-neutral-grey-84);
  --color-text-secondary: var(--color-neutral-grey-60);
  --color-text-tertiary: var(--color-neutral-grey-48);

  /* -- Shadows -- */
  --shadow-2: 0px 0.3px 0.9px rgba(0, 0, 0, 0.1), 0px 1.6px 3.6px rgba(0, 0, 0, 0.13);
  --shadow-4: 0px 0.3px 0.9px rgba(0, 0, 0, 0.1), 0px 1.6px 3.6px rgba(0, 0, 0, 0.13),
    0px 3.6px 7.2px rgba(0, 0, 0, 0.16);
  --shadow-8: 0px 3.2px 7.2px rgba(0, 0, 0, 0.16), 0px 14.4px 28.8px rgba(0, 0, 0, 0.22);
  --shadow-16: 0px 6.4px 14.4px rgba(0, 0, 0, 0.18), 0px 28.8px 57.6px rgba(0, 0, 0, 0.28);
  --shadow-28: 0px 12.8px 28.8px rgba(0, 0, 0, 0.26), 0px 57.6px 115.2px rgba(0, 0, 0, 0.35);

  --shadow-brand: 0px 8px 24px rgba(98, 100, 167, 0.25), 0px 2px 8px rgba(98, 100, 167, 0.15);
  --shadow-brand-strong: 0px 12px 32px rgba(98, 100, 167, 0.35), 0px 4px 12px rgba(98, 100, 167, 0.25);
  --shadow-success: 0px 4px 16px rgba(16, 162, 16, 0.2);
  --shadow-hover: 0px 8px 24px rgba(0, 0, 0, 0.15), 0px 2px 8px rgba(98, 100, 167, 0.1);

  /* -- Borders -- */
  --border-radius-small: 4px;
  --border-radius-medium: 8px;
  --border-radius-large: 12px;
  --border-radius-xlarge: 16px;
  --border-radius-circular: 50%;
  --border-radius-pill: 24px;

  /* -- Animations -- */
  --duration-fast: 100ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
  --ease-fluent: cubic-bezier(0.33, 0, 0.67, 1);

  /* -- Legacy/Aliases (Maintained for backward compatibility) -- */
  --neutralForeground1: var(--colorNeutralForeground1);
  --neutralForeground2: var(--colorNeutralForeground2);
  --neutralForeground3: var(--colorNeutralForeground3);
  --neutralBackground1: var(--colorNeutralBackground1);
  --neutralBackground2: var(--colorNeutralBackground2);
  --neutralStroke1: var(--colorNeutralStroke1);
  --neutralStroke2: var(--colorNeutralStroke2);
  --brandBackground: var(--color-brand-primary);
  --color-white: #ffffff;
}

/* -------------------------------------------------------------------------- */
/* 2. Reset & Base Styles                                                     */
/* -------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
  font-family: var(--font-family);
}

body {
  margin: 0;
  font-weight: 400;
  color: var(--colorNeutralForeground1);
  background-color: var(--colorNeutralBackground1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--colorNeutralBackground3);
}
::-webkit-scrollbar-thumb {
  background: var(--colorNeutralStroke1);
  border-radius: var(--border-radius-small);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--colorNeutralForeground3);
}

/* Hide scrollbars for specific containers while keeping functionality */
.glyde-conversation-list,
.glyde-chat-messages,
.glyde-right-pane,
.glyde-center-pane {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}
.glyde-conversation-list::-webkit-scrollbar,
.glyde-chat-messages::-webkit-scrollbar,
.glyde-right-pane::-webkit-scrollbar,
.glyde-center-pane::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Opera */
}

/* -------------------------------------------------------------------------- */
/* 3. Layout Containers                                                       */
/* -------------------------------------------------------------------------- */
.glyde-app-container {
  margin: 4em auto;
  max-width: 1200px;
}

/* Main Panes Configuration */
.glyde-left-pane,
.glyde-center-pane,
.glyde-right-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.glyde-left-pane {
  flex: 0 0 var(--pane-left, 25%);
  min-width: 300px;
  border-right: 1px solid var(--neutralStroke2);
  background-color: var(--colorNeutralBackground2);
  height: 100%;
}

.glyde-center-pane {
  flex: 0 0 var(--pane-center, 50%);
  background-color: var(--color-surface-primary);
  position: relative;
}

.glyde-right-pane {
  flex: 0 0 var(--pane-right, 25%);
  border-left: 1px solid var(--color-neutral-grey-16);
  background: linear-gradient(180deg, #eef2ff 0%, #ffffff 100%); /* Match welcome-right.html */
  overflow-y: auto;
}

.glyde-resizer {
  /* Resizer style hook for JS */
  flex-basis: 0;
  z-index: 100;
}

/* -------------------------------------------------------------------------- */
/* 4. Modal Styles                                                            */
/* -------------------------------------------------------------------------- */
#glyde-chat-modal {
  position: fixed;
  top: 50px;
  left: 50px;
  width: 90vw;
  height: 80vh;
  background: linear-gradient(180deg, var(--colorNeutralBackground1) 0%, rgba(245, 245, 245, 0.5) 100%);
  display: flex;
  flex-direction: column;
  border-radius: var(--border-radius-large);
  box-shadow: var(--shadow-28);
  z-index: 10001;
  overflow: hidden;
  border: 1px solid var(--colorNeutralStroke2);
  animation: fluent-scale-in var(--duration-normal) var(--ease-fluent);
}

/* Decorative top bar */
#glyde-chat-modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0; /* Hidden by default or specific height if needed */
  background: var(--gradient-brand);
}

/* Visibility States */
#glyde-chat-modal.hidden {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

#glyde-chat-modal.fullscreen:not(.hidden) {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Fullscreen Mode (Teams) */
.glyde-modal.fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  transform: none !important;
  animation: none !important;
}

.glyde-modal.fullscreen .glyde-modal-body {
  height: 100%;
  width: 100%;
}

/* Adjust pane sizes in fullscreen if needed */
.glyde-modal.fullscreen .glyde-left-pane {
  flex: 0 0 var(--pane-left, 25%);
  height: 100vh;
}
.glyde-modal.fullscreen .glyde-center-pane {
  flex: 0 0 var(--pane-center, 50%);
}
.glyde-modal.fullscreen .glyde-right-pane {
  flex: 0 0 var(--pane-right, 25%);
}

.glyde-modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Modal Header */
.glyde-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-l) var(--spacing-xl);
  cursor: move;
  font-size: var(--font-size-300);
  font-weight: 600;
  background: var(--gradient-brand);
  color: var(--color-white);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 8px rgba(98, 100, 167, 0.2);
  position: relative;
}

.glyde-modal-title {
  font-size: var(--font-size-400);
  font-weight: 600;
}

/* -------------------------------------------------------------------------- */
/* 5. Common UI Elements (Buttons, Pills, Headers)                            */
/* -------------------------------------------------------------------------- */
/* Buttons */
.glyde-close-btn,
.glyde-header-btn {
  background: none;
  border: none;
  color: var(--color-white);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--border-radius-small);
  transition: background-color var(--duration-fast) var(--ease-fluent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.glyde-close-btn:hover,
.glyde-header-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.glyde-header-btn.hidden {
  display: none;
}

/* Section Headers (Floating Pill Style) */
.glyde-pane-header {
  display: flex;
  flex-direction: column;
  margin: 12px 16px;
  color: var(--colorNeutralForeground1);
  padding: var(--spacing-l);
  background-color: rgba(255, 255, 255, 0.85); /* Semi-transparent acrylic */
  backdrop-filter: blur(10px); /* Acrylic blur effect */
  font-weight: 600;
  font-size: var(--font-size-300);
  line-height: var(--line-height-300);
  border-radius: var(--border-radius-pill);
  box-shadow: var(--shadow-8);
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.5); /* Subtle border for acrylic feel */
}

/* Left Pane Header Override */
.glyde-left-pane .glyde-pane-header {
  flex-shrink: 0;
  padding: 16px;
  border-radius: 0;
  margin: 0;
  box-shadow: none;
  background: linear-gradient(180deg, var(--colorNeutralBackground1) 0%, var(--colorNeutralBackground2) 100%);
  border-bottom: 1px solid var(--colorNeutralStroke2);
}

/* Center Chat Header Specifics */
#glyde-chat-header {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  min-height: 56px;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#candidate-name {
  font-size: 18px;
  font-weight: 600;
}

#talent-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--neutralStroke2);
}

/* Status Pills */
.screen-result-pill,
.message-type-pill,
.application-status-nested,
.glyde-conversation-secondary .status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
  text-align: center;
}

.screen-result-pill {
  padding: 4px 12px;
  font-size: var(--font-size-100);
  background-color: rgba(245, 245, 245, 0.7); /* Acrylic base */
  backdrop-filter: blur(4px); /* Acrylic blur */
  color: var(--colorNeutralForeground2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all var(--duration-fast) var(--ease-fluent);
  border: 1px solid rgba(0, 0, 0, 0.05); /* Acrylic border */
}
.screen-result-pill:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Status Colors */
.screen-result-pill.screen_result_positive,
.screen-result-pill.positive,
.internal {
  background-color: rgba(212, 245, 212, 0.7) !important; /* Acrylic success */
  color: var(--color-success-vibrant) !important;
  border-color: var(--color-success) !important;
}

.screen-result-pill.screen_result_negative,
.screen-result-pill.negative {
  background-color: rgba(255, 224, 224, 0.7) !important; /* Acrylic danger */
  color: var(--color-danger-vibrant) !important;
  border-color: var(--color-danger) !important;
}

.screen-result-pill.pending,
.screen-result-pill.incomplete,
.note-pill {
  background-color: rgba(255, 231, 212, 0.7) !important; /* Acrylic warning */
  color: var(--color-warning) !important;
  border-color: var(--color-warning) !important;
}

.email-pill {
  background-color: var(--color-brand-primary) !important;
  color: white !important;
}

.sms-pill {
  background-color: rgba(255, 255, 255, 0.25) !important;
  color: white !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  font-size: 9px !important;
  padding: 1px 6px !important;
}

.screen-chat-pill,
.info {
  background-color: var(--color-info) !important;
  color: white !important;
}

.glyde-separator {
  height: 1px;
  background-color: var(--color-neutral-grey-16);
  margin: 16px 0;
}

/* -------------------------------------------------------------------------- */
/* 6. Component: Conversation List                                            */
/* -------------------------------------------------------------------------- */
.glyde-conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px;
  margin: 0;
  list-style: none;
}

.glyde-conversation-item {
  position: relative;
  margin-bottom: 8px;
  cursor: pointer;
}

.glyde-buddy-item {
  margin-top: 12px;
}

.glyde-conversation-card {
  background: linear-gradient(180deg, var(--colorNeutralBackground1) 0%, rgba(255, 255, 255, 0.5) 100%);
  border-radius: var(--border-radius-medium);
  border: 1px solid var(--colorNeutralStroke2);
  padding: var(--spacing-m) var(--spacing-l);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-fluent);
  box-shadow: var(--shadow-2);
}

/* Hover Effect Line */
.glyde-conversation-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-brand);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-fluent);
}

.glyde-conversation-card:hover {
  background: linear-gradient(180deg, rgba(98, 100, 167, 0.03) 0%, rgba(255, 255, 255, 0.8) 100%);
  border-color: var(--color-brand-primary);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.glyde-conversation-card:hover::before {
  opacity: 1;
}

.glyde-conversation-item.active .glyde-conversation-card {
  border-color: var(--brandBackground);
  background-color: var(--brandBackground);
  color: var(--color-white);
}

.glyde-conversation-item.active .glyde-conversation-primary span,
.glyde-conversation-item.active .glyde-conversation-secondary {
  color: var(--color-white);
}

/* Content Layout */
.glyde-conversation-primary {
  display: flex;
  align-items: center;
  gap: 12px;
}

.glyde-conversation-primary img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--neutralStroke2);
}

.glyde-conversation-primary span.candidate_name {
  font-weight: 600;
  font-size: 14px;
  line-height: 20px;
  color: var(--neutralForeground1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.glyde-conversation-primary .conversation-date {
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-left: auto;
  color: var(--color-text-tertiary);
  gap: 4px;
}

.glyde-conversation-secondary {
  margin-top: 8px;
  color: var(--neutralForeground3);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Stacked Applications (Nested Cards) */
.glyde-stacked-applications {
  position: relative;
  margin-top: -12px;
}

.glyde-stacked-card {
  position: relative;
  background-color: var(--color-surface-primary);
  border: 1px solid var(--neutralStroke2);
  border-radius: 12px;
  padding: 8px 12px;
  margin-top: -4px;
  height: 32px;
  width: 97%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
  overflow: hidden;
}

.glyde-stacked-card .stacked-card-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  flex: 1;
  min-width: 0;
}

.glyde-stacked-card:hover {
  transform: scale(1.02);
  width: 95%;
  z-index: 10;
  box-shadow: var(--shadow-2);
}

.conversations-loading-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
}

.conversations-loading-spinner svg {
  animation: rotate 1s linear infinite;
  transform-origin: center;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.conversations-loading-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
}

.conversations-loading-spinner svg {
  animation: rotate 1s linear infinite;
  transform-origin: center;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.glyde-conversation-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--colorNeutralStroke2);
  border-radius: var(--border-radius-small);
  font-size: 14px;
  background-color: var(--colorNeutralBackground1);
  transition: all var(--duration-fast);
}

.glyde-conversation-search-input:focus {
  outline: none;
  border-color: var(--color-brand-vibrant);
  box-shadow: 0 0 0 3px rgba(98, 100, 167, 0.25);
}

/* -------------------------------------------------------------------------- */
/* 7. Component: Chat Area (Messages)                                         */
/* -------------------------------------------------------------------------- */
.glyde-chat-messages {
  padding: 20px 16px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--color-surface-primary);
  min-height: 0; /* Critical for nested flex scrolling */
}

/* Add this rule to prevent messages from squashing */
.glyde-chat-messages > * {
  flex-shrink: 0;
}

/* Unified History Card (Email, Notes, Screen Chat groups) */
.glyde-history-card,
.glyde-message.note,
.glyde-message.internal,
.email-message,
.screen-chat-group {
  display: block;
  margin: 12px 0;
  border: 1px solid var(--neutralStroke2);
  border-radius: 24px;
  background-color: var(--color-surface-primary);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  transition: all 0.2s ease;
}

.glyde-history-card:hover {
  box-shadow: var(--shadow-4);
}

.expanded {
  box-shadow: var(--shadow-8);
  border-color: var(--color-brand-primary);
}

/* Card Headers */
.email-message-header,
.screen-chat-header,
.glyde-message.note h2 {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.email-message-header .chevron,
.screen-chat-header .chevron {
  transition: transform 0.2s ease;
}

/* Fix email card chevron animation (was rotating shadow) */
.email-message-header .chevron.expanded,
.screen-chat-header .chevron.expanded,
.note-chevron.expanded {
  transform: rotate(180deg);
  background-color: rgba(0, 0, 0, 0.1);
}

.email-message-header {
  background-color: var(--color-brand-lighter);
  color: var(--color-brand-primary);
}
.screen-chat-header {
  background-color: var(--color-info-light);
  color: var(--color-info-vibrant);
}
.glyde-message.note h2 {
  background-color: var(--color-warning-light);
  color: var(--color-warning-vibrant);
  background-color: rgba(255, 248, 240, 0.85); /* Acrylic */
  backdrop-filter: blur(8px);
}

/* Dynamic Note Header Colors */
.glyde-message.note h2.header-positive {
  background-color: rgba(212, 245, 212, 0.7); /* Acrylic success */
  color: var(--color-success-vibrant);
}

.glyde-message.note h2.header-negative {
  background-color: rgba(255, 224, 224, 0.7); /* Acrylic danger */
  color: var(--color-danger-vibrant);
}

.glyde-message.note h2.header-pending {
  background-color: rgba(255, 231, 212, 0.7); /* Acrylic warning */
  color: var(--color-warning-vibrant);
}

.message-type-pill.note-pill {
  background-color: rgba(255, 248, 240, 0.85);
  color: var(--color-warning-vibrant);
  backdrop-filter: blur(4px);
  border: 1px solid var(--color-warning);
}

/* Card Body Content */
.email-message-content,
.note-content-body,
.screen-chat-messages {
  padding: 16px;
  background-color: white;
  display: none; /* Collapsed by default */
}

.email-message-content.expanded,
.note-content-body.expanded,
.screen-chat-messages.expanded,
.screen-chat-group.expanded .screen-chat-messages {
  display: block;
  max-height: 400px;
  overflow-y: auto;
}

/* Standard Chat Bubbles */
.glyde-message {
  display: flex;
  margin-bottom: 16px;
  align-items: flex-end;
}

.glyde-message.assistant {
  justify-content: flex-end;
} /* Me */
.message-content.assistant {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.glyde-message.candidate {
  justify-content: flex-start;
} /* Them */
.glyde-message.assistant.bot-message {
  justify-content: flex-start;
} /* Bot acting as user assistant */

.glyde-message-bubble {
  padding: 12px 16px;
  max-width: 80%;
  width: fit-content;
  font-size: 14px;
  line-height: 1.4;
}

.candidate-bubble {
  background: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%);
  color: var(--colorNeutralForeground1);
  border-radius: 18px 18px 18px 4px;
}

.assistant-bubble {
  background: var(--gradient-brand);
  color: white;
  border-radius: 18px 18px 4px 18px;
}

.avatar img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--neutralStroke2);
}

.message-timestamp {
  font-size: 10px;
  color: var(--color-text-tertiary);
  margin-top: 4px;
  text-align: right;
}

/* Chevrons */
.chevron,
.note-chevron {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease;
  margin-left: auto;
}
.chevron.expanded {
  transform: rotate(180deg);
  background-color: rgba(0, 0, 0, 0.1);
}

/* -------------------------------------------------------------------------- */
/* 8. Component: Input Area                                                   */
/* -------------------------------------------------------------------------- */
.glyde-chat-input {
  border-top: 1px solid var(--color-neutral-grey-16);
  background-color: var(--color-surface-primary);
  z-index: 10;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
  margin: 0 16px 12px;
  border-radius: 24px;
  overflow: hidden;
  flex-shrink: 0;
}

.glyde-tab-buttons {
  display: flex;
  padding: 12px 16px 0;
  gap: 8px;
}

.glyde-tab-button {
  flex: 1;
  padding: 4px 12px;
  background-color: var(--colorNeutralBackground1);
  border: 1px solid var(--colorNeutralStroke2);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--colorNeutralForeground2);
}

.glyde-tab-button:hover {
  background-color: var(--colorNeutralBackground1Hover);
}

.glyde-tab-button.active {
  background: var(--gradient-brand);
  color: white;
  border-color: transparent;
  font-weight: 600;
  box-shadow: var(--shadow-brand);
}
/* Contextual Active Tabs */
.glyde-tab-button.active[data-tab='notes'] {
  background: var(--color-warning);
}
.glyde-tab-button.active[data-tab='internal'] {
  background: var(--color-success);
}
.glyde-tab-button.active[data-tab='glyde'] {
  background: var(--color-info);
}

.glyde-tab-contents {
  padding: 16px;
  background-color: var(--color-surface-tertiary);
}

.glyde-tab-content {
  display: none;
}
.glyde-tab-content.active {
  display: block;
}

.glyde-tab-content textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid var(--colorNeutralStroke2);
  resize: none;
  background-color: white;
}

/* Contextual Input Colors */
.glyde-tab-content[data-tab-content='notes'] textarea {
  background-color: var(--color-warning-light);
  border-color: var(--color-warning);
}
.glyde-tab-content[data-tab-content='internal'] textarea {
  background-color: var(--color-success-light);
  border-color: var(--color-success);
}
.glyde-tab-content[data-tab-content='glyde'] {
  background: var(--color-neutral-grey-8);
  border-radius: 12px;
  padding: 16px;
}
.glyde-tab-content[data-tab-content='glyde'] .input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.glyde-send-message-btn {
  margin-top: 12px;
  padding: 8px 16px;
  background: var(--gradient-brand);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  width: 100%;
  transition: transform 0.1s;
}
.glyde-send-message-btn:active {
  transform: scale(0.98);
}

.glyde-send-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--color-brand-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* -------------------------------------------------------------------------- */
/* 9. Component: Drawers & Overlays                                           */
/* -------------------------------------------------------------------------- */
.glyde-chat-history-drawer {
  position: relative;
  margin-bottom: 8px;
}

.glyde-drawer-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background-color: #f5f5f5;
  border: 1px solid #d1d1d1;
  border-radius: 8px;
  cursor: pointer;
}

.glyde-drawer-content {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 400px;
  background: white;
  border: 1px solid #d1d1d1;
  border-radius: 8px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
}
.glyde-drawer-content.hidden {
  display: none;
}

/* ACS Drawer Specifics */
.acs-chat-drawer-wrapper .glyde-drawer-content.acs-chat-drawer {
  bottom: calc(100% + 8px);
  width: 95%;
  left: 2.5%;
  right: 2.5%;
}

/* -------------------------------------------------------------------------- */
/* 10. Component: Right Pane (CRM Info)                                       */
/* -------------------------------------------------------------------------- */
.glyde-crm-details {
  padding: 12px 16px;
}

.accordion-section {
  margin-bottom: 12px;
  border: 1px solid var(--neutralStroke2);
  border-radius: 8px;
  overflow: hidden;
}

.accordion-title {
  padding: 12px;
  background-color: var(--color-neutral-grey-4);
  font-weight: 600;
  font-size: 14px;
  border-bottom: 1px solid var(--neutralStroke2);
}

.accordion-content {
  padding: 12px;
  background-color: white;
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 20px;
  margin-top: 12px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background-color: var(--color-neutral-grey-20);
}

.timeline-dot {
  position: absolute;
  left: -21px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--color-brand-primary);
  border: 2px solid white;
  box-shadow: 0 0 0 1px var(--color-neutral-grey-20);
  z-index: 1;
}

.timeline-card {
  background: var(--color-surface-primary);
  border: 1px solid var(--neutralStroke2);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow-2);
}

/* -------------------------------------------------------------------------- */
/* 11. Utilities & Mobile                                                     */
/* -------------------------------------------------------------------------- */
.hidden {
  display: none !important;
}

/* Mobile Navigation Icons (Only visible on small screens handled by media queries if needed) */
.mobile-nav-icon {
  display: none; /* Default hidden */
  background: none;
  border: none;
  font-size: 16px;
  color: var(--color-text-tertiary);
  cursor: pointer;
  padding: 6px;
}

/* Utility to ensure resizers work */
.glyde-resizer[data-resizer='left'],
.glyde-resizer[data-resizer='right'] {
  width: 4px;
  cursor: col-resize;
  background-color: transparent;
  transition: background-color 0.2s;
}
.glyde-resizer:hover {
  background-color: var(--color-brand-light);
}

/* Conversation List Tabs */
.glyde-conversation-tabs {
  display: flex;
  gap: 4px;
  margin-top: 12px;
}
.glyde-conversation-tab {
  flex: 1;
  padding: 6px 12px;
  background-color: var(--color-surface-primary);
  border: 1px solid var(--neutralStroke2);
  border-radius: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.glyde-conversation-tab.active {
  background-color: var(--brandBackground);
  color: white;
  border-color: var(--brandBackground);
}

/* ==========================================================================
   Mobile Layout & Responsiveness (Restored & Enhanced)
   ========================================================================== */

/* Mobile Layout States */
.mobile-layout {
  --pane-left: 0%;
  --pane-center: 100%;
  --pane-right: 0%;
}

.mobile-layout .glyde-left-pane {
  position: fixed;
  top: 0;
  left: 0;
  width: 85%;
  max-width: 300px;
  height: 100vh;
  z-index: 1000;
  background: var(--color-surface-secondary);
  border-right: 1px solid var(--color-neutral-grey-16);
  box-shadow: var(--shadow-16);
  flex: none; /* Override flex properties */
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.33, 1, 0.68, 1); /* Fluent 2 ease */
}

.mobile-layout .glyde-left-pane.open {
  transform: translateX(0);
}

.mobile-layout .glyde-right-pane {
  position: fixed;
  top: 0;
  right: 0;
  width: 85%;
  max-width: 320px;
  height: 100vh;
  z-index: 1000;
  background: var(--color-surface-secondary);
  border-left: 1px solid var(--color-neutral-grey-16);
  box-shadow: var(--shadow-16);
  flex: none; /* Override flex properties */
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.33, 1, 0.68, 1);
}

.mobile-layout .glyde-right-pane.open {
  transform: translateX(0);
}

/* Ensure center pane takes full width in mobile layout */
.mobile-layout .glyde-center-pane {
  flex: 1 1 100% !important;
  width: 100% !important;
  min-width: 0 !important;
}

/* Mobile Close Button Style */
.mobile-close-left {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  border: none;
  font-size: 18px;
  color: var(--color-text-secondary);
  cursor: pointer;
  z-index: 1001;
  border-radius: 4px;
}

.mobile-close-left:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Drawer Overlay */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  /* Mobile layout activation */
  .glyde-modal-body {
    position: relative;
    overflow: hidden;
  }

  /* Show mobile navigation icons */
  .mobile-nav-icon {
    display: block;
    touch-action: manipulation;
    user-select: none;
  }

  /* Hide desktop resizers */
  .glyde-resizer {
    display: none !important;
  }

  /* Adjust header padding to accommodate mobile icons */
  #glyde-chat-header .header-left {
    padding-left: 32px;
  }

  #glyde-chat-header .header-right {
    padding-right: 32px;
  }

  /* Initial state: left pane hidden (handled by transform in .mobile-layout .glyde-left-pane) */
  /* But we need to override the static layout if not using mobile-layout class yet */

  /* Force center pane to take full width */
  .glyde-center-pane {
    flex: 1 1 100% !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  /* Override any flex basis on mobile */
  .mobile-layout .glyde-modal-body {
    flex-direction: row;
  }

  /* Mobile drawer background */
  .mobile-layout .glyde-left-pane,
  .mobile-layout .glyde-right-pane {
    background-color: var(--color-white) !important;
  }

  /* Reduce margins for notes on mobile */
  .glyde-message.note,
  .glyde-message.internal,
  .email-message {
    margin: 8px 0 !important;
  }
}

@media (max-width: 720px) {
  .glyde-message-bubble {
    max-width: 90%;
    font-size: 13px;
  }

  /* Smaller mobile adjustments */
  .mobile-layout .glyde-left-pane {
    width: 90%;
    max-width: 280px;
  }

  .mobile-layout .glyde-right-pane {
    width: 90%;
    max-width: 280px;
  }
}

/* -------------------------------------------------------------------------- */
/* 12. Component: SMS Features                                                */
/* -------------------------------------------------------------------------- */
/* SMS Delay Modal - Improved Design */
.sms-delay-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--color-surface-primary);
  border-radius: var(--border-radius-large);
  box-shadow: var(--shadow-28);
  z-index: 20000;
  width: 360px;
  max-width: 90vw;
  animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -60%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.sms-delay-content {
  padding: var(--spacing-xxl);
  text-align: center;
}

.sms-delay-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-m);
  margin-bottom: var(--spacing-l);
}

.sms-delay-header svg {
  color: var(--brandBackground);
  width: 24px;
  height: 24px;
}

.sms-delay-header h3 {
  margin: 0;
  font-size: var(--font-size-400);
  font-weight: 600;
  color: var(--color-text-primary);
}

.sms-delay-message {
  margin: 0 0 var(--spacing-xl) 0;
  font-size: var(--font-size-200);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

#sms-timer-countdown {
  font-weight: 600;
  color: var(--brandBackground);
  font-size: var(--font-size-300);
}

.sms-delay-progress-container {
  margin: var(--spacing-xl) 0;
}

.sms-delay-progress-bar {
  width: 100%;
  height: 6px;
  background-color: var(--color-neutral-grey-12);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.sms-delay-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--brandBackground) 0%, var(--color-brand-vibrant) 100%);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}

.sms-delay-actions {
  margin-top: var(--spacing-xxl);
  display: flex;
  justify-content: center;
  gap: var(--spacing-m);
}

.sms-delay-cancel-btn {
  padding: 10px 24px;
  border: 1px solid var(--neutralStroke2);
  background-color: var(--color-surface-primary);
  color: var(--color-text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: var(--font-size-200);
  font-weight: 500;
  transition: all 0.2s ease;
}

.sms-delay-cancel-btn:hover {
  background-color: var(--color-neutral-grey-8);
  border-color: var(--color-neutral-grey-24);
}

.sms-delay-cancel-btn:active {
  background-color: var(--color-neutral-grey-12);
}

/* SMS Message Styling - iMessage/WhatsApp-like appearance */
.glyde-message.sms-message {
  margin-bottom: var(--spacing-m);
}

.glyde-message.sms-message .glyde-message-bubble.sms-bubble {
  background-color: var(--brandBackground);
  color: white;
  border-radius: 18px 18px 4px 18px; /* Pico en esquina inferior izquierda (apunta hacia avatar a la derecha) */
  padding: 10px 14px;
  width: fit-content; /* Los mensajes cortos ocupan solo el espacio necesario */
  max-width: 75%; /* Los mensajes largos no se extienden más del 75% */
  min-width: 60px; /* Ancho mínimo para evitar burbujas demasiado pequeñas */
  box-shadow: var(--shadow-2);
  position: relative;
}

.sms-channel-indicator {
  margin-bottom: 6px;
  display: flex;
  align-items: center;
}

.sms-message-content {
  margin-bottom: 4px;
  word-wrap: break-word;
  white-space: pre-wrap;
  line-height: 1.4;
}

.sms-message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.8;
}

.sms-timestamp {
  font-size: 11px;
  opacity: 0.9;
}

.sms-status-icon {
  font-size: 12px;
  opacity: 0.9;
  line-height: 1;
}

/* Ensure SMS messages appear on the right (outgoing) */
.glyde-message.sms-message.assistant {
  justify-content: flex-end;
  /* No row-reverse needed - HTML order is already correct: message-content first, avatar second */
}

.glyde-message.sms-message .message-content.assistant {
  align-items: flex-end;
}
