/* ============================================
   OmniDesk Hyperion — Custom Styles
   Tailwind handles most styling via CDN.
   This file covers animations, scrollbars, 
   glass morphism, and component-specific CSS.
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: 'Inter', sans-serif;
  background: #0a0f1c;
}

/* skip-navigation link */
.skip-nav {
  position: absolute;
  top: -40px;
  left: 0;
  background: #00bcd4;
  color: #0a0f1c;
  padding: 8px 16px;
  z-index: 10000;
  font-weight: 700;
  font-size: 0.875rem;
  transition: top 0.2s;
}
.skip-nav:focus {
  top: 0;
}

/* focus-visible indicator */
*:focus-visible {
  outline: 2px solid #00bcd4;
  outline-offset: 2px;
}

/* custom scrollbar - ultra thin */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: #1a1f2e; border-radius: 10px; }
::-webkit-scrollbar-thumb { background: #3b4259; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #5f6a8a; }

/* glass morphism */
.glass-panel {
  background: rgba(18, 25, 45, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(72, 85, 120, 0.25);
}
.ai-glow {
  box-shadow: 0 0 12px rgba(0, 188, 212, 0.3), 0 0 0 1px rgba(0, 188, 212, 0.2);
}

/* loading skeleton shimmer */
.loading-skeleton {
  background: linear-gradient(90deg, #1a2332 25%, #243044 50%, #1a2332 75%);
  background-size: 200% 100%;
}
/* message entrance animation */
.message-in {}

/* AI message glow */
.ai-pulse {
  box-shadow: 0 0 12px rgba(255, 185, 95, 0.2);
}

/* Message badge base */
.msg-badge {
  position: absolute;
  top: -0.5rem;
  left: -0.5rem;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  line-height: 1.2;
}
.msg-badge .material-symbols-outlined {
  font-size: 10px;
}
/* online status pulse */
.pulse-dot {
  box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.7);
}

@media (prefers-reduced-motion: no-preference) {
  .loading-skeleton {
    animation: shimmer 1.5s infinite;
  }
  @keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }
  .message-in {
    animation: fadeSlideUp 0.2s ease-out;
  }
  @keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .pulse-dot {
    animation: pulse 1.8s infinite;
  }
  @keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(0, 230, 118, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 230, 118, 0); }
  }
}

/* typing indicator (reserved) */
.typing-indicator span {
  height: 6px;
  width: 6px;
  background: #8892b0;
  border-radius: 50%;
  display: inline-block;
}
@media (prefers-reduced-motion: no-preference) {
  .typing-indicator span {
    animation: typingBounce 1.2s infinite ease-in-out;
  }
  .typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
  .typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
  @keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-4px); }
  }
}

/* AI suggestion chips */
.suggestion-chip {
  transition: all 0.15s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}
.suggestion-chip:hover {
  transform: translateY(-1px);
  background: #2a3a6e;
  border-color: #5f7fbf;
}

/* Account rail — click-toggle expansion */
.account-item {
  transition: all 0.2s;
  border-left: 3px solid transparent;
  border-radius: 0 12px 12px 0;
}
.account-item:hover {
  background: rgba(30, 42, 58, 0.5);
}
.account-item.active {
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.12) 0%, rgba(30, 60, 90, 0.06) 100%);
  border-left-color: #06b6d4;
}
.account-item.active .account-badge {
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.5), 0 0 16px rgba(6, 182, 212, 0.2);
  transform: scale(1.05);
}
#accountRail {
  transition: width 300ms ease;
}
#accountRail:hover,
#accountRail.expanded {
  width: 16rem;
}
.account-details {
  opacity: 0;
  transition: opacity 200ms ease;
}
#accountRail:hover .account-details,
#accountRail.expanded .account-details {
  opacity: 1;
}
/* Show search when rail is expanded */
#accountRail:hover #railSearchWrap,
#accountRail.expanded #railSearchWrap {
  display: block;
}
/* Scrollable rail list */
#accountRailList {
  scrollbar-width: none;
}
#accountRail:hover #accountRailList {
  scrollbar-width: thin;
  scrollbar-color: #3b4259 transparent;
}
#accountRail.expanded #accountRailList {
  scrollbar-width: thin;
  scrollbar-color: #3b4259 transparent;
}

/* Chat row selection */
.chat-row {
  transition: all 0.15s;
}
.chat-row.active {
  background: linear-gradient(90deg, rgba(0, 188, 212, 0.08) 0%, rgba(30, 60, 90, 0) 100%);
  border-left: 3px solid #00bcd4;
}

/* Button press feedback */
button:active:not(:disabled) {
  transform: scale(0.97);
}

/* Notification dropdown */
.notification-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  width: 20rem;
  max-height: 20rem;
  overflow-y: auto;
  background: #111827;
  border: 1px solid #1e2a3a;
  border-radius: 0.75rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  z-index: 100;
}
.notification-dropdown.open {
  display: block;
}

/* Date separator */
.date-separator {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}
.date-separator::before,
.date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #1e2a3a;
}
.date-separator span {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6b7280;
  white-space: nowrap;
}

/* Right panel collapse */
#intelPanel {
  transition: width 300ms ease, opacity 200ms ease;
}
#intelPanel.collapsed {
  width: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0;
  border: none;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Compact mode — tighter spacing */
body.compact-mode .p-5 { padding: 0.75rem; }
body.compact-mode .p-4 { padding: 0.5rem; }
body.compact-mode .p-3 { padding: 0.375rem; }
body.compact-mode .space-y-4 > * + * { margin-top: 0.5rem; }
body.compact-mode .space-y-2 > * + * { margin-top: 0.25rem; }
body.compact-mode .mb-4 { margin-bottom: 0.5rem; }
body.compact-mode .gap-4 { gap: 0.5rem; }

/* Hide timestamps preference */
body.hide-timestamps .msg-timestamp { display: none; }

/* ≤1440px: right panel narrows */
@media (max-width: 1440px) {
  #intelPanel:not(.collapsed) {
    width: 20rem;
  }
}
/* ≤1280px: hide right panel by default, show via toggle */
@media (max-width: 1280px) {
  #intelPanel {
    position: fixed;
    top: 3.5rem;
    right: 0;
    bottom: 0;
    z-index: 60;
    width: 0;
    overflow: hidden;
    opacity: 0;
    border: none;
  }
  #intelPanel.slide-open {
    width: 24rem;
    opacity: 1;
    overflow-y: auto;
    border-left: 1px solid #1e2a3a;
  }
  #intelToggleBtn {
    display: flex !important;
  }
}
/* ≤768px: single-column mobile layout */
@media (max-width: 768px) {
  #accountRail { display: none !important; }
  .chat-list-panel { width: 100% !important; }
  #intelPanel { display: none !important; }
  .mobile-back-btn { display: inline-flex !important; }
  /* Mobile panel switching: show only one panel at a time */
  body.mobile-messages .chat-list-panel { display: none !important; }
  body:not(.mobile-messages) #mainContent { display: none !important; }
}

/* ============================================
 * Phase 15 — All Chats: compact rows, badges,
 * bulk actions, context menu, realtime pill
 * ============================================ */
.chat-row-compact {
  padding: 0.5rem 0.625rem;
  font-size: 11px;
}
.chat-row-compact h4 { line-height: 1.2; }
.chat-label-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  border-radius: 0.25rem;
  background: #1e2a3a;
  color: #67e8f9;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  user-select: none;
}
.chat-label-badge-empty {
  background: transparent;
  color: #475569;
  border: 1px dashed #2a3748;
}
.chat-bulk-cb { cursor: pointer; }

.bulk-action-bar {
  animation: slideDown 120ms ease-out;
}
@keyframes slideDown {
  from { transform: translateY(-6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.chat-context-menu {
  animation: ctxFade 100ms ease-out;
}
@keyframes ctxFade {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* Segmented filter active state is set inline by JS; provide hover smoothness */
.chat-segment-btn { transition: background-color 120ms, color 120ms; }

/* Realtime status pill */
.realtime-status-pill { transition: background-color 200ms, border-color 200ms; }
.realtime-status-pill.live { border-color: rgba(16, 185, 129, 0.35); }
.realtime-status-pill.reconnecting { border-color: rgba(245, 158, 11, 0.35); }
.realtime-status-pill.offline { border-color: rgba(107, 114, 128, 0.35); }

/* ============================================
 * Chat list — v2 row design (avatars, accent stripe,
 * unread bubble, lead score, status pills)
 * ============================================ */
.chat-row-v2 {
  position: relative;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem 0.625rem 0.875rem;
  border-bottom: 1px solid #182234;
  cursor: pointer;
  background: transparent;
  transition: background 140ms ease, transform 140ms ease;
}
.chat-row-v2:hover {
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.04), rgba(15, 23, 42, 0));
}
.chat-row-v2.active {
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.12) 0%, rgba(30, 60, 90, 0) 70%);
  border-left: none; /* the accent stripe replaces this */
}
.chat-row-v2.active .chat-row-name { color: #67e8f9; }

/* Left accent stripe — color hints status at a glance */
.chat-row-accent {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: transparent;
  transition: background 140ms ease;
}
.chat-row-v2.accent-ai     .chat-row-accent { background: linear-gradient(180deg, #22d3ee, #3b82f6); }
.chat-row-v2.accent-human  .chat-row-accent { background: linear-gradient(180deg, #6b7280, #4b5563); }
.chat-row-v2.accent-reply  .chat-row-accent { background: linear-gradient(180deg, #fbbf24, #f59e0b); }
.chat-row-v2.accent-call   .chat-row-accent { background: linear-gradient(180deg, #34d399, #10b981); }
.chat-row-v2.accent-spam   .chat-row-accent { background: linear-gradient(180deg, #f43f5e, #be123c); }
.chat-row-v2.active .chat-row-accent { width: 4px; }

.chat-row-v2 .chat-bulk-cb {
  width: 0.875rem;
  height: 0.875rem;
  margin-top: 0.875rem;
  accent-color: #06b6d4;
  cursor: pointer;
  flex-shrink: 0;
}

/* Avatar */
.chat-avatar {
  position: relative;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.chat-avatar-mode {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  background: #0f172a;
  border: 2px solid #0b1220;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  line-height: 1;
}

.chat-row-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.chat-row-line1 {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  justify-content: space-between;
}
.chat-row-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #e2e8f0;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
  transition: color 120ms ease;
}
.chat-row-meta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}
.chat-time {
  font-size: 0.625rem;
  color: #94a3b8;
  font-weight: 600;
  white-space: nowrap;
}
.chat-score {
  font-size: 0.625rem;
  font-weight: 800;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  line-height: 1.4;
  border: 1px solid transparent;
}
.chat-score.score-hi  { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.3); }
.chat-score.score-mid { background: rgba(245, 158, 11, 0.16); color: #fcd34d; border-color: rgba(245, 158, 11, 0.3); }
.chat-score.score-lo  { background: rgba(244, 63, 94, 0.14);  color: #fda4af; border-color: rgba(244, 63, 94, 0.28); }

.chat-row-line2 {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.chat-row-snippet {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.7rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}
.chat-row-v2.has-unread .chat-row-snippet,
.chat-row-line2 .chat-unread + .chat-row-snippet { color: #cbd5e1; font-weight: 600; }

.chat-unread {
  flex-shrink: 0;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(6, 182, 212, 0.35);
}

.chat-row-line3 {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-top: 0.125rem;
}
.chat-row-acc {
  font-size: 0.6rem;
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 8rem;
  margin-left: auto;
}

.chat-pill-row {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.chat-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1rem;
  min-width: 1rem;
  padding: 0 0.25rem;
  font-size: 0.6rem;
  border-radius: 0.25rem;
  line-height: 1;
}
.chat-pill.pill-reply { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.chat-pill.pill-call  { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
.chat-pill.pill-wait  { background: rgba(245, 158, 11, 0.14); color: #fde68a; }
.chat-pill.pill-spam  { background: rgba(244, 63, 94, 0.18);  color: #fda4af; }
.chat-pill.pill-aioff { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; }
