/* Al-Ghaith dashboard — brand colours taken from the company logo */
:root {
  --teal-300:#6AD0CA; --teal-400:#23ABA4; --teal-500:#159B96; --teal-600:#0E8A86; --teal-700:#0C6E73;
  --navy-700:#0B4A63; --navy-800:#0A3B55; --navy-900:#12284F; --grey:#A5A8AB;
  --grad: linear-gradient(135deg,#23ABA4 0%,#0E8A86 42%,#0A3B55 100%);
  --bg:#F2F7F7; --surface:#fff; --line:#E1EBEB; --text:#14303F; --muted:#64808C;
  --red:#D64545; --amber:#C98A12; --green:#1E8E5A;
  --r:16px; --shadow:0 1px 2px rgba(10,59,85,.06), 0 8px 24px rgba(10,59,85,.06);
  --font:"IBM Plex Sans Arabic", system-ui, "Segoe UI", Tahoma, Arial, sans-serif;
}
* { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; }
body { margin:0; font-family:var(--font); background:var(--bg); color:var(--text); font-size:15px; line-height:1.55; }
.hidden { display:none !important; }
button, input, select, textarea { font:inherit; color:inherit; }
input, select, textarea { width:100%; padding:10px 12px; border:1.5px solid var(--line); border-radius:12px; background:#fff; transition:border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline:none; border-color:var(--teal-500); box-shadow:0 0 0 4px rgba(35,171,164,.18); }
textarea { resize:vertical; min-height:72px; }
label { display:block; margin-bottom:12px; font-size:13px; font-weight:500; color:var(--muted); }
label > input, label > select, label > textarea { margin-top:6px; font-size:15px; }
h2 { margin:0 0 14px; font-size:22px; font-weight:700; color:var(--navy-800); }
h3 { margin:0 0 12px; font-size:16px; font-weight:600; color:var(--navy-800); }
.muted { color:var(--muted); }
.error { color:var(--red); min-height:1.3em; margin:4px 0 10px; font-size:14px; }

/* buttons */
.btn { border:1.5px solid var(--line); background:#fff; padding:9px 16px; border-radius:12px; cursor:pointer; color:var(--navy-800); font-weight:500; transition:all .15s; }
.btn:hover { background:#EDF5F5; border-color:#cfe0e0; }
.btn.primary { background:var(--grad); border-color:transparent; color:#fff; box-shadow:0 6px 16px rgba(14,138,134,.28); }
.btn.primary:hover { filter:brightness(1.07); transform:translateY(-1px); }
.btn.danger { color:var(--red); }
.btn.small { padding:5px 11px; font-size:13px; border-radius:10px; }
.btn.block { width:100%; padding:12px; font-size:16px; }
.btn.ghost { background:rgba(255,255,255,.08); border-color:rgba(255,255,255,.22); color:#fff; }
.btn.ghost:hover { background:rgba(255,255,255,.18); }
.icon-btn { background:none; border:none; padding:6px; border-radius:10px; cursor:pointer; color:var(--navy-800); display:none; }
.card { background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:18px; box-shadow:var(--shadow); }

/* logo mark: crops the "G" symbol out of the full logo image (805x895 region of 1990x2000) */
.logo-mark { display:inline-block; position:relative; width:var(--w); aspect-ratio:805/895; overflow:hidden; flex:none; }
.logo-mark img { position:absolute; top:0; width:calc(var(--w) * 2.472); left:calc(var(--w) * -0.739); max-width:none; }
[dir=rtl] .logo-mark img { left:calc(var(--w) * -0.739); }

/* splash */
.splash { position:fixed; inset:0; z-index:100; background:#fff; display:grid; place-content:center; justify-items:center; gap:28px; transition:opacity .45s ease, visibility .45s; }
.splash.out { opacity:0; visibility:hidden; }
.splash-logo { width:min(220px, 52vw); animation:float 2.4s ease-in-out infinite; }
.splash-bar { width:140px; height:4px; border-radius:4px; background:#E4EEEE; overflow:hidden; }
.splash-bar i { display:block; height:100%; width:40%; background:var(--grad); border-radius:4px; animation:slide 1.2s ease-in-out infinite; }
@keyframes float { 0%,100% { transform:translateY(0); } 50% { transform:translateY(-6px); } }
@keyframes slide { 0% { transform:translateX(-120%); } 100% { transform:translateX(320%); } }
[dir=rtl] .splash-bar i { animation-direction:reverse; }

/* login */
.login { min-height:100vh; display:grid; grid-template-columns:1.05fr 1fr; }
.login-hero { position:relative; overflow:hidden; background:#fff; display:grid; place-content:center; justify-items:center; gap:22px; padding:32px; text-align:center; }
.login-hero::before, .login-hero::after { content:""; position:absolute; border-radius:50%; background:var(--grad); opacity:.08; }
.login-hero::before { width:520px; height:520px; inset-block-start:-180px; inset-inline-start:-160px; }
.login-hero::after { width:380px; height:380px; inset-block-end:-140px; inset-inline-end:-120px; }
.hero-logo { position:relative; width:min(300px, 60vw); }
.hero-tag { position:relative; margin:0; font-size:18px; font-weight:500; color:var(--navy-800); max-width:320px; }
.login-side { background:var(--grad); display:grid; place-items:center; padding:28px; }
.login-card { width:min(410px,100%); background:#fff; border-radius:22px; padding:30px 28px; box-shadow:0 24px 60px rgba(8,30,60,.35); }
.login-card h1 { margin:0 0 4px; font-size:24px; color:var(--navy-800); }
.login-card > .muted { margin:0 0 20px; }

/* shell */
.shell { display:grid; grid-template-columns:260px 1fr; min-height:100vh; }
.side { position:sticky; top:0; height:100vh; display:flex; flex-direction:column; padding:18px 14px; background:linear-gradient(180deg,#0B4A63 0%,#0A3B55 45%,#12284F 100%); color:#fff; z-index:30; }
.side-brand { display:flex; align-items:center; gap:12px; padding:6px 8px 18px; border-bottom:1px solid rgba(255,255,255,.12); margin-bottom:14px; }
.brand-icon { width:48px; height:48px; border-radius:14px; flex:none; box-shadow:0 4px 12px rgba(0,0,0,.25); }
.brand-icon.sm { width:34px; height:34px; border-radius:10px; box-shadow:none; }
.side-brand b { display:block; font-size:16px; line-height:1.2; }
.side-brand small { color:#a9c7d3; font-size:12px; }
#nav { display:flex; flex-direction:column; gap:4px; flex:1; overflow-y:auto; }
#nav a { display:flex; align-items:center; gap:12px; padding:11px 14px; border-radius:12px; color:#cfe3ea; cursor:pointer; font-weight:500; transition:all .15s; }
#nav a[data-p=apisettings] { margin-top:auto; border-top:1px solid rgba(255,255,255,.1); border-radius:0 0 12px 12px; padding-top:14px; }
#nav a[data-p=apisettings].active { border-radius:12px; }
#nav a svg { width:20px; height:20px; flex:none; opacity:.9; }
#nav a:hover { background:rgba(255,255,255,.08); color:#fff; }
#nav a.active { background:var(--grad); color:#fff; box-shadow:0 8px 18px rgba(0,0,0,.25); }
.side-foot { border-top:1px solid rgba(255,255,255,.12); padding-top:14px; display:grid; gap:10px; }
.who { font-size:13px; color:#d6e6ec; }
.foot-btns { display:flex; gap:8px; }
.foot-btns .btn { flex:1; }
.badges span { display:inline-block; background:#F6D27A; color:#5a4100; font-size:11px; font-weight:600; padding:2px 9px; border-radius:20px; margin:0 0 4px; margin-inline-end:4px; }
.main { min-width:0; }
.topbar { display:none; align-items:center; gap:10px; padding:10px 14px; background:#fff; border-bottom:1px solid var(--line); position:sticky; top:0; z-index:20; color:var(--navy-800); }
.scrim { display:none; }
.page { padding:26px 28px 40px; max-width:1320px; margin:0 auto; }

/* stats / tables */
.stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:14px; margin-bottom:22px; }
.stat { position:relative; overflow:hidden; padding-top:20px; }
.stat::before { content:""; position:absolute; inset-inline:0; top:0; height:4px; background:var(--grad); }
.stat b { display:block; font-size:30px; font-weight:700; color:var(--navy-800); line-height:1.2; }
.stat span { color:var(--muted); font-size:13px; }
.stat.warn::before { background:linear-gradient(90deg,#E86A6A,#D64545); }
.stat.warn b { color:var(--red); }
.table-wrap { overflow-x:auto; border:1px solid var(--line); border-radius:var(--r); background:#fff; box-shadow:var(--shadow); }
table { width:100%; border-collapse:collapse; }
th, td { padding:11px 14px; text-align:start; border-bottom:1px solid var(--line); vertical-align:top; }
tbody tr:last-child td { border-bottom:none; }
th { color:var(--muted); font-size:12px; font-weight:600; background:#F8FBFB; }
tbody tr:hover { background:#F8FBFB; }
tr.overdue, tr.overdue:hover { background:#FDEEEE; }
.pill { display:inline-block; padding:2px 10px; border-radius:20px; font-size:12px; font-weight:500; background:#E4EEEE; color:var(--navy-800); }
.pill.ai { background:#E0F2F9; color:#0B6788; } .pill.routed { background:#DDF4EA; color:var(--green); }
.pill.human { background:#FFF0D1; color:var(--amber); } .pill.closed { background:#EEF0F1; color:#6c7479; }
.pill.bad { background:var(--red); color:#fff; }

/* inbox */
.inbox { display:grid; grid-template-columns:350px 1fr; gap:16px; height:calc(100vh - 70px); }
.list { display:flex; flex-direction:column; min-height:0; }
.filters { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:10px; }
.filters input[type=search] { grid-column:1/-1; }
.filters select, .filters input { padding:8px 10px; }
.conv-list { overflow-y:auto; flex:1; border:1px solid var(--line); border-radius:var(--r); background:#fff; box-shadow:var(--shadow); }
.conv { padding:12px 14px; border-bottom:1px solid var(--line); cursor:pointer; transition:background .12s; }
.conv:hover { background:#F5FAFA; } .conv.active { background:#E3F4F3; box-shadow:inset 3px 0 0 var(--teal-500); }
[dir=rtl] .conv.active { box-shadow:inset -3px 0 0 var(--teal-500); }
.conv.overdue { background:#FEF5F5; }
.conv .row { display:flex; justify-content:space-between; gap:8px; align-items:center; }
.conv .last { color:var(--muted); font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin:2px 0; }
.back-btn { display:none; }
.thread { display:flex; flex-direction:column; min-height:0; padding:0; overflow:hidden; }
.thread-head { padding:14px 18px; border-bottom:1px solid var(--line); background:#fff; }
.thread-head .actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; align-items:center; }
.thread-head select { width:auto; padding:5px 10px; }
.msgs { flex:1; overflow-y:auto; padding:18px; display:flex; flex-direction:column; gap:10px; background:#EDF4F4; background-image:radial-gradient(rgba(14,138,134,.07) 1px, transparent 1px); background-size:18px 18px; }
.msg { max-width:76%; padding:9px 14px; border-radius:16px; background:#fff; white-space:pre-wrap; word-break:break-word; align-self:flex-start; box-shadow:0 1px 2px rgba(10,59,85,.08); border-end-start-radius:4px; }
.msg.out { align-self:flex-end; background:#D4F1EE; border-end-start-radius:16px; border-end-end-radius:4px; }
.msg.staff { background:#CFE4F5; }
.msg.system { align-self:center; background:#FBF3DC; font-size:12.5px; max-width:90%; border-radius:12px; box-shadow:none; }
.msg small { display:block; color:var(--muted); font-size:11px; margin-bottom:3px; }
.msg .fix { background:none; border:none; color:var(--teal-600); cursor:pointer; font-size:12px; padding:3px 0 0; text-decoration:underline; }
.replybox { display:flex; gap:10px; padding:12px; border-top:1px solid var(--line); background:#fff; }
.replybox textarea { min-height:46px; height:46px; }
.empty { display:grid; place-items:center; height:100%; color:var(--muted); }

.inbox > *, .grid2 > *, .sim > *, .users-top > *, .form-row > * { min-width:0; } /* stop long text from stretching grid columns on phones */
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:18px; align-items:start; }
.entry { padding:12px 0; border-bottom:1px solid var(--line); }
.entry:last-child { border-bottom:none; }
.entry .head { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.entry p { margin:6px 0 8px; white-space:pre-wrap; }
.entry.off { opacity:.5; }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; }

/* users page */
.page-head { display:flex; align-items:baseline; gap:12px; margin-bottom:14px; }
.page-head h2 { margin:0; }
.users-top { display:grid; grid-template-columns:1fr 1fr; gap:18px; margin-bottom:22px; align-items:stretch; }
.form-card { display:flex; flex-direction:column; }
.form-card label:last-of-type { margin-bottom:0; }
.card-head { display:flex; align-items:center; gap:12px; margin-bottom:16px; }
.card-head h3 { margin:0; }
.card-head p { margin:2px 0 0; font-size:13px; }
.card-foot { margin-top:auto; padding-top:16px; display:flex; align-items:center; justify-content:space-between; gap:12px; }
.card-foot .error { margin:0; flex:1; min-height:0; }
.avatar { display:inline-grid; place-items:center; width:44px; height:44px; border-radius:14px; background:var(--grad); color:#fff; font-weight:700; font-size:15px; flex:none; }
.avatar.sm { width:36px; height:36px; border-radius:11px; font-size:13px; }
.avatar.plus { background:#E3F4F3; color:var(--teal-600); font-size:22px; font-weight:500; }
.users-table .actions-col { width:1%; white-space:nowrap; text-align:end; }
.user-cell { display:flex; align-items:center; gap:12px; }
.user-cell b { font-weight:600; }
@media (max-width: 900px) { .users-top { grid-template-columns:1fr; } }

.sim { display:grid; grid-template-columns:1fr 1fr; gap:18px; align-items:start; }
.sim .chat { height:430px; overflow-y:auto; background:#E6DED0; border-radius:14px; padding:12px; display:flex; flex-direction:column; gap:7px; margin-top:6px; }
.bubble { max-width:82%; padding:7px 12px; border-radius:12px; background:#fff; white-space:pre-wrap; word-break:break-word; align-self:flex-start; box-shadow:0 1px 1px rgba(0,0,0,.1); }
.bubble.me { align-self:flex-end; background:#DCF8C6; }
.bubble a.cta { display:block; margin-top:8px; padding:8px; text-align:center; border-top:1px solid #e6e6e6; color:#0a7bd6; text-decoration:none; font-weight:600; }
.bubble.contact { border-inline-start:4px solid var(--teal-500); }
.bubble.wide { max-width:92%; min-width:230px; }
.opts { margin-top:8px; display:grid; gap:6px; }
.opt-title { font-size:11.5px; font-weight:600; color:var(--muted); margin-top:6px; }
.opt { display:flex; flex-direction:column; gap:1px; text-align:start; width:100%; padding:8px 12px; border:1px solid #cfe3e2; background:#F4FBFA; border-radius:10px; cursor:pointer; color:var(--teal-700); font-weight:500; transition:background .12s; }
.opt:hover { background:#E3F4F3; }
.opt small { color:var(--muted); font-weight:400; font-size:12px; }
.alert-item { padding:10px 0; border-bottom:1px solid var(--line); font-size:14px; white-space:pre-wrap; }

@media (max-width: 900px) {
  .login { grid-template-columns:1fr; }
  .login-hero { padding:28px 20px 18px; gap:10px; }
  .hero-logo { width:140px; } .hero-tag { font-size:15px; }
  .login-side { padding:22px 16px 36px; border-radius:26px 26px 0 0; margin-top:-8px; position:relative; }
  .shell { display:block; }
  .topbar { display:flex; }
  .icon-btn { display:inline-flex; }
  .side { position:fixed; inset-block:0; inset-inline-start:0; width:268px; transform:translateX(-105%); transition:transform .25s ease; box-shadow:0 0 40px rgba(0,0,0,.35); }
  [dir=rtl] .side { transform:translateX(105%); }
  body.nav-open .side { transform:none; }
  .scrim { position:fixed; inset:0; background:rgba(8,26,45,.5); z-index:25; }
  body.nav-open .scrim { display:block; }
  .page { padding:18px 14px 34px; }
  /* phones: show either the conversation list or the open chat (with a Back button) */
  .inbox { grid-template-columns:1fr; height:calc(100dvh - 130px); min-height:420px; }
  .inbox .list { height:100%; } .conv-list { max-height:none; }
  .inbox:not(.show-thread) #thread { display:none; }
  .inbox.show-thread .list { display:none; }
  .back-btn { display:inline-block; margin-bottom:8px; }
  .grid2, .sim, .form-row { grid-template-columns:1fr; }
  .stats { grid-template-columns:repeat(2,1fr); }
  .msg { max-width:88%; }
}
@media (prefers-reduced-motion: reduce) { * { animation:none !important; transition:none !important; } }
