.delivery-chat-button {
  position: relative;
  border: 0;
  background: #17191c;
  color: #fff;
  font-weight: 800;
}

.delivery-chat-button:hover { background: #292c31; color: #fff; }
.chat-badge { display: grid; position: absolute; top: -8px; right: -7px; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border: 2px solid #fff; border-radius: 999px; background: #ff3b30; color: #fff; font-size: .72rem; }
.delivery-chat-panel { margin-top: 14px; overflow: hidden; border: 1px solid #e5e7eb; border-radius: 22px; background: #f6f7f8; }
.delivery-chat-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #e5e7eb; background: #fff; }
.delivery-chat-head > span { display: flex; align-items: center; gap: 9px; }
.delivery-chat-head i { color: #ff6b00; }
.delivery-chat-head button { border: 0; background: transparent; color: #667085; }
.delivery-chat-messages { display: flex; flex-direction: column; gap: 8px; max-height: 250px; min-height: 120px; overflow-y: auto; padding: 14px; }
.chat-message { display: grid; align-self: flex-start; max-width: 82%; padding: 9px 12px; border-radius: 16px 16px 16px 5px; background: #fff; box-shadow: 0 4px 14px rgba(15,23,42,.06); }
.chat-message.mine { align-self: flex-end; border-radius: 16px 16px 5px 16px; background: #ff6b00; color: #fff; }
.chat-message strong { font-size: .72rem; opacity: .72; }
.chat-message small { justify-self: end; margin-top: 3px; font-size: .65rem; opacity: .65; }
.chat-empty { margin: auto; color: #667085; font-size: .86rem; text-align: center; }
.chat-empty.chat-error { display: grid; justify-items: center; gap: 7px; color: #b42318; }
.chat-empty.chat-error strong { color: #7a271a; }
.chat-retry {
  padding: 7px 13px;
  border: 0;
  border-radius: 999px;
  background: #17191c;
  color: #fff;
  font-size: .76rem;
  font-weight: 800;
}
.delivery-chat-compose { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e5e7eb; background: #fff; }
.delivery-chat-compose input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border: 1px solid #d0d5dd; border-radius: 14px; outline: none; }
.delivery-chat-compose input:focus { border-color: #ff6b00; box-shadow: 0 0 0 3px rgba(255,107,0,.12); }
.delivery-chat-compose button { display: grid; flex: 0 0 44px; place-items: center; border: 0; border-radius: 14px; background: #ff6b00; color: #fff; }
.delivery-chat-compose button:disabled { cursor: wait; opacity: .55; }
@media (max-width: 575px) { .tracking-actions { grid-template-columns: 1fr 1fr; } .tracking-actions .delivery-chat-button { grid-column: span 1; } .chat-message { max-width: 88%; } }

.delivery-event-alert {
  display: flex;
  position: fixed;
  z-index: 9999;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  align-items: center;
  gap: 12px;
  width: min(calc(100vw - 28px), 440px);
  padding: 13px 14px;
  transform: translateX(-50%);
  border: 1px solid rgba(0,168,107,.35);
  border-radius: 20px;
  background: linear-gradient(135deg, #effcf7, #fff);
  box-shadow: 0 22px 60px rgba(15,23,42,.25);
  animation: deliveryEventIn .32s ease-out both;
}
.delivery-event-alert.accepted,
.delivery-event-alert.picked-up,
.delivery-event-alert.delivered { border-color: #8fdab8; background: linear-gradient(135deg, #e8fbf2, #fff); }
.delivery-event-alert > span:nth-child(2) { display: grid; flex: 1; }
.delivery-event-alert strong { color: #17191c; font-size: .95rem; }
.delivery-event-alert small { color: #667085; }
.delivery-event-icon { display: grid; flex: 0 0 44px; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: #dff8ec; color: #008a58; font-size: 1.2rem; }
.delivery-event-alert button { border: 0; background: transparent; color: #667085; }
@keyframes deliveryEventIn { from { opacity: 0; transform: translate(-50%, -18px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* Acciones apiladas: Chat conserva toda el área táctil incluso cuando también
   aparece Cancelar. Evita dos botones estrechos en iPhone. */
.tracking-actions {
  grid-template-columns: 1fr !important;
}

.tracking-actions .delivery-chat-button {
  grid-column: 1 / -1 !important;
  width: 100% !important;
}
