/* ========================================================
   TrailTrack Stories — Floating DM Bubbles
   ======================================================== */

.dm-bubble {
  position: fixed;
  width: 340px;
  height: 420px;
  background: var(--surface, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: height 0.2s ease, width 0.2s ease, box-shadow 0.2s;
}

.dm-bubble:hover {
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

/* Minimized state — just the header */
.dm-bubble-minimized {
  height: 44px;
  width: 240px;
}

.dm-bubble-minimized .dm-bubble-messages,
.dm-bubble-minimized .dm-bubble-drop-zone {
  display: none;
}

/* Flash animation for new message */
.dm-bubble-flash {
  animation: bubble-flash 0.5s ease;
}

@keyframes bubble-flash {
  0%, 100% { box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 20px rgba(16, 185, 129, 0.5); }
}

/* ---- Header ---- */
.dm-bubble-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0,0,0,0.2);
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
}

.dm-bubble-header:active {
  cursor: grabbing;
}

.dm-bubble-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.dm-bubble-user .avatar {
  width: 24px;
  height: 24px;
  font-size: 0.6rem;
  flex-shrink: 0;
}

.dm-bubble-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text, #f1f5f9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dm-bubble-status {
  width: 8px;
  height: 8px;
  background: var(--green-light, #10b981);
  border-radius: 50%;
  flex-shrink: 0;
}

.dm-bubble-actions {
  display: flex;
  gap: 2px;
}

.dm-bubble-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  border-radius: 4px;
  font-size: 1rem;
  transition: background 0.15s, color 0.15s;
}

.dm-bubble-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text, #f1f5f9);
}

/* ---- Messages ---- */
.dm-bubble-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.dm-bubble-messages::-webkit-scrollbar {
  width: 4px;
}

.dm-bubble-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.dm-bubble-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #64748b);
  font-size: 0.8rem;
}

.dm-bubble-msg {
  max-width: 85%;
  animation: fade-in 0.15s ease;
}

.dm-bubble-msg.own {
  align-self: flex-end;
}

.dm-bubble-msg-text {
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 0.82rem;
  line-height: 1.4;
  word-wrap: break-word;
  background: var(--bg, #0f172a);
  color: var(--text-secondary, #94a3b8);
}

.dm-bubble-msg.own .dm-bubble-msg-text {
  background: rgba(5, 150, 105, 0.2);
  color: var(--text, #f1f5f9);
}

.dm-bubble-msg-photo {
  max-width: 100%;
  max-height: 150px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 2px;
}

.dm-bubble-msg-photo:hover {
  opacity: 0.9;
}

/* Drag over */
.dm-bubble-drag-over {
  outline: 2px dashed var(--green-light, #10b981);
  outline-offset: -4px;
}

.dm-bubble-drag-over::after {
  content: '📷 Drop';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--green-light);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--green-light);
  z-index: 5;
  pointer-events: none;
}

/* ---- Input ---- */
.dm-bubble-drop-zone {
  flex-shrink: 0;
  border-top: 1px solid var(--border, #334155);
  padding: 8px;
}

.dm-bubble-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  background: var(--bg, #0f172a);
  border: 1px solid var(--border, #334155);
  border-radius: 8px;
  padding: 4px 6px;
}

.dm-bubble-input-wrap:focus-within {
  border-color: var(--green, #059669);
}

.dm-bubble-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text, #f1f5f9);
  font-size: 0.82rem;
  resize: none;
  outline: none;
  max-height: 80px;
  line-height: 1.4;
  padding: 4px;
}

.dm-bubble-input::placeholder {
  color: var(--text-muted, #64748b);
}

.dm-bubble-send,
.dm-bubble-photo {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.dm-bubble-send {
  background: var(--green, #059669);
  color: white;
}

.dm-bubble-send:hover {
  background: var(--green-light, #10b981);
}

.dm-bubble-photo {
  background: none;
  color: var(--text-muted);
}

.dm-bubble-photo:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
  .dm-bubble {
    width: calc(100vw - 20px);
    height: 50vh;
    bottom: 10px !important;
    right: 10px !important;
    left: 10px !important;
  }

  .dm-bubble-minimized {
    width: 200px;
    left: auto !important;
  }
}

@media (max-width: 480px) {
  .dm-bubble {
    width: 100vw;
    height: 50vh;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    border-radius: 12px 12px 0 0;
  }
}
