/* AIorder in-app chat widget (#17) */
:root {
  --aw-navy: #243447;
  --aw-blue: #3399ff;
  --aw-orange: #ff6b35;
  --aw-paper: #f0ede6;
  --aw-sky: #d1e8ff;
  --aw-shadow: 0 8px 32px rgba(36,52,71,.25);
}

#aw-fab {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: 20px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--aw-paper);
  border: 3px solid var(--aw-blue);
  cursor: pointer;
  box-shadow: var(--aw-shadow);
  z-index: 9998;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s, transform .15s;
}
#aw-fab img, #aw-fab svg { width: 100%; height: 100%; display: block; }
#aw-fab:hover { border-color: var(--aw-orange); transform: scale(1.05); }
#aw-fab.aw-hidden { display: none; }

#aw-teaser {
  position: fixed;
  bottom: calc(36px + env(safe-area-inset-bottom));
  right: 96px;
  background: white;
  color: var(--aw-navy);
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  box-shadow: var(--aw-shadow);
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  max-width: 220px;
  line-height: 1.35;
  z-index: 9997;
  cursor: pointer;
  animation: aw-pop .3s ease-out;
}
#aw-teaser .aw-teaser-close {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--aw-navy);
  color: white;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  line-height: 1;
}
#aw-teaser.aw-hidden { display: none; }
@keyframes aw-pop {
  from { opacity: 0; transform: scale(.8) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@media (max-width: 480px) {
  #aw-teaser { max-width: 180px; font-size: 12px; right: 90px; }
}

#aw-fab .aw-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--aw-orange);
  color: white;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}
#aw-fab .aw-badge.aw-show { display: flex; }

#aw-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  height: 100dvh;
  background: var(--aw-paper);
  z-index: 9999;
  display: none;
  flex-direction: column;
  font-family: 'Montserrat', system-ui, sans-serif;
}
#aw-panel.aw-open { display: flex; }

@media (min-width: 768px) {
  #aw-panel {
    bottom: 90px;
    right: 20px;
    left: auto;
    width: 380px;
    height: 600px;
    max-height: calc(100dvh - 110px);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--aw-shadow);
  }
}

#aw-header {
  background: var(--aw-navy);
  color: var(--aw-paper);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: calc(16px + env(safe-area-inset-top));
}
#aw-header .aw-title {
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#aw-header .aw-title::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
}
#aw-header .aw-close {
  background: none;
  border: none;
  color: var(--aw-paper);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

#aw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--aw-paper);
}

.aw-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.aw-bubble.aw-user {
  align-self: flex-end;
  background: var(--aw-blue);
  color: white;
  border-bottom-right-radius: 4px;
}
.aw-bubble.aw-assistant {
  align-self: flex-start;
  background: white;
  color: var(--aw-navy);
  border: 1px solid var(--aw-sky);
  border-bottom-left-radius: 4px;
}
.aw-bubble.aw-typing {
  display: flex;
  gap: 4px;
  padding: 14px;
}
.aw-bubble.aw-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--aw-blue);
  opacity: .4;
  animation: aw-blink 1.2s infinite;
}
.aw-bubble.aw-typing span:nth-child(2) { animation-delay: .2s; }
.aw-bubble.aw-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aw-blink {
  0%, 60%, 100% { opacity: .4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.aw-bubble.aw-error {
  align-self: center;
  background: #fee;
  color: #c00;
  font-size: 12px;
  border: 1px solid #fcc;
}
.aw-bubble.aw-processing {
  color: #476582;
  font-size: 13px;
  font-style: italic;
}

#aw-input-row {
  display: flex;
  padding: 12px;
  gap: 8px;
  background: white;
  border-top: 1px solid var(--aw-sky);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
#aw-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--aw-sky);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
#aw-input:focus { border-color: var(--aw-blue); }
#aw-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--aw-blue);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
#aw-send:disabled { opacity: .5; cursor: not-allowed; }
#aw-send:not(:disabled):hover { background: var(--aw-orange); }

#aw-confirm-banner {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: white;
  padding: 10px 14px;
  font-size: 13px;
  text-align: center;
  display: none;
}
#aw-confirm-banner.aw-show { display: block; }
