*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #e85d04;
  --primary-dark:  #c44d03;
  --primary-light: #fff0e6;
  --accent:        #f4a261;
  --bg:            #fff8f2;
  --white:         #ffffff;
  --text:          #1f2937;
  --text-muted:    #6b7280;
  --border:        #e5e7eb;
  --shadow-sm:     0 2px 8px rgba(0,0,0,.07);
  --shadow-md:     0 4px 16px rgba(0,0,0,.11);
  --radius:        20px;
}

html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ── App shell ─────────────────────────────────────────────────────────── */

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: var(--shadow-md);
}

/* ── Header ────────────────────────────────────────────────────────────── */

.header { background: var(--primary); padding: 14px 18px; flex-shrink: 0; z-index: 10; }
.header-content { display: flex; align-items: center; gap: 12px; }
.bot-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.bot-info { flex: 1; }
.bot-info h1 { font-size: 17px; font-weight: 700; color: #fff; }
.status { font-size: 12px; color: #fde68a; font-weight: 500; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.cart-btn {
  display: flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.2); border: none; border-radius: 20px;
  color: #fff; font-size: 13px; font-weight: 600;
  padding: 5px 12px; cursor: pointer; transition: background .2s;
}
.cart-btn:hover { background: rgba(255,255,255,.35); }
.cart-count {
  background: #fde68a; color: var(--primary-dark);
  border-radius: 99px; padding: 1px 6px; font-size: 11px; font-weight: 700;
}
.admin-link { color: rgba(255,255,255,.7); font-size: 18px; text-decoration: none; padding: 4px; transition: color .2s; }
.admin-link:hover { color: #fff; }

/* ── Messages area ─────────────────────────────────────────────────────── */

.chat-container { flex: 1; overflow-y: auto; padding: 16px; scroll-behavior: smooth; }
.messages { display: flex; flex-direction: column; gap: 12px; }

/* ── Message bubbles ───────────────────────────────────────────────────── */

.message { display: flex; flex-direction: column; max-width: 82%; animation: fadeSlideIn .25s ease both; }
.message.user  { align-self: flex-end; }
.message.bot   { align-self: flex-start; }
.message.wide  { max-width: 100%; width: 100%; }

.bubble {
  padding: 11px 15px;
  border-radius: var(--radius);
  font-size: 14px; line-height: 1.55;
  box-shadow: var(--shadow-sm);
  word-break: break-word;
}
.message.user .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 5px; }
.message.bot  .bubble { background: var(--white); color: var(--text); border-bottom-left-radius: 5px; }
.message.wide .bubble { background: transparent; box-shadow: none; padding: 0; }

.message-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; padding: 0 4px; }
.message.user .message-time { text-align: right; }

/* ── Item cards ────────────────────────────────────────────────────────── */

.item-cards { display: flex; flex-direction: column; gap: 8px; width: 100%; }

.item-card {
  background: var(--white);
  border-radius: 14px;
  border-left: 4px solid var(--accent);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.item-card-body { display: flex; gap: 10px; align-items: flex-start; }
.item-info { flex: 1; }
.item-name { font-size: 14px; font-weight: 600; color: var(--text); }
.item-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.item-meta { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.item-price { font-size: 15px; font-weight: 700; color: var(--primary); }
.item-time  { font-size: 11px; color: var(--text-muted); }
.item-stock { font-size: 11px; color: #059669; font-weight: 500; }
.item-provider { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.item-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; flex-shrink: 0; }

.add-btn {
  background: var(--primary); color: #fff;
  border: none; border-radius: 20px;
  padding: 6px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .2s, transform .1s;
  white-space: nowrap;
}
.add-btn:hover  { background: var(--primary-dark); }
.add-btn:active { transform: scale(.96); }

.qty-controls { display: flex; align-items: center; gap: 6px; }
.qty-btn {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--primary); color: var(--primary);
  background: var(--white); font-size: 16px; font-weight: 700;
  cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.qty-btn:hover { background: var(--primary); color: #fff; }
.qty-val { font-size: 15px; font-weight: 700; min-width: 20px; text-align: center; }
.qty-input {
  width: 44px; text-align: center; font-size: 15px; font-weight: 700;
  border: 2px solid var(--primary); border-radius: 8px;
  padding: 2px 4px; background: var(--white); color: var(--text);
  -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.in-cart-label { font-size: 11px; color: #059669; font-weight: 500; }

/* ── Cart bubble ───────────────────────────────────────────────────────── */

.cart-bubble { font-size: 14px; line-height: 1.6; }
.cart-provider { margin-bottom: 10px; }
.cart-item { padding-left: 10px; font-size: 13px; color: var(--text-muted); }
.cart-delivery-cost { padding-left: 10px; font-size: 13px; color: #0369a1; margin-top: 2px; }
.cart-address { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.cart-total { margin-top: 10px; font-size: 15px; border-top: 1px solid var(--border); padding-top: 8px; }

/* ── Typing indicator ──────────────────────────────────────────────────── */

.typing-indicator {
  display: flex; gap: 5px; padding: 12px 15px;
  background: var(--white); border-radius: var(--radius); border-bottom-left-radius: 5px;
  width: fit-content; box-shadow: var(--shadow-sm);
}
.dot { width: 7px; height: 7px; background: var(--primary); border-radius: 50%; animation: bounce 1.3s infinite ease-in-out; }
.dot:nth-child(2) { animation-delay: .18s; }
.dot:nth-child(3) { animation-delay: .36s; }

/* ── Quick buttons ─────────────────────────────────────────────────────── */

.quick-buttons {
  padding: 6px 14px 10px; display: flex; flex-wrap: wrap; gap: 7px;
  flex-shrink: 0; min-height: 10px; max-height: 170px; overflow-y: auto;
}
.quick-btn {
  background: var(--white); border: 2px solid var(--primary); color: var(--primary);
  border-radius: 24px; padding: 7px 16px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .18s, color .18s, transform .1s; font-family: inherit;
}
.quick-btn:hover  { background: var(--primary); color: #fff; }
.quick-btn:active { transform: scale(.97); }

/* ── Input area ────────────────────────────────────────────────────────── */

.input-area {
  display: flex; gap: 9px; align-items: center;
  padding: 10px 14px; background: var(--white);
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.input-area input {
  flex: 1; border: 2px solid var(--border); border-radius: 24px;
  padding: 9px 16px; font-size: 14px; font-family: inherit; outline: none;
  transition: border-color .2s; background: #fafafa;
}
.input-area input:focus { border-color: var(--primary); background: #fff; }
.send-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary); border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: background .2s, transform .1s;
}
.send-btn:hover  { background: var(--primary-dark); }
.send-btn:active { transform: scale(.94); }

/* ── Toast ─────────────────────────────────────────────────────────────── */

.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: #1f2937; color: #fff; border-radius: 24px;
  padding: 8px 20px; font-size: 13px; font-weight: 500;
  opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Animations ────────────────────────────────────────────────────────── */

@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

/* ── Scrollbar ─────────────────────────────────────────────────────────── */

.chat-container::-webkit-scrollbar       { width: 4px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ── Admin page ────────────────────────────────────────────────────────── */

.admin-page { padding: 24px; max-width: 960px; margin: 0 auto; }
.admin-page h2 { font-size: 22px; color: var(--primary); margin-bottom: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: 12px; padding: 16px; box-shadow: var(--shadow-sm); text-align: center; }
.stat-card .value { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.progress-bar-wrap { background: #e5e7eb; border-radius: 99px; height: 10px; margin: 4px 0; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; background: var(--primary); transition: width .5s; }
.progress-bar.warning { background: var(--accent); }
.progress-bar.danger  { background: #ef4444; }
table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--white); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm); margin-bottom: 24px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--primary-light); color: var(--primary); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 12px; background: var(--white); padding: 18px; border-radius: 12px; box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.form-grid label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 13px; outline: none; transition: border-color .2s; }
.form-grid input:focus, .form-grid select:focus { border-color: var(--primary); }
.btn { padding: 9px 20px; border-radius: 8px; border: none; font-family: inherit; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .2s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #ef4444; color: #fff; }
.tab-nav { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn { padding: 8px 18px; border-radius: 20px; border: 2px solid var(--primary); background: transparent; color: var(--primary); font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: all .2s; }
.tab-btn.active { background: var(--primary); color: #fff; }
.section { display: none; }
.section.active { display: block; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.provider-section { background: var(--white); border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.provider-section h3 { color: var(--primary); margin-bottom: 10px; font-size: 15px; }
.items-list { display: grid; gap: 6px; }
.item-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: var(--bg); border-radius: 8px; font-size: 13px; }
.item-row-info { flex: 1; }
.item-row-price { font-weight: 600; color: var(--primary); }

@media (max-width: 600px) { .admin-page { padding: 14px; } }

/* ── Provider cards (multi-select) ──────────────────────────────────── */
.provider-cards { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.provider-card {
  border: 2px solid var(--border); border-radius: 14px; background: var(--white);
  transition: border-color .15s, background .15s, box-shadow .15s; cursor: pointer;
}
.provider-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.provider-card.selected {
  border-color: var(--primary); background: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary);
}
.provider-card-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px 12px; }
/* Checkbox circular */
.provider-check {
  width: 22px; height: 22px; min-width: 22px; margin-top: 1px;
  border: 2px solid var(--border); border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
}
.provider-check::after {
  content: '';
  width: 5px; height: 9px;
  border-right: 2px solid transparent; border-bottom: 2px solid transparent;
  transform: rotate(45deg) translateY(-1px);
  transition: border-color .15s;
}
.provider-card.selected .provider-check { background: var(--primary); border-color: var(--primary); }
.provider-card.selected .provider-check::after { border-right-color: #fff; border-bottom-color: #fff; }
.provider-info { flex: 1; min-width: 0; }
.provider-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.provider-name { font-weight: 600; font-size: 14px; }
.provider-distance { font-size: 11px; font-weight: 600; color: var(--primary); background: var(--primary-light); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.provider-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.confirm-providers-btn {
  width: 100%; margin-top: 4px; padding: 12px;
  background: var(--primary); color: #fff; border: none; border-radius: 12px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.confirm-providers-btn:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }
.confirm-providers-btn:not(:disabled):hover { background: var(--primary-dark); }
.back-providers-btn {
  width: 100%; margin-top: 6px; padding: 10px;
  background: transparent; color: var(--text-muted); border: 1px solid var(--border); border-radius: 12px;
  font-size: 13px; cursor: pointer; transition: background .15s, color .15s;
}
.back-providers-btn:hover { background: var(--border); color: var(--text); }
