:root {
  --navy-950: #081322;
  --navy-900: #0b192c;
  --navy-800: #132945;
  --navy-700: #1e3a5f;
  --gold-500: #d49a2a;
  --gold-400: #eab308;
  --gold-100: #fef6e4;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(11, 25, 44, 0.05);
  --shadow-md: 0 8px 24px rgba(11, 25, 44, 0.08);
  --shadow-lg: 0 18px 40px rgba(11, 25, 44, 0.14);
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* =========================================================================
   SHARED HEADER & CONTROLS
   ========================================================================= */
.site-header {
  background: #000000;
  color: #fff;
  height: 58px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  z-index: 30;
}

.header-logo-horizontal {
  height: 30px;
  width: auto;
  display: block;
  object-fit: contain;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-monogram {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.4px;
  line-height: 1.1;
}

.brand-text span {
  display: block;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--gold-400);
  margin-top: 2px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.header-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.header-pill:hover { background: rgba(255, 255, 255, 0.2); }
.header-pill.active { background: #fff; color: var(--navy-900); border-color: #fff; }
.header-pill.gold {
  background: rgba(234, 179, 8, 0.2);
  border-color: rgba(234, 179, 8, 0.5);
  color: #fde68a;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--navy-900); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-800); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-gold { background: linear-gradient(135deg, #d99b26, #b87c14); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; border-color: var(--border-strong); color: var(--navy-900); }
.btn-outline:hover:not(:disabled) { background: var(--surface-soft); border-color: var(--navy-700); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: #e2e8f0; color: var(--navy-900); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 12px 18px; font-size: 14.5px; width: 100%; }

/* Inputs & Cards */
.input, .select, .textarea {
  width: 100%;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px 11px;
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}
.textarea { resize: vertical; min-height: 60px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 12px; font-weight: 700; color: var(--navy-900); }
.form-label .req { color: var(--danger); }
.hint { font-size: 12px; color: var(--text-light); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 14px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.card-title { margin: 0; font-size: 15.5px; font-weight: 700; color: var(--navy-900); }

/* Badges & Alerts */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-confirmed { background: #dbeafe; color: #1e40af; }
.badge-bill { background: #fce7f3; color: #9d174d; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-processing { background: #e0e7ff; color: #3730a3; }
.badge-shipping { background: #cffafe; color: #155e75; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

.alert { border-radius: 11px; padding: 10px 12px; font-size: 13px; border: 1px solid transparent; }
.alert-warn { background: var(--warning-bg); border-color: #fde68a; color: #78350f; }
.alert-info { background: var(--info-bg); border-color: #bfdbfe; color: #1e3a8a; }
.alert-success { background: var(--success-bg); border-color: #a7f3d0; color: #065f46; }
.alert-danger { background: var(--danger-bg); border-color: #fecaca; color: #991b1b; }

/* =========================================================================
   CUSTOMER ULTRA-SIMPLE ZALO-STYLE CHAT SHELL
   ========================================================================= */
.customer-app-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 680px;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: 0 0 36px rgba(8, 19, 34, 0.1);
}

@media (max-width: 680px) {
  .customer-app-shell { max-width: 100%; box-shadow: none; }
}

.welcome-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: linear-gradient(180deg, #f8fafc 0%, #eaf0f7 100%);
}

.welcome-box {
  width: 100%;
  max-width: 410px;
  background: #fff;
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  text-align: center;
}

.welcome-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--navy-900);
  color: #fff;
  border: 3px solid var(--gold-400);
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 700;
  margin: 0 auto 12px;
}

/* =========================================================================
   CHAT MESSAGES & INTERACTIVE CARDS (SHARED BY CUSTOMER & ADMIN)
   ========================================================================= */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: #e9eff6;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 88%;
}

.msg-row.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-row.theirs {
  align-self: flex-start;
}

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--navy-900);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1.5px solid var(--gold-400);
}

.msg-avatar.cust {
  background: #64748b;
  border-color: #cbd5e1;
}

.msg-bubble {
  border-radius: 16px;
  padding: 10px 13px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.msg-row.theirs .msg-bubble {
  background: #ffffff;
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg-row.mine .msg-bubble {
  background: var(--navy-900);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.msg-time {
  font-size: 10.5px;
  color: var(--text-light);
  margin-top: 4px;
  padding: 0 4px;
}

.msg-row.mine .msg-time { text-align: right; }

.msg-image {
  display: block;
  max-width: 260px;
  width: 100%;
  border-radius: 12px;
  margin-top: 6px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  cursor: pointer;
}

/* Rich Interactive Cards Inside Chat */
.chat-card {
  background: #ffffff;
  border: 1.5px solid var(--border-strong);
  border-radius: 16px;
  padding: 14px;
  width: 340px;
  max-width: 100%;
  color: var(--text);
  box-shadow: var(--shadow-md);
}

.chat-card.order-card { border-color: var(--navy-700); }
.chat-card.qr-card-chat { border-color: var(--navy-900); }
.chat-card.paid-card-chat {
  border-color: var(--success);
  background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 55%);
}

.chat-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.chat-card-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--navy-900);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.chat-order-line {
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.chat-order-line:last-child { border-bottom: none; }

.emb-highlight {
  margin-top: 5px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #78350f;
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 12.5px;
}

.emb-highlight strong { font-size: 14px; }

.chat-qr-img {
  display: block;
  width: 100%;
  max-width: 240px;
  margin: 10px auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 6px;
}

.copy-kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
}
.copy-kv:last-child { border-bottom: none; }

/* Chat Composer Bar */
.chat-composer {
  background: #ffffff;
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.composer-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 18px;
  flex-shrink: 0;
  transition: background 0.14s ease;
}
.composer-icon-btn:hover { background: #e2e8f0; }

.composer-input {
  flex: 1;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 14px;
  max-height: 110px;
  min-height: 40px;
  resize: none;
  line-height: 1.4;
}
.composer-input:focus {
  outline: none;
  border-color: var(--navy-700);
}

.composer-send-btn {
  height: 40px;
  padding: 0 16px;
  border-radius: 12px;
  border: none;
  background: var(--navy-900);
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  flex-shrink: 0;
}
.composer-send-btn:hover { background: var(--navy-800); }

/* =========================================================================
   ADMIN 3-COLUMN ZALO-PC WORKSPACE
   ========================================================================= */
.admin-body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.zalo-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(360px, 1fr) 390px;
  height: 100%;
  overflow: hidden;
}

@media (max-width: 1180px) {
  .zalo-workspace {
    grid-template-columns: 260px minmax(300px, 1fr) 340px;
  }
}

@media (max-width: 920px) {
  .zalo-workspace {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
}

/* Column 1: Inbox */
.col-inbox {
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inbox-top {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inbox-filters {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.chip-btn {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-muted);
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.chip-btn.active {
  background: var(--navy-900);
  color: #fff;
  border-color: var(--navy-900);
}

.inbox-list {
  flex: 1;
  overflow-y: auto;
}

.inbox-item {
  padding: 11px 12px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  transition: background 0.12s ease;
}
.inbox-item:hover { background: #f8fafc; }
.inbox-item.active {
  background: #eaf1fb;
  border-left: 3.5px solid var(--navy-900);
}

.inbox-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--navy-800);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  position: relative;
}

.unread-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
}

.inbox-meta {
  flex: 1;
  min-width: 0;
}

.inbox-name-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.inbox-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inbox-preview {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Column 2: Chat Area */
.col-chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #e9eff6;
}

.chat-topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.quick-replies-bar {
  background: #f8fafc;
  border-top: 1px solid var(--border);
  padding: 7px 10px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex-shrink: 0;
}

.qr-chip {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--navy-900);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.qr-chip:hover {
  background: var(--navy-900);
  color: #fff;
  border-color: var(--navy-900);
}

/* Column 3: Staff Tools (Order Builder, Custom QR, Embroidery) */
.col-tools {
  background: #ffffff;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tools-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  flex-shrink: 0;
}

.tools-tab-btn {
  border: none;
  background: transparent;
  padding: 11px 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
}
.tools-tab-btn.active {
  color: var(--navy-900);
  border-bottom-color: var(--navy-900);
  background: #fff;
}

.tools-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.tool-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface-soft);
  margin-bottom: 12px;
}

.upload-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  background: #fff;
  cursor: pointer;
}
.upload-dropzone:hover { border-color: var(--navy-700); background: #eef4fb; }

/* Full Scroll Page Container (for Orders/Embroidery/Settings tabs in Admin) */
.page-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 48px;
}

.container {
  max-width: 1220px;
  margin: 0 auto;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f8fafc; font-size: 11.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }

/* Modals & Toasts */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 19, 34, 0.62);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-panel {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 20px;
}

.toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 350px;
}

.toast {
  background: var(--navy-900);
  color: #fff;
  padding: 11px 15px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--gold-400);
}
.toast.success { border-left-color: #10b981; }
.toast.error { border-left-color: #ef4444; background: #7f1d1d; }

/* Official Brand Assets, Pagination & AI Agent UI */
.brand-icon-img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  flex-shrink: 0;
}

.msg-avatar-img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 1.5px solid var(--border-strong);
  flex-shrink: 0;
}

.welcome-brand-stack {
  background: #ffffff;
  padding: 6px 8px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.welcome-icon-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: #ffffff;
}

.welcome-logo-black {
  max-width: 196px;
  width: 100%;
  height: auto;
  display: block;
}

.load-more-wrap {
  text-align: center;
  padding: 2px 0 6px;
}

.load-more-btn {
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.92);
  color: var(--navy-900);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.load-more-btn:hover { background: #fff; border-color: var(--navy-900); }

.ai-draft-bar {
  background: linear-gradient(135deg, #eef2ff 0%, #fefce8 100%);
  border-top: 1.5px solid #c7d2fe;
  padding: 9px 12px;
  flex-shrink: 0;
}

.ai-draft-text {
  font-size: 13px;
  color: var(--navy-900);
  white-space: pre-wrap;
  background: #fff;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  padding: 8px 10px;
  margin: 6px 0;
}

.ai-bill-box {
  margin-top: 6px;
  padding: 7px 9px;
  border-radius: 9px;
  font-size: 12px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #065f46;
}
.ai-bill-box.warn {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

/* Slash-Command Quick Template Popup (Zalo-style) */
.slash-popup {
  background: #ffffff;
  border-top: 1.5px solid var(--navy-700);
  max-height: 230px;
  overflow-y: auto;
  box-shadow: 0 -6px 20px rgba(8, 19, 34, 0.12);
  flex-shrink: 0;
}

.slash-item {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.slash-item:hover { background: #eef4fb; }

.tpl-thumb-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.tpl-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-strong);
}

.hidden { display: none !important; }
