// ============================================================================
//  SB Chat — client application styles (WhatsApp-style, Uganda Crane brand)
// ============================================================================

:root {
  --brand: #075E54;      /* deep green  */
  --brand-2: #128C7E;    /* teal        */
  --brand-3: #25D366;    /* chat bubble */
  --brand-dark: #054D45;
  --gold: #D4A017;       /* crane crest */
  --bg: #efeae2;
  --panel: #ffffff;
  --wing: #ece5dd;
  --ink: #111b21;
  --muted: #667781;
  --muted-2: #8696a0;
  --danger: #e53935;
  --border: #e6e0d7;
  --tabbar: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

input, button, textarea { font-family: inherit; }
button { cursor: pointer; }

#app { position: fixed; inset: 0; overflow: hidden; background: var(--bg); }

.screen { position: absolute; inset: 0; display: none; flex-direction: column; background: var(--bg); }
.screen.active { display: flex; }

/* ------------------------------------------------------------ header bar */
.hbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--brand); color: #fff;
  padding: 12px 12px;
  flex: 0 0 auto;
}
.hbar .title { font-size: 19px; font-weight: 700; flex: 1; }
.hbar .subtitle { font-size: 12.5px; color: rgba(255,255,255,.82); font-weight: 400; }
.hbtn {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.hbtn:active { background: rgba(255,255,255,.28); }
.hbtn svg { width: 22px; height: 22px; }

.searchbar { padding: 8px 10px; background: var(--panel); border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.searchbar input {
  width: 100%; border: none; outline: none; background: #f0f2f5;
  border-radius: 8px; padding: 9px 12px; font-size: 15px;
}

/* --------------------------------------------------------------- lists */
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.list-item:active { background: #f0f2f5; }
.avatar { width: 48px; height: 48px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 25px;
  background: linear-gradient(145deg, #dfe7dd, #c8d6c5); position: relative; }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 14px; height: 14px;
  border-radius: 50%; background: #aab; border: 2px solid #fff; }
.avatar .dot.on { background: var(--brand-3); }

.item-body { flex: 1; min-width: 0; }
.item-top { display: flex; align-items: baseline; gap: 8px; }
.item-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.item-time { font-size: 12px; color: var(--muted-2); flex: 0 0 auto; }
.item-sub { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.badge {
  background: var(--brand-2); color: #fff; font-size: 12px; font-weight: 700;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.tag { font-size: 11px; padding: 2px 7px; border-radius: 20px; background: #e8f5e9; color: var(--brand-2);
  font-weight: 700; flex: 0 0 auto; }
.tag.admin { background: #fff3e0; color: #e65100; }
.tag.banned { background: #ffebee; color: var(--danger); }
.tag.pending { background: #fff8e1; color: #f9a825; }
.tag.bot { background: #e3f2fd; color: #1565c0; }

.empty {
  text-align: center; color: var(--muted); padding: 48px 24px;
}
.empty .big { font-size: 52px; }
.empty h3 { margin: 8px 0 4px; color: var(--ink); font-size: 17px; }
.empty p { margin: 0; font-size: 14px; line-height: 1.5; }

/* ------------------------------------------------------------- onboarding */
.split {
  display: flex; flex-direction: column; align-items: stretch;
  padding: 26px 26px 18px; text-align: center;
}
.split .logo {
  width: 92px; height: 92px; border-radius: 24px; margin: 0 auto 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); display: block; object-fit: cover;
}
.split h1 { font-size: 24px; margin: 6px 0 2px; color: var(--brand); }
.split .tagline { color: var(--muted); font-size: 14px; margin: 0 0 6px; }
.split .flag { margin: 6px 0 2px; font-size: 13px; color: var(--muted); }

.form { padding: 8px 26px 30px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px 2px; font-weight: 600; }
.field input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 13px; font-size: 16px; background: var(--panel); outline: none;
}
.field input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(18,140,126,.15); }
.hint { font-size: 12.5px; color: var(--muted-2); margin-top: 5px; line-height: 1.45; }
.phone-wrap { position: relative; }
.phone-wrap .prefix {
  position: absolute; left: 0; top: 0; bottom: 0; display: flex; align-items: center;
  padding: 0 13px; font-size: 16px; font-weight: 700; color: var(--brand);
  background: #e9f2ef; border-right: 1px solid var(--border); border-radius: 10px 0 0 10px;
}
.phone-wrap input { padding-left: 72px; }

.btn {
  width: 100%; border: none; border-radius: 10px; padding: 13px 16px; font-size: 16px;
  font-weight: 700; background: var(--brand-2); color: #fff;
}
.btn:active { filter: brightness(.92); }
.btn:disabled { opacity: .55; }
.btn.ghost { background: transparent; color: var(--brand-2); border: 1px solid var(--brand-2); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 9px 14px; font-size: 14px; border-radius: 8px; }

.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }

.otp-row { display: flex; gap: 8px; justify-content: center; margin: 6px 0 14px; }
.otp-row input {
  width: 44px; height: 52px; text-align: center; font-size: 22px; font-weight: 700;
  border: 1px solid var(--border); border-radius: 10px; background: var(--panel); outline: none;
}
.otp-row input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(18,140,126,.15); }

.section-title { font-size: 13px; font-weight: 700; color: var(--brand); padding: 14px 14px 6px; }

.developer-code {
  margin: 10px 0 0; padding: 10px 12px; background: #fff8e1; border: 1px dashed #f9a825;
  border-radius: 8px; font-size: 13px; color: #7a5b00; line-height: 1.5;
}
.developer-code b { font-size: 16px; letter-spacing: 1px; }

/* --------------------------------------------------------------- chat */
.chat-header { display: flex; align-items: center; gap: 10px; background: var(--brand); color: #fff; padding: 8px 10px; flex: 0 0 auto; }
.chat-header .avatar { width: 40px; height: 40px; font-size: 21px; background: #0b6b5c; }
.chat-header .who { flex: 1; min-width: 0; }
.chat-header .who .n { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header .who .s { font-size: 12px; color: rgba(255,255,255,.78); }

.msgs { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 4px;
  background-image:
    linear-gradient(rgba(7,94,84,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(7,94,84,.045) 1px, transparent 1px);
  background-size: 26px 26px; }
.date-sep { align-self: center; background: #fff; color: var(--muted); font-size: 12px; padding: 5px 10px;
  border-radius: 8px; box-shadow: var(--shadow); margin: 6px 0; }
.msg { max-width: 82%; padding: 7px 10px 3px; border-radius: 10px; position: relative;
  font-size: 15px; line-height: 1.42; word-wrap: break-word; box-shadow: var(--shadow); }
.msg .txt { white-space: pre-wrap; }
.msg.in { background: var(--panel); border-top-left-radius: 2px; align-self: flex-start; }
.msg.out { background: #d9fdd3; border-top-right-radius: 2px; align-self: flex-end; }
.msg.sys { background: #fff3e0; color: #7a5b00; align-self: center; font-size: 13px; max-width: 92%; }
.msg .meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; color: var(--muted-2); margin-top: 2px; }
.msg .meta svg { width: 15px; height: 15px; }
.tick.read { color: #34b7f1; }

.composer { flex: 0 0 auto; background: var(--panel); border-top: 1px solid var(--border);
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
.composer textarea {
  flex: 1; border: none; outline: none; resize: none; background: var(--panel);
  font-size: 16px; max-height: 120px; padding: 9px 2px; line-height: 1.35;
}
.sendbtn {
  background: var(--brand-2); color: #fff; border: none; border-radius: 50%;
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.sendbtn:disabled { background: #b9d6cf; }
.sendbtn svg { width: 22px; height: 22px; }

/* ------------------------------------------------------------- tab bar */
.tabbar {
  flex: 0 0 auto; display: flex; background: var(--tabbar);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 0 6px; color: var(--muted-2); border: none; background: none; font-size: 11px; position: relative; }
.tabbar .tab svg { width: 23px; height: 23px; }
.tabbar .tab.on { color: var(--brand-2); }
.tabbar .tab .tbadge { position: absolute; top: 3px; left: 50%; margin-left: 10px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }

/* --------------------------------------------------------------- modals */
.modal-back { position: absolute; inset: 0; background: rgba(0,0,0,.45); display: none;
  align-items: flex-end; justify-content: center; z-index: 50; }
.modal-back.open { display: flex; }
.sheet { background: var(--panel); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 88%; overflow-y: auto; }
.sheet h3 { margin: 0 0 14px; font-size: 18px; }
.sheet .meta-line { font-size: 14px; color: var(--muted); margin: 4px 0; }
.sheet hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.sheet .actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.sheet .actions .actions-row { display: flex; gap: 8px; }
.sheet .actions .actions-row > * { flex: 1; }
.toast {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(17,27,33,.92); color: #fff; padding: 10px 16px; border-radius: 22px;
  font-size: 14px; z-index: 60; display: none; white-space: nowrap;
}
.fi { align-items: center; }

/* --------------------------------------------------------- admin screen */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 12px; }
.stat { background: var(--panel); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 26px; font-weight: 800; color: var(--brand); margin-top: 2px; }
.mini { display: flex; gap: 8px; align-items: center; }
.mini .avatar { width: 40px; height: 40px; font-size: 20px; }
.mini .n { font-size: 15px; font-weight: 600; }
.mini .s { font-size: 12.5px; color: var(--muted); }

/* --------------------------------------------------------------- splash */
#splash { position: absolute; inset: 0; background: var(--brand); display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: #fff; z-index: 100; gap: 14px; }
#splash img { width: 108px; height: 108px; border-radius: 26px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
#splash .brand { font-size: 26px; font-weight: 800; letter-spacing: .5px; }
#splash .sub { font-size: 13px; color: rgba(255,255,255,.75); }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 26px; height: 26px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .8s linear infinite; }
