/* ============================================================
   Messify Delivery — app.css  v2.0  (UI/UX Pro Max)
   Tema dual: html.theme-dark / html.theme-light
   ============================================================ */

/* ── DARK THEME ─────────────────────────────────────── */
html.theme-dark {
  --bg:              #080e1a;
  --card-bg:         rgba(14, 20, 36, 0.92);
  --card-bg-2:       rgba(18, 26, 46, 0.88);
  --border:          rgba(255,255,255,0.07);
  --border-strong:   rgba(255,255,255,0.13);
  --text:            #f1f5f9;
  --muted:           #64748b;
  --muted2:          #94a3b8;
  --primary:         #6366f1;
  --primary-hover:   #4f46e5;
  --primarySoft:     rgba(99,102,241,0.14);
  --topbar-bg:       rgba(8,14,26,0.82);
  --input-bg:        rgba(255,255,255,0.05);
  --input-bg-focus:  rgba(99,102,241,0.08);
  --conv-bg:         rgba(255,255,255,0.03);
  --msg-area-bg:     rgba(0,0,0,0.18);
  --orderbox-bg:     rgba(0,0,0,0.18);
  --msg-in-bg:       rgba(34,197,94,0.08);
  --msg-in-border:   rgba(34,197,94,0.20);
  --msg-out-bg:      rgba(99,102,241,0.11);
  --msg-out-border:  rgba(99,102,241,0.24);
  --pill-bg:         rgba(255,255,255,0.06);
  --danger:          #f87171;
  --dangerSoft:      rgba(248,113,113,0.12);
  --danger-border:   rgba(248,113,113,0.28);
  --success:         #4ade80;
  --successSoft:     rgba(74,222,128,0.12);
  --success-border:  rgba(74,222,128,0.28);
  --warning:         #fbbf24;
  --warningSoft:     rgba(251,191,36,0.12);
  --shadow-sm:       0 1px 4px rgba(0,0,0,0.5);
  --shadow-md:       0 4px 16px rgba(0,0,0,0.55);
  --shadow-lg:       0 8px 32px rgba(0,0,0,0.65);
  --glow-primary:    0 0 0 3px rgba(99,102,241,0.22);
}

html.theme-dark body {
  background:
    radial-gradient(ellipse 1400px 700px at 15% -10%, rgba(99,102,241,0.18), transparent 60%),
    radial-gradient(ellipse 900px 600px at 95% 5%,  rgba(34,197,94,0.10),  transparent 55%),
    radial-gradient(ellipse 800px 500px at 50% 100%, rgba(99,102,241,0.08), transparent 60%),
    var(--bg);
}

/* ── LIGHT THEME ─────────────────────────────────────── */
html.theme-light {
  --bg:              #f0f4fa;
  --card-bg:         rgba(255,255,255,0.96);
  --card-bg-2:       rgba(248,250,252,0.96);
  --border:          rgba(0,0,0,0.07);
  --border-strong:   rgba(0,0,0,0.12);
  --text:            #0f172a;
  --muted:           #64748b;
  --muted2:          #94a3b8;
  --primary:         #4f46e5;
  --primary-hover:   #4338ca;
  --primarySoft:     rgba(79,70,229,0.09);
  --topbar-bg:       rgba(255,255,255,0.90);
  --input-bg:        rgba(0,0,0,0.04);
  --input-bg-focus:  rgba(79,70,229,0.05);
  --conv-bg:         rgba(0,0,0,0.025);
  --msg-area-bg:     rgba(0,0,0,0.025);
  --orderbox-bg:     rgba(0,0,0,0.025);
  --msg-in-bg:       rgba(34,197,94,0.07);
  --msg-in-border:   rgba(34,197,94,0.18);
  --msg-out-bg:      rgba(79,70,229,0.07);
  --msg-out-border:  rgba(79,70,229,0.18);
  --pill-bg:         rgba(0,0,0,0.05);
  --danger:          #dc2626;
  --dangerSoft:      rgba(220,38,38,0.08);
  --danger-border:   rgba(220,38,38,0.22);
  --success:         #16a34a;
  --successSoft:     rgba(22,163,74,0.08);
  --success-border:  rgba(22,163,74,0.22);
  --warning:         #d97706;
  --warningSoft:     rgba(217,119,6,0.08);
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.07);
  --shadow-md:       0 4px 14px rgba(0,0,0,0.09);
  --shadow-lg:       0 8px 28px rgba(0,0,0,0.11);
  --glow-primary:    0 0 0 3px rgba(79,70,229,0.16);
}

html.theme-light body {
  background:
    radial-gradient(ellipse 1400px 700px at 15% -10%, rgba(79,70,229,0.05), transparent 60%),
    radial-gradient(ellipse 900px 600px at 95% 5%,  rgba(34,197,94,0.04),  transparent 55%),
    var(--bg);
}

/* ── RESET & BASE ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s ease, color 0.35s ease;
}

.hidden { display: none !important; }

/* ── APP SHELL ───────────────────────────────────────── */
.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── TOPBAR ──────────────────────────────────────────── */
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background 0.3s ease, border-color 0.3s ease;
  flex-shrink: 0;
}

.brand {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.4px;
  background: linear-gradient(135deg, var(--primary) 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pill {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 11px;
  background: var(--pill-bg);
  letter-spacing: 0.1px;
  transition: all 0.3s ease;
}

/* ── THEME TOGGLE ────────────────────────────────────── */
.theme-toggle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--input-bg);
  color: var(--muted2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 14px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--primarySoft);
  border-color: var(--primary);
  color: var(--primary);
  transform: rotate(15deg);
}

/* ── MAIN ────────────────────────────────────────────── */
.main {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ── LOGIN CARD ──────────────────────────────────────── */
#loginCard {
  align-self: center;
  margin: auto;
  width: 100%;
  max-width: 440px;
}

#loginCard h1 {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.6px;
  margin-bottom: 6px;
  color: var(--text);
}

#loginCard .login-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 22px;
  margin-top: 0;
}

/* ── CARD ────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow-md);
  transition: background 0.3s ease, border-color 0.3s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

h1, h2, h3 { margin: 0 0 10px; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; min-height: 16px; line-height: 1.4; }
.sub  { color: var(--muted); font-size: 12px; margin-top: -3px; }

/* ── FORMS ───────────────────────────────────────────── */
.grid { display: grid; gap: 14px; }

label span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 6px;
}

input, select {
  width: 100%;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  font-size: 14px;
  font-family: inherit;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
}
input:focus, select:focus {
  border-color: var(--primary);
  background: var(--input-bg-focus);
  box-shadow: var(--glow-primary);
}
input::placeholder { color: var(--muted); opacity: 0.7; }

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 9px 15px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.1px;
  color: var(--text);
  background: var(--input-bg);
  border-color: var(--border-strong);
  white-space: nowrap;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(99,102,241,0.35);
}
.btn.primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 4px 18px rgba(99,102,241,0.45);
  transform: translateY(-1px);
}

.btn.ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--muted2);
}
.btn.ghost:hover:not(:disabled) {
  background: var(--primarySoft);
  border-color: var(--primary);
  color: var(--primary);
}

.btn.danger {
  background: var(--dangerSoft);
  border-color: var(--danger-border);
  color: var(--danger);
}
.btn.danger:hover:not(:disabled) {
  background: rgba(248,113,113,0.20);
  border-color: var(--danger);
}

.btn.success {
  background: var(--successSoft);
  border-color: var(--success-border);
  color: var(--success);
}
.btn.success:hover:not(:disabled) {
  background: rgba(74,222,128,0.20);
  border-color: var(--success);
}

.btn:disabled { opacity: 0.32; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.98); }

/* ── LAYOUT SPLIT ────────────────────────────────────── */
.split {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }

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

/* ── CONVERSATION LIST (INBOX) ───────────────────────── */
.list {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.list > .row {
  margin-bottom: 6px;
  flex-shrink: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.list h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.conv-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.conv-list::-webkit-scrollbar { width: 4px; }
.conv-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.conv-list::-webkit-scrollbar-track { background: transparent; }

.conv-list.loading { opacity: 0.45; pointer-events: none; }

/* Conversation card */
.conv {
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 11px 13px;
  cursor: pointer;
  background: var(--conv-bg);
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}
.conv::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
  border-radius: 0 2px 2px 0;
  transition: background 0.15s ease;
}
.conv:hover  { border-color: var(--border-strong); background: var(--primarySoft); }
.conv:hover::before { background: var(--primary); opacity: 0.5; }
.conv.active { border-color: rgba(99,102,241,0.40); background: var(--primarySoft); box-shadow: var(--shadow-sm); }
.conv.active::before { background: var(--primary); }

.conv-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}
.conv .t {
  font-weight: 700;
  font-size: 13px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-time {
  font-size: 10.5px;
  color: var(--muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.conv-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Status badge */
.conv-status {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
  flex-shrink: 0;
}
.conv-status.s-new,
.conv-status.s-open      { background: var(--primarySoft); color: var(--primary); border-color: rgba(99,102,241,0.22); }
.conv-status.s-waiting,
.conv-status.s-pending   { background: var(--warningSoft); color: var(--warning); border-color: rgba(251,191,36,0.22); }
.conv-status.s-confirmed { background: var(--successSoft); color: var(--success); border-color: var(--success-border); }
.conv-status.s-closed,
.conv-status.s-cancelled { background: rgba(100,116,139,0.10); color: var(--muted); border-color: var(--border-strong); }

.conv-channel {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--border-strong);
  border-radius: 13px;
  margin-top: 4px;
  line-height: 1.6;
}
.empty-state::before {
  content: '📭';
  display: block;
  font-size: 28px;
  margin-bottom: 10px;
  opacity: 0.7;
}

/* ── DETAIL PANEL ────────────────────────────────────── */
.detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.detail-title h2 {
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 2px;
  letter-spacing: -0.3px;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Messages area */
.messages {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: var(--msg-area-bg);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  transition: background 0.3s ease, border-color 0.3s ease, opacity 0.2s ease;
}
.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.messages.loading { opacity: 0.4; pointer-events: none; }

.msg {
  padding: 9px 12px;
  border-radius: 14px;
  margin: 6px 0;
  max-width: 75%;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}
.msg.in  {
  background: var(--msg-in-bg);
  border: 1px solid var(--msg-in-border);
  border-bottom-left-radius: 4px;
}
.msg.out {
  margin-left: auto;
  background: var(--msg-out-bg);
  border: 1px solid var(--msg-out-border);
  border-bottom-right-radius: 4px;
}
.msg .meta {
  color: var(--muted);
  font-size: 10.5px;
  margin-top: 5px;
  opacity: 0.8;
}

/* Reply area */
.reply-area {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.reply-area input {
  flex: 1;
  border-radius: 12px;
  padding: 10px 14px;
}

/* ── ORDER BOX ───────────────────────────────────────── */
.orderbox {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--orderbox-bg);
  flex-shrink: 0;
  transition: background 0.3s ease, border-color 0.3s ease;
}
.orderbox h3 {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 0 0 12px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

.order-items { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 12px; }

.order-item {
  display: grid;
  grid-template-columns: 52px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--conv-bg);
  font-size: 13px;
}
.order-item .name  { color: var(--text); font-weight: 600; }
.order-item .price { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.order-item input[type="number"] {
  padding: 6px 8px;
  border-radius: 8px;
  width: 52px;
  text-align: center;
}
.order-item .rm {
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 12px;
}
