/* DoorForce Messaging — WhatsApp-like usability (not WhatsApp branding) */

.df-chat-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 0;
  min-height: calc(100vh - 220px);
  background: #fff;
  border: 1px solid var(--df-border, #e2e8f0);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.df-chat-shell.is-dragover {
  outline: 2px dashed var(--df-navy, #0a2342);
  outline-offset: -4px;
}

.df-chat-sidebar {
  border-right: 1px solid var(--df-border, #e2e8f0);
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.df-chat-sidebar-head {
  padding: 12px;
  border-bottom: 1px solid var(--df-border, #e2e8f0);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.df-chat-search {
  width: 100%;
  border-radius: 999px !important;
  background: #fff !important;
}

.df-chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Author `display:flex` must not defeat the HTML hidden attribute */
#df-chat-active-tools[hidden],
#df-chat-composer[hidden],
.df-chat-btn-call-icon[hidden],
#df-chat-emoji-panel[hidden],
#df-chat-reply-bar[hidden],
#df-chat-typing[hidden] {
  display: none !important;
}

.df-chat-shell.is-error #df-chat-active-tools,
.df-chat-shell.is-error #df-chat-composer,
.df-chat-shell.is-empty-selection #df-chat-active-tools,
.df-chat-shell.is-empty-selection #df-chat-composer {
  display: none !important;
}

.df-chat-list {
  overflow: auto;
  flex: 1;
  padding: 6px;
}

.df-chat-item {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}

.df-chat-item:hover { background: #eef2f7; }
.df-chat-item.is-active { background: #e2e8f0; }

.df-chat-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #0a2342;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex: 0 0 auto;
}

.df-chat-avatar[data-online="1"]::after {
  content: '';
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #16a34a;
  border: 2px solid #f8fafc;
}

.df-chat-item-body { flex: 1; min-width: 0; }
.df-chat-item-top, .df-chat-item-bottom {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.df-chat-item-title {
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.df-chat-item-time, .df-chat-type {
  font-size: 0.72rem;
  color: #64748b;
  white-space: nowrap;
}
.df-chat-item-preview {
  font-size: 0.82rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.df-chat-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #bf0a30;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.df-chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #ece5dd;
  background-image: linear-gradient(rgba(236, 229, 221, 0.92), rgba(236, 229, 221, 0.92));
}

.df-chat-main-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: #f0f2f5;
  border-bottom: 1px solid #d1d5db;
}

.df-chat-main-head h3 { margin: 0; font-size: 1rem; color: #0a2342; }
.df-chat-active-status { font-size: 0.78rem; color: #64748b; }

.df-chat-messages {
  flex: 1;
  overflow: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.df-chat-day {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}
.df-chat-day span {
  background: rgba(255,255,255,0.85);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.72rem;
  color: #475569;
}

.df-chat-bubble-row { display: flex; }
.df-chat-bubble-row.is-mine { justify-content: flex-end; }

.df-chat-bubble {
  max-width: min(72%, 520px);
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px 6px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
  position: relative;
}
.df-chat-bubble-row.is-mine .df-chat-bubble {
  background: #d9fdd3;
}

.df-chat-bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: #0f172a;
  font-size: 0.92rem;
  line-height: 1.35;
}
.df-chat-bubble-meta {
  margin-top: 4px;
  font-size: 0.68rem;
  color: #64748b;
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  align-items: center;
}
.df-chat-receipt {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 4px;
  font-size: 0.72rem;
  line-height: 1;
  color: #94a3b8;
  vertical-align: middle;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: default;
}
.df-chat-receipt-group { cursor: pointer; }
.df-chat-receipt-group:hover { color: #0a2342; }
.df-chat-receipt-svg {
  width: 14px;
  height: 12px;
  display: block;
  flex: 0 0 auto;
}
.df-chat-receipt--sending { color: #94a3b8; }
.df-chat-receipt--sent { color: #94a3b8; }
.df-chat-receipt--delivered { color: #94a3b8; }
.df-chat-receipt--read { color: #0a2342; }
.df-chat-receipt-text { font-size: 0.68rem; font-weight: 600; }
.df-chat-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.df-chat-receipt-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 12000;
  padding: 16px;
}
.df-chat-receipt-card {
  width: min(360px, 100%);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
  padding: 14px 14px 8px;
}
.df-chat-receipt-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: #0a2342;
}
.df-chat-receipt-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow: auto;
}
.df-chat-receipt-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px;
  border-top: 1px solid #e2e8f0;
  font-size: 0.86rem;
  color: #334155;
}
.df-chat-receipt-list li span { color: #64748b; font-size: 0.78rem; }
.df-chat-receipt-empty { color: #64748b; border-top: 0 !important; }

.df-chat-deleted { color: #94a3b8; font-size: 0.85rem; }
.df-chat-reply-quote {
  border-left: 3px solid #0a2342;
  background: rgba(15,23,42,0.05);
  padding: 4px 8px;
  margin-bottom: 6px;
  border-radius: 4px;
  font-size: 0.8rem;
}
.df-chat-forward-tag {
  font-size: 0.72rem;
  color: #64748b;
  margin-bottom: 4px;
  font-style: italic;
}
.df-chat-attach-img img {
  max-width: 240px;
  max-height: 220px;
  border-radius: 8px;
  display: block;
  margin-top: 6px;
}
.df-chat-attach-file {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(15,23,42,0.06);
  border-radius: 8px;
  color: #0a2342;
  text-decoration: none;
  font-size: 0.82rem;
}
.df-chat-audio { width: 220px; margin-top: 6px; }

.df-chat-bubble-actions {
  display: none;
  gap: 6px;
  margin-top: 4px;
}
.df-chat-bubble:hover .df-chat-bubble-actions { display: flex; }
.df-chat-bubble-actions button {
  border: 0;
  background: transparent;
  color: #0a2342;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.df-chat-typing {
  padding: 0 14px 6px;
  font-size: 0.8rem;
  color: #475569;
  min-height: 1.2em;
}

.df-chat-composer {
  padding: 10px 12px;
  background: #f0f2f5;
  border-top: 1px solid #d1d5db;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.df-chat-reply-bar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
}

.df-chat-composer-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.df-chat-composer-tools {
  display: flex;
  gap: 4px;
}

.df-chat-composer textarea {
  flex: 1;
  border-radius: 10px !important;
  min-height: 44px;
  resize: none;
  background: #fff !important;
}

.df-chat-emoji-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
}
.df-chat-emoji-btn {
  border: 0;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px;
}

.df-chat-empty {
  padding: 28px 16px;
  text-align: center;
  color: #64748b;
  font-size: 0.9rem;
}

.df-chat-empty-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 280px;
  padding: 40px 24px;
}
.df-chat-empty-hero strong {
  color: #0a2342;
  font-size: 1.15rem;
}
.df-chat-empty-hero p {
  margin: 0;
  max-width: 320px;
  line-height: 1.45;
}

.df-chat-dir-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10040;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.df-chat-dir-card {
  width: min(480px, 100%);
  max-height: min(72vh, 640px);
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.df-chat-dir-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}
.df-chat-dir-head h3 { margin: 2px 0 0; font-size: 1.05rem; color: #0a2342; }
.df-chat-dir-filters {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
}
.df-chat-dir-status {
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #64748b;
  border-bottom: 1px solid #f1f5f9;
}
.df-chat-dir-list {
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.df-chat-dir-item {
  display: flex;
  gap: 10px;
  align-items: center;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  width: 100%;
}
.df-chat-dir-item:hover { background: #f1f5f9; }
.df-chat-dir-item-body { display: flex; flex-direction: column; min-width: 0; }
.df-chat-dir-item-body strong { color: #0a2342; font-size: 0.92rem; }
.df-chat-dir-item-body small { color: #64748b; font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.df-chat-nav-badge,
.df-header-badge {
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 4px;
  border-radius: 999px;
  background: #bf0a30;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
}
.df-header-badge[hidden],
.df-header-badge:empty { display: none !important; }

@media (max-width: 900px) {
  .df-chat-shell {
    grid-template-columns: 1fr;
    min-height: 70vh;
  }
  .df-chat-sidebar { max-height: 40vh; }
.df-chat-call-event {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}
.df-chat-call-event span {
  font-size: 0.78rem;
  color: #475569;
  background: #eef2f7;
  border: 1px solid #dbe3ee;
  border-radius: 999px;
  padding: 4px 12px;
}
.df-chat-btn-call-icon {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0a2342;
}
.df-chat-btn-call-icon:focus-visible {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
}
.df-chat-btn-call-icon .df-chat-call-icon {
  display: block;
}
.df-chat-btn-call-icon[hidden] {
  display: none !important;
}

/* Voice call UI */
.df-voice-incoming {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 18, 34, 0.72);
  padding: 20px;
}
.df-voice-incoming[hidden],
.df-voice-panel[hidden],
.df-voice-enable-sounds[hidden] { display: none !important; }
.df-voice-incoming-card {
  width: min(420px, 100%);
  text-align: center;
  color: #f8fafc;
  background: linear-gradient(160deg, #0a2342 0%, #163a63 55%, #0f2744 100%);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 28px 22px 24px;
  position: relative;
}
.df-voice-pulse {
  position: absolute;
  inset: 18% 28%;
  border-radius: 50%;
  border: 2px solid rgba(94, 184, 255, 0.35);
  animation: df-voice-pulse 1.6s ease-out infinite;
  pointer-events: none;
}
@keyframes df-voice-pulse {
  0% { transform: scale(0.7); opacity: 0.8; }
  100% { transform: scale(1.35); opacity: 0; }
}
.df-voice-avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: #1d4f82;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  font-weight: 700;
  position: relative;
  z-index: 1;
}
.df-voice-incoming-card h2 {
  margin: 0;
  font-size: 1.35rem;
  position: relative;
  z-index: 1;
}
.df-voice-sub { color: #b6c7db; margin: 6px 0 0; font-size: 0.9rem; }
.df-voice-visually {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.df-voice-incoming-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 28px;
}
.df-voice-btn {
  border: 0;
  border-radius: 14px;
  min-height: 56px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
}
.df-voice-accept { background: #15803d; }
.df-voice-accept:focus-visible,
.df-voice-decline:focus-visible,
.df-voice-panel button:focus-visible {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
}
.df-voice-decline { background: #b91c1c; }
.df-voice-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 11900;
  width: min(360px, calc(100vw - 24px));
  background: #0a2342;
  color: #f8fafc;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 12px 40px rgba(8, 18, 34, 0.35);
}
.df-voice-panel-inner { padding: 14px 14px 12px; }
.df-voice-panel-meta {
  display: grid;
  gap: 2px;
  margin-bottom: 10px;
}
.df-voice-status { color: #7dd3fc; font-size: 0.82rem; }
.df-voice-duration { font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.df-voice-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.df-voice-panel-actions .btn { color: #0a2342; }
.df-voice-end { background: #b91c1c !important; border-color: #b91c1c !important; color: #fff !important; }
.df-voice-turn-warn {
  margin: 10px 0 0;
  font-size: 0.75rem;
  color: #fde68a;
}
.df-voice-enable-sounds {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 11850;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: #0a2342;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.df-tone-backdrop {
  position: fixed;
  inset: 0;
  z-index: 11000;
  background: rgba(8, 18, 34, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.df-tone-card {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 14px;
  border: 1px solid #dbe3ee;
  padding: 18px;
  max-height: 90vh;
  overflow: auto;
}
.df-tone-card h3 { margin: 0 0 12px; color: #0a2342; }
.df-tone-grid {
  display: grid;
  gap: 10px;
}
.df-tone-grid label {
  display: grid;
  gap: 4px;
  font-size: 0.85rem;
  color: #334155;
}
@media (max-width: 720px) {
  .df-voice-panel {
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
  }
  .df-voice-incoming-actions { grid-template-columns: 1fr; }
  .df-voice-btn { min-height: 64px; }
}
