/**
 * ADHC Phase 2 — Sprint 1C — Conversation Panel Styles
 * ======================================================
 * Glassmorphism, healthcare theme, mobile-first.
 * All selectors prefixed .adhc-* — zero conflicts with Phase 1.
 * CSS-only animations, no heavy libraries.
 */

/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --adhc-teal:        #0d9488;
  --adhc-teal-dark:   #0f766e;
  --adhc-teal-light:  #ccfbf1;
  --adhc-bg:          #ffffff;
  --adhc-glass:       rgba(255,255,255,0.96);
  --adhc-border:      rgba(13,148,136,0.15);
  --adhc-shadow:      0 8px 40px rgba(0,0,0,0.18);
  --adhc-radius:      20px;
  --adhc-radius-sm:   12px;
  --adhc-font:        'Inter', system-ui, sans-serif;
  --adhc-panel-w:     380px;
  --adhc-panel-w-sm:  100vw;
}

/* ── Overlay ────────────────────────────────────────────────────────────── */
#adhc-conv-overlay {
  display:    none;
  position:   fixed;
  inset:      0;
  background: rgba(15,23,42,0.45);
  z-index:    11000;
  backdrop-filter: blur(2px);
  opacity:    0;
  transition: opacity 0.3s ease;
}
#adhc-conv-overlay.adhc-overlay-visible {
  display: block;
  opacity: 1;
}

/* ── Panel Container ────────────────────────────────────────────────────── */
#adhc-conv-panel {
  position:      fixed;
  top:           0;
  right:         0;
  bottom:        0;
  width:         var(--adhc-panel-w);
  max-width:     100vw;
  z-index:       11001;
  display:       flex;
  flex-direction: column;
  background:    var(--adhc-glass);
  border-left:   1.5px solid var(--adhc-border);
  box-shadow:    var(--adhc-shadow);
  font-family:   var(--adhc-font);
  overflow:      hidden;
  transform:     translateX(100%);
  transition:    transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
  will-change:   transform;
}

#adhc-conv-panel.adhc-panel-open {
  transform: translateX(0);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.adhc-panel-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         1rem 1.1rem 0.85rem;
  background:      linear-gradient(135deg, var(--adhc-teal) 0%, var(--adhc-teal-dark) 100%);
  color:           #fff;
  flex-shrink:     0;
  border-bottom:   1px solid rgba(255,255,255,0.12);
}

.adhc-panel-avatar-wrap {
  display:     flex;
  align-items: center;
  gap:         0.65rem;
}

.adhc-panel-avatar-emoji {
  font-size:        2rem;
  line-height:      1;
  background:       rgba(255,255,255,0.18);
  border-radius:    50%;
  width:            46px;
  height:           46px;
  display:          flex;
  align-items:      center;
  justify-content:  center;
  border:           2px solid rgba(255,255,255,0.3);
  flex-shrink:      0;
}

.adhc-panel-avatar-info {
  display:       flex;
  flex-direction: column;
  gap:            2px;
}

.adhc-panel-name {
  font-size:   1rem;
  font-weight: 800;
  line-height: 1.2;
}

.adhc-panel-subtitle {
  font-size:   0.72rem;
  font-weight: 500;
  opacity:     0.85;
  letter-spacing: 0.2px;
}

.adhc-panel-close {
  width:            38px;
  height:           38px;
  border-radius:    50%;
  background:       rgba(255,255,255,0.18);
  border:           1.5px solid rgba(255,255,255,0.3);
  color:            #fff;
  font-size:        1rem;
  font-weight:      700;
  cursor:           pointer;
  display:          flex;
  align-items:      center;
  justify-content:  center;
  transition:       all 0.2s ease;
  flex-shrink:      0;
  min-width:        38px;   /* large touch target */
  min-height:       38px;
}
.adhc-panel-close:hover   { background: rgba(255,255,255,0.3); transform: scale(1.1); }
.adhc-panel-close:active  { transform: scale(0.95); }

/* ── Voice Transcript Band ───────────────────────────────────────────────── */
.adhc-voice-band {
  display:         flex;
  align-items:     center;
  gap:             0.5rem;
  padding:         0.55rem 1rem;
  background:      linear-gradient(90deg, rgba(13,148,136,0.08), rgba(13,148,136,0.04));
  border-bottom:   1px solid var(--adhc-border);
  flex-shrink:     0;
}

.adhc-voice-icon {
  font-size: 1rem;
  animation: adhc-pulse 1.2s ease-in-out infinite;
}

@keyframes adhc-pulse {
  0%,100% { opacity:1; }
  50%     { opacity:0.5; }
}

.adhc-voice-transcript {
  font-size:   0.8rem;
  font-weight: 600;
  color:       var(--adhc-teal-dark);
  flex:        1;
  overflow:    hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ── Message List ─────────────────────────────────────────────────────────── */
.adhc-msg-list {
  flex:         1;
  overflow-y:   auto;
  padding:      0.85rem 0.9rem;
  display:      flex;
  flex-direction: column;
  gap:          0.55rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.adhc-msg-list::-webkit-scrollbar { width: 4px; }
.adhc-msg-list::-webkit-scrollbar-thumb { background: rgba(13,148,136,0.25); border-radius: 2px; }

/* ── Message Row ─────────────────────────────────────────────────────────── */
.adhc-msg-row {
  display:     flex;
  max-width:   90%;
}

.adhc-msg-row.adhc-msg-out    { align-self: flex-start; }
.adhc-msg-row.adhc-msg-in     { align-self: flex-end;   }
.adhc-msg-row.adhc-msg-system { align-self: center; max-width: 100%; }

/* ── Bubble ──────────────────────────────────────────────────────────────── */
.adhc-msg-bubble {
  padding:        0.6rem 0.85rem;
  border-radius:  var(--adhc-radius-sm);
  font-size:      0.88rem;
  line-height:    1.45;
  display:        flex;
  align-items:    flex-start;
  gap:            0.4rem;
  box-shadow:     0 2px 8px rgba(0,0,0,0.07);
  opacity:        0;
  transform:      translateY(8px);
  transition:     opacity 0.25s ease, transform 0.25s ease;
  word-break:     break-word;
  position:       relative;
}

.adhc-msg-bubble.adhc-msg-visible {
  opacity:   1;
  transform: translateY(0);
}

/* ── Message type colors ─────────────────────────────────────────────────── */
.msg-assistant {
  background:    var(--adhc-teal-light);
  color:         #0f172a;
  border:        1.5px solid rgba(13,148,136,0.2);
  border-radius: var(--adhc-radius-sm) var(--adhc-radius-sm) var(--adhc-radius-sm) 4px;
}
.msg-user {
  background:    var(--adhc-teal);
  color:         #ffffff;
  border-radius: var(--adhc-radius-sm) var(--adhc-radius-sm) 4px var(--adhc-radius-sm);
}
.msg-system {
  background:    #f1f5f9;
  color:         #64748b;
  border:        1px dashed #cbd5e1;
  border-radius: 8px;
  font-size:     0.78rem;
  padding:       0.4rem 0.7rem;
}
.msg-info {
  background:    #eff6ff;
  color:         #1d4ed8;
  border:        1.5px solid #bfdbfe;
}
.msg-reminder {
  background:    #fef9c3;
  color:         #854d0e;
  border:        1.5px solid #fde68a;
}
.msg-alert {
  background:    #fef2f2;
  color:         #991b1b;
  border:        1.5px solid #fecaca;
}
.msg-error {
  background:    #fff1f2;
  color:         #be123c;
  border:        1.5px solid #fecdd3;
}

.adhc-msg-icon {
  font-size:  1rem;
  flex-shrink: 0;
  margin-top:  1px;
}
.adhc-msg-text {
  flex: 1;
  font-weight: 500;
}
.adhc-msg-time {
  font-size:  0.62rem;
  opacity:    0.55;
  align-self: flex-end;
  margin-left: 4px;
  white-space: nowrap;
}

/* ── Typing Indicator ────────────────────────────────────────────────────── */
.adhc-typing-indicator {
  display:     flex;
  align-items: center;
  gap:         0.45rem;
  padding:     0.55rem 0.9rem;
  flex-shrink: 0;
  background:  var(--adhc-teal-light);
  border-top:  1px solid var(--adhc-border);
}

.adhc-typing-avatar { font-size: 1rem; }

.adhc-typing-label {
  font-size:   0.78rem;
  color:       var(--adhc-teal-dark);
  font-weight: 600;
}

.adhc-typing-dots {
  display:     flex;
  align-items: center;
  gap:         3px;
  margin-left: 2px;
}

.adhc-typing-dots span {
  width:        7px;
  height:       7px;
  border-radius: 50%;
  background:   var(--adhc-teal);
  display:      inline-block;
  animation:    adhc-dot-bounce 1.2s ease-in-out infinite;
}
.adhc-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.adhc-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes adhc-dot-bounce {
  0%,60%,100% { transform: translateY(0);    opacity: 0.6; }
  30%          { transform: translateY(-5px); opacity: 1;   }
}

/* ── Quick Actions ────────────────────────────────────────────────────────── */
.adhc-quick-actions {
  padding:      0.7rem 0.9rem 0.5rem;
  border-top:   1px solid var(--adhc-border);
  flex-shrink:  0;
  background:   rgba(240,253,250,0.7);
}

.adhc-qa-label {
  font-size:    0.78rem;
  font-weight:  700;
  color:        var(--adhc-teal-dark);
  margin-bottom: 0.55rem;
  letter-spacing: 0.2px;
}

.adhc-qa-grid {
  display:               grid;
  grid-template-columns: repeat(2, 1fr);
  gap:                   0.5rem;
  max-height:            200px;
  overflow-y:            auto;
  -webkit-overflow-scrolling: touch;
}

.adhc-qa-card {
  display:          flex;
  flex-direction:   column;
  align-items:      flex-start;
  padding:          0.65rem 0.75rem;
  background:       #ffffff;
  border:           1.5px solid var(--adhc-border);
  border-radius:    var(--adhc-radius-sm);
  cursor:           pointer;
  transition:       all 0.2s ease;
  text-align:       left;
  gap:              2px;
  min-height:       64px;   /* large touch target for seniors */
  box-shadow:       0 2px 8px rgba(0,0,0,0.05);
}

.adhc-qa-card:hover  {
  background:   var(--adhc-teal-light);
  border-color: var(--adhc-teal);
  transform:    translateY(-2px);
  box-shadow:   0 6px 16px rgba(13,148,136,0.18);
}
.adhc-qa-card:active { transform: scale(0.97); }

/* Emergency card highlight */
.adhc-qa-card:last-child {
  border-color: rgba(239,68,68,0.3);
  background:   #fff5f5;
}
.adhc-qa-card:last-child:hover {
  background:   #fef2f2;
  border-color: #ef4444;
}

.qa-icon  { font-size: 1.2rem; line-height: 1; }
.qa-label { font-size: 0.78rem; font-weight: 800; color: #0f172a; line-height: 1.2; }
.qa-sub   { font-size: 0.62rem; color: #64748b; font-weight: 500; }

/* ── Input Row ────────────────────────────────────────────────────────────── */
.adhc-input-row {
  display:       flex;
  align-items:   center;
  gap:           0.4rem;
  padding:       0.65rem 0.75rem 0.75rem;
  border-top:    1.5px solid var(--adhc-border);
  background:    #fff;
  flex-shrink:   0;
}

.adhc-text-input {
  flex:           1;
  padding:        0.65rem 0.9rem;
  border:         1.5px solid var(--adhc-border);
  border-radius:  999px;
  font-size:      0.9rem;
  font-family:    var(--adhc-font);
  color:          #0f172a;
  background:     #f8fafc;
  outline:        none;
  transition:     border-color 0.2s ease, box-shadow 0.2s ease;
  min-width:      0;
}
.adhc-text-input:focus {
  border-color: var(--adhc-teal);
  box-shadow:   0 0 0 3px rgba(13,148,136,0.15);
  background:   #fff;
}
.adhc-text-input::placeholder { color: #94a3b8; }

.adhc-send-btn,
.adhc-mic-btn {
  width:            42px;
  height:           42px;
  min-width:        42px;
  border-radius:    50%;
  border:           none;
  display:          flex;
  align-items:      center;
  justify-content:  center;
  cursor:           pointer;
  font-size:        1rem;
  transition:       all 0.2s ease;
  flex-shrink:      0;
}

.adhc-send-btn {
  background: var(--adhc-teal);
  color:      #fff;
  box-shadow: 0 4px 12px rgba(13,148,136,0.3);
}
.adhc-send-btn:hover  { background: var(--adhc-teal-dark); transform: scale(1.07); }
.adhc-send-btn:active { transform: scale(0.95); }

.adhc-mic-btn {
  background: #f1f5f9;
  color:      var(--adhc-teal);
  border:     1.5px solid var(--adhc-border);
}
.adhc-mic-btn:hover  { background: var(--adhc-teal-light); }
.adhc-mic-btn:active { transform: scale(0.95); }

/* ── Mobile: full-width panel ────────────────────────────────────────────── */
@media (max-width: 414px) {
  #adhc-conv-panel { width: 100vw; border-left: none; }

  .adhc-qa-grid {
    grid-template-columns: repeat(2, 1fr);
    max-height:            180px;
  }

  .adhc-panel-header { padding: 0.85rem 0.9rem 0.75rem; }

  .adhc-msg-bubble { font-size: 0.85rem; }

  .adhc-text-input { font-size: 0.85rem; }
}

@media (max-width: 375px) {
  .adhc-qa-grid { grid-template-columns: repeat(2, 1fr); gap: 0.4rem; }
  .adhc-qa-card { padding: 0.55rem 0.6rem; min-height: 56px; }
  .qa-label     { font-size: 0.73rem; }
  .qa-sub       { font-size: 0.6rem; }
}

@media (max-width: 360px) {
  #adhc-conv-panel { width: 100vw; }
  .adhc-msg-bubble { font-size: 0.82rem; padding: 0.5rem 0.7rem; }
}

/* ── Landscape: reduce quick-actions height ─────────────────────────────── */
@media (max-height: 500px) {
  .adhc-qa-grid   { max-height: 100px; }
  .adhc-qa-card   { min-height: 48px; padding: 0.4rem 0.55rem; }
  .adhc-msg-list  { flex: 1; }
}

/* ── Accessibility: reduce motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #adhc-conv-panel,
  .adhc-msg-bubble,
  .adhc-qa-card,
  .adhc-typing-dots span {
    animation: none !important;
    transition: none !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   ADHC Sprint 2A — Quick Reply Chips
   ══════════════════════════════════════════════════════════════════════════ */

.adhc-chip-row {
  display:         flex;
  flex-wrap:       wrap;
  gap:             0.4rem;
  padding:         0.45rem 0;
  opacity:         0;
  transform:       translateY(6px);
  transition:      opacity 0.25s ease, transform 0.25s ease;
  align-self:      flex-start;
  max-width:       100%;
}

.adhc-chip-row.adhc-chip-row-visible {
  opacity:   1;
  transform: translateY(0);
}

.adhc-chip {
  display:       inline-flex;
  align-items:   center;
  padding:       0.45rem 0.85rem;
  border:        1.5px solid var(--adhc-teal);
  border-radius: 999px;
  background:    rgba(13, 148, 136, 0.06);
  color:         var(--adhc-teal-dark);
  font-size:     0.78rem;
  font-weight:   700;
  font-family:   var(--adhc-font);
  cursor:        pointer;
  white-space:   nowrap;
  transition:    all 0.18s ease;
  min-height:    36px;   /* large touch target */
  line-height:   1;
}

.adhc-chip:hover {
  background:  var(--adhc-teal);
  color:       #ffffff;
  transform:   translateY(-2px);
  box-shadow:  0 4px 12px rgba(13, 148, 136, 0.3);
}

.adhc-chip:active { transform: scale(0.96); }

/* Emergency chip — red tint */
.adhc-chip[aria-label*="Emergency"],
.adhc-chip[aria-label*="Madad"],
.adhc-chip[aria-label*="108"],
.adhc-chip[aria-label*="112"] {
  border-color: #ef4444;
  color:        #ef4444;
  background:   rgba(239,68,68,0.06);
}

.adhc-chip[aria-label*="Emergency"]:hover,
.adhc-chip[aria-label*="Madad"]:hover,
.adhc-chip[aria-label*="108"]:hover,
.adhc-chip[aria-label*="112"]:hover {
  background: #ef4444;
  color:      #ffffff;
}

/* Mobile adjustments */
@media (max-width: 414px) {
  .adhc-chip       { font-size: 0.73rem; padding: 0.4rem 0.7rem; }
  .adhc-chip-row   { gap: 0.35rem; }
}
