/* Reusable components: cards, tables, buttons, badges, chat, modals */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-m); box-shadow: var(--shadow-s); padding: 18px;
}
.card h3 { font-size: .98rem; margin-bottom: 12px; }
.card .card-sub { color: var(--text-3); font-size: .78rem; margin-top: -8px; margin-bottom: 12px; }

/* Stat tiles */
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .label { color: var(--text-2); font-size: .8rem; }
.stat .value { font-size: 1.55rem; font-weight: 800; letter-spacing: -.5px; }
.stat .delta { font-size: .76rem; color: var(--text-3); }
.stat .delta.up { color: var(--green-600); }
.stat .delta.down { color: var(--red-600); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: .88rem; font-weight: 600; transition: .12s;
}
.btn:hover { border-color: var(--border-2); background: var(--surface-2); }
.btn.primary { background: var(--orange-500); border-color: var(--orange-500); color: #fff; }
.btn.primary:hover { background: var(--orange-600); }
.btn.blue { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn.blue:hover { background: var(--blue-500); }
.btn.danger { color: var(--red-600); border-color: var(--red-100); }
.btn.small { padding: 5px 10px; font-size: .78rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; justify-content: center; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 999px; font-size: .72rem; font-weight: 700;
}
.badge.green { background: var(--green-100); color: var(--green-600); }
.badge.blue { background: var(--blue-100); color: var(--blue-600); }
.badge.orange { background: var(--orange-100); color: var(--orange-600); }
.badge.red { background: var(--red-100); color: var(--red-600); }
.badge.amber { background: var(--amber-100); color: var(--amber-600); }
.badge.gray { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge.lock::before { content: "🔒"; font-size: .7rem; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-m); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th {
  text-align: left; padding: 11px 14px; background: var(--surface-2);
  color: var(--text-2); font-size: .74rem; text-transform: uppercase;
  letter-spacing: .5px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td .mono { font-family: var(--mono); font-size: .8rem; color: var(--text-2); }
.shelf-chip {
  font-family: var(--mono); font-weight: 700; font-size: .78rem;
  background: var(--amber-100); color: var(--amber-600);
  padding: 2px 8px; border-radius: 6px;
}

/* Forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: .78rem; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--blue-100); border-color: var(--blue-500);
}
.form-row { display: flex; gap: 10px; }
.form-row .field { flex: 1; }

/* Chat */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; height: calc(100vh - 150px); }
.conv-list { overflow-y: auto; padding: 8px; }
.conv-item {
  display: flex; gap: 11px; width: 100%; padding: 11px; border: 0;
  border-radius: var(--radius-s); background: transparent; text-align: left; color: var(--text);
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--blue-100); }
.conv-meta { flex: 1; min-width: 0; }
.conv-meta b { display: flex; align-items: center; gap: 6px; font-size: .88rem; }
.conv-meta p { color: var(--text-3); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-thread { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 11px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.enc-note {
  text-align: center; font-size: .72rem; color: var(--amber-600);
  background: var(--amber-100); margin: 10px auto; padding: 5px 14px; border-radius: 999px;
}
.chat-body { flex: 1; overflow-y: auto; padding: 8px 18px; display: flex; flex-direction: column; gap: 8px; }
.bubble {
  max-width: 68%; padding: 9px 13px; border-radius: 14px; font-size: .88rem;
  line-height: 1.4; position: relative;
}
.bubble.me { align-self: flex-end; background: var(--blue-600); color: #fff; border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble .meta { display: block; font-size: .66rem; opacity: .7; margin-top: 3px; text-align: right; }
.chat-input { display: flex; gap: 9px; padding: 13px 18px; border-top: 1px solid var(--border); }
.chat-input input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text); }
.quick-templates { display: flex; gap: 7px; padding: 0 18px 10px; flex-wrap: wrap; }

/* Avatars */
.biz-avatar {
  width: 40px; height: 40px; min-width: 40px; border-radius: 11px;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .9rem;
}

/* POS cart */
.pos-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
.cart-line { display: flex; align-items: center; gap: 9px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.cart-line .name { flex: 1; font-size: .86rem; }
.cart-line input { width: 62px; padding: 5px 7px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); }
.totals-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: .9rem; }
.totals-row.grand { font-size: 1.15rem; font-weight: 800; border-top: 2px solid var(--border); padding-top: 10px; }
.pay-row { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.pay-row select { flex: 1; }
.pay-row input { width: 110px; }
.pay-remaining { font-size: .82rem; padding: 8px 10px; border-radius: 8px; }
.pay-remaining.ok { background: var(--green-100); color: var(--green-600); }
.pay-remaining.warn { background: var(--red-100); color: var(--red-600); }

/* States */
.empty-state { text-align: center; padding: 46px 18px; color: var(--text-3); }
.empty-state .big { font-size: 2.2rem; margin-bottom: 10px; }
.error-state { text-align: center; padding: 36px; color: var(--red-600); }
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; min-height: 16px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.fade-in { animation: fadein .18s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8, 15, 35, .55);
  display: grid; place-items: center; z-index: 100;
}
.modal {
  width: min(560px, 94vw); max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--radius-l);
  padding: 24px; box-shadow: var(--shadow-m);
}
.modal h2 { font-size: 1.1rem; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }

/* Toast */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  padding: 12px 18px; border-radius: 11px; background: var(--navy-800); color: #fff;
  font-size: .86rem; box-shadow: var(--shadow-m); animation: fadein .2s;
}
.toast.error { background: var(--red-600); }
.toast.success { background: var(--green-600); }

/* Mini chart */
.bars { display: flex; align-items: flex-end; gap: 5px; height: 120px; }
.bars .bar { flex: 1; background: var(--blue-500); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; }
.bars .bar:hover { background: var(--orange-500); }
.bars .bar .tip {
  display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--navy-900); color: #fff; font-size: .68rem; padding: 3px 8px;
  border-radius: 6px; white-space: nowrap; margin-bottom: 4px; z-index: 5;
}
.bars .bar:hover .tip { display: block; }

/* Activity feed */
.feed-item { display: flex; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .85rem; }
.feed-item:last-child { border-bottom: 0; }
.feed-icon { width: 34px; height: 34px; min-width: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); }
.feed-item .when { color: var(--text-3); font-size: .74rem; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-size: .82rem; font-weight: 600;
}
.tab.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }

/* Receipt preview */
.receipt { font-family: var(--mono); font-size: .78rem; background: #fffef5; color: #1c1917; border: 1px dashed #d6d3d1; border-radius: 8px; padding: 18px; }
[data-theme="dark"] .receipt { background: #1c1917; color: #e7e5e4; border-color: #44403c; }
.receipt hr { border: 0; border-top: 1px dashed #a8a29e; margin: 8px 0; }
.receipt .r-row { display: flex; justify-content: space-between; }
.receipt .r-center { text-align: center; }
.receipt .r-foot { text-align: center; font-size: .7rem; margin-top: 10px; color: #78716c; }
