/* Kauthar — public ticket form + customer portal (mobile-first, RTL + LTR; same look as the customer chat). Also the base sheet of the booking pages. */
:root {
  /* tenant brand — overridden per tenant by an inline :root{} from src/lib/brand.js (cssVars) */
  --brand: #0f766e; --brand-600: #0d6660; --brand-50: #e7f6f3; --on-brand: #fff; --brand-ink: #0f766e;
  --brand-soft: var(--brand-50);
  --brand-dark: var(--brand-ink);
  --bg: #eef1f6; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --ok: #10b981; --bad: #dc2626; --warn: #f59e0b;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { overflow-x: hidden; }
body {
  font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif; color: var(--ink);
  background: linear-gradient(170deg, var(--brand-soft), var(--bg) 340px); min-height: 100vh;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font-family: inherit; }
.ltr { direction: ltr; text-align: left; }
html[dir=rtl] .ltr { text-align: right; }
.ltr-num { direction: ltr; unicode-bidi: isolate; display: inline-block; }
[hidden] { display: none !important; }

.tp-app { max-width: 680px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* header (same gradient as the chat) */
.tp-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(135deg, var(--brand), var(--brand-600)); color: var(--on-brand); box-shadow: 0 2px 12px rgba(0,0,0,.12);
}
@media (min-width: 720px) { .tp-head { border-radius: 0 0 20px 20px; } }
.tp-avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 19px;
  background: color-mix(in srgb, var(--on-brand) 18%, transparent); border: 2px solid color-mix(in srgb, var(--on-brand) 40%, transparent); overflow: hidden; }
.tp-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tp-avatar.is-logo { background: #fff; border-color: #fff; }
.tp-avatar.is-logo img { object-fit: contain; padding: 4px; }
.tp-title { flex: 1; min-width: 0; }
.tp-name { font-weight: 700; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-sub { font-size: 12.5px; opacity: .92; }
.tp-iconbtn { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--on-brand) 15%, transparent); color: var(--on-brand); font-size: 18px; text-decoration: none; }
.tp-iconbtn:hover { background: color-mix(in srgb, var(--on-brand) 26%, transparent); }
/* language switcher (views/partials/lang_switch.ejs «pills») on the brand header — compact for 360-390 px phones */
.tp-head .k-lang { flex: none; background: color-mix(in srgb, var(--on-brand) 16%, transparent); padding: 2px; }
.tp-head .k-lang a { min-width: 28px; height: 28px; padding: 0 6px; font-size: .74rem; color: var(--on-brand); }
.tp-head .k-lang a:hover { background: color-mix(in srgb, var(--on-brand) 22%, transparent); color: var(--on-brand); }
.tp-head .k-lang a.is-on { background: #fff; color: var(--brand-ink); }
@media (max-width: 380px) { .tp-head { gap: 8px; padding-inline: 12px; } .tp-head .tp-avatar { width: 38px; height: 38px; font-size: 16px; } .tp-head .tp-iconbtn { width: 36px; height: 36px; font-size: 16px; } }
/* RTL-drawn chevrons/arrows → mirrored on LTR pages */
html[dir=ltr] .tp-flip { display: inline-block; transform: scaleX(-1); }

.tp-main { flex: 1; min-width: 0; position: relative; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 14px; }
.tp-hero { padding: 4px 4px 0; }
.tp-hero h1 { font-size: 21px; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.tp-hero h1 i { color: var(--brand-ink); }
.tp-hero p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.8; }

.tp-card { background: var(--card); border-radius: 18px; padding: 16px; box-shadow: 0 4px 18px rgba(15,23,42,.07); border: 1px solid var(--line); }
.tp-card h2 { font-size: 15.5px; margin: 0 0 10px; display: flex; align-items: center; gap: 7px; }
.tp-card h2 i { color: var(--brand-ink); }

.tp-alert { border-radius: 14px; padding: 10px 14px; font-size: 14px; font-weight: 600; display: flex; gap: 8px; align-items: flex-start; line-height: 1.7; }
.tp-alert.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.tp-alert.bad { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.tp-alert.wait { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; text-align: start; margin: 10px 0; }
.tp-card > .tp-alert { margin-bottom: 12px; }

/* form */
.tp-grid { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 560px) { .tp-grid { grid-template-columns: 1fr 1fr; } }
.tp-field { margin-bottom: 12px; }
.tp-field label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 5px; color: #334155; }
.tp-field label small { font-weight: 500; color: var(--muted); }
.tp-field label.required::after { content: ' *'; color: var(--bad); }
.tp-field input:not([type=radio]):not([type=file]), .tp-field select, .tp-field textarea, .tp-reply textarea, .tp-csat textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 16px; outline: none;
  background: #f8fafc; color: var(--ink); transition: border-color .15s, background .15s;
}
.tp-field textarea, .tp-reply textarea, .tp-csat textarea { resize: vertical; line-height: 1.7; }
.tp-field input:focus, .tp-field select:focus, .tp-field textarea:focus, .tp-reply textarea:focus, .tp-csat textarea:focus { border-color: var(--brand-ink); background: #fff; }
.tp-invalid { display: none; color: var(--bad); font-size: 12.5px; margin-top: 4px; }
.was-validated :invalid { border-color: var(--bad) !important; }
.was-validated :invalid ~ .tp-invalid, .was-validated .tp-field:has(.kphone-num:invalid) > .tp-invalid { display: block; }

/* shared international phone field (public/js/kphone.js + kphone.css): always LTR (+dial code, then the number) */
.tp-field .kphone { direction: ltr; }
.tp-field .kphone .kphone-cc { min-height: 46px; border: 1.5px solid var(--line); border-right: 0; border-radius: 12px 0 0 12px; background: #f1f5f9; color: var(--ink); font-size: 15px; }
.tp-field .kphone .kphone-cc:hover, .tp-field .kphone .kphone-cc:focus-visible { background: var(--brand-soft); box-shadow: none; }
.tp-field .kphone input.kphone-num { flex: 1 1 auto; width: auto; min-width: 0; border-radius: 0 12px 12px 0; text-align: left; direction: ltr; }
.was-validated .tp-field .kphone .kphone-num:invalid { border-color: var(--bad) !important; }
.kphone-sheet { font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif; }
.tp-hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; opacity: 0; pointer-events: none; }

.tp-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
@media (max-width: 420px) { .tp-seg { grid-template-columns: 1fr 1fr; } }
.tp-seg-opt { margin: 0 !important; cursor: pointer; }
.tp-seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.tp-seg-opt span { display: flex; align-items: center; justify-content: center; gap: 5px; padding: 9px 6px; border-radius: 12px; border: 1.5px solid var(--line);
  background: #f8fafc; font-size: 14px; font-weight: 600; color: #334155; transition: all .15s; }
.tp-seg-opt input:checked + span { border-color: var(--brand-ink); background: var(--brand-soft); color: var(--brand-ink); }
.tp-seg-opt input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.tp-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); }
.tp-drop { display: flex !important; align-items: center; justify-content: center; gap: 6px; padding: 12px; border: 1.5px dashed color-mix(in srgb, var(--brand) 45%, #cbd5e1);
  border-radius: 12px; color: var(--brand-dark) !important; background: var(--brand-soft); cursor: pointer; font-weight: 700; }
.tp-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tp-filechip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 5px 10px; border-radius: 10px; background: #f1f5f9; border: 1px solid var(--line);
  font-size: 12.5px; color: #334155; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-filechip small { color: var(--muted); }
a.tp-filechip:hover { border-color: var(--brand-ink); color: var(--brand-ink); }
.tp-file-err { display: none; }

.tp-btn { display: flex; width: 100%; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 13px; padding: 12px 16px;
  font-size: 15.5px; font-weight: 700; cursor: pointer; background: var(--brand); color: var(--on-brand); text-decoration: none; transition: background .15s, transform .1s;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 30%, transparent); }
.tp-btn:hover { background: var(--brand-600); }
.tp-btn:active { transform: scale(.98); }
.tp-btn:disabled { opacity: .55; cursor: default; transform: none; }
.tp-btn.sm { width: auto; padding: 8px 14px; font-size: 14px; box-shadow: none; }
.tp-btn.ghost { background: #fff; color: var(--brand-ink); border: 1.5px solid color-mix(in srgb, var(--brand) 40%, transparent); box-shadow: none; }
.tp-btn.ghost:hover { background: var(--brand-soft); }
.tp-btn.success { background: var(--ok); color: #fff; box-shadow: 0 4px 12px rgba(16,185,129,.3); }
.tp-btn.success:hover { background: #059669; }
.tp-btn.wa { background: #25d366; color: #fff; box-shadow: 0 4px 12px rgba(37,211,102,.3); }
.tp-btn.wa:hover { background: #1fbd5a; }
.tp-spin { width: 16px; height: 16px; border: 2px solid color-mix(in srgb, currentColor 45%, transparent); border-top-color: currentColor; border-radius: 50%; animation: tpSpin .8s linear infinite; }
@keyframes tpSpin { to { transform: rotate(360deg); } }
.tp-note { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.7; }
.tp-center { text-align: center; margin: 0; }
.tp-link { color: var(--brand-dark); font-weight: 700; text-decoration: none; font-size: 14px; }
.tp-link:hover { text-decoration: underline; }

/* my tickets on this device */
.tp-mine { background: #fff; border-radius: 16px; border: 1px solid var(--line); overflow: hidden; }
.tp-mine-h { padding: 9px 14px; font-size: 13px; font-weight: 700; color: var(--muted); background: #f8fafc; border-bottom: 1px solid var(--line); }
.tp-mine-i { display: flex; align-items: center; gap: 8px; padding: 10px 14px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); font-size: 14px; }
.tp-mine-i:last-child { border-bottom: 0; }
.tp-mine-i b { color: var(--brand-ink); }
.tp-mine-i span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-mine-i i { color: var(--muted); }
.tp-mine-i:hover { background: var(--brand-soft); }

/* thank-you */
.tp-done { text-align: center; padding: 26px 18px; }
.tp-done-ic { width: 74px; height: 74px; border-radius: 50%; margin: 0 auto 12px; display: grid; place-items: center; font-size: 38px; color: #fff;
  background: var(--ok); box-shadow: 0 0 0 10px rgba(16,185,129,.15); animation: tpPop .4s ease-out; }
@keyframes tpPop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.tp-done h1 { font-size: 22px; margin: 0 0 6px; }
.tp-done p { color: var(--muted); line-height: 1.8; margin: 0 0 14px; }
.tp-bignum { font-size: 15px; color: var(--muted); margin-bottom: 8px; }
.tp-bignum b { font-size: 30px; color: var(--brand-ink); font-weight: 800; margin-inline-start: 6px; vertical-align: middle; }
.tp-save { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 12px; padding: 9px 12px; font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.tp-copy { display: flex; gap: 8px; align-items: stretch; margin-bottom: 12px; }
.tp-copy input { flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: 13px; background: #f8fafc; color: #334155; }
.tp-actions { display: grid; gap: 8px; }

/* portal */
.tp-ticket-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.tp-num { font-weight: 800; color: var(--brand-ink); font-size: 18px; }
.tp-badge { font-size: 12.5px; font-weight: 700; padding: 4px 12px; border-radius: 20px; background: #e2e8f0; color: #334155; white-space: nowrap; }
.tp-badge.s-new { background: #dbeafe; color: #1e40af; }
.tp-badge.s-open, .tp-badge.s-on_hold { background: #fef3c7; color: #92400e; }
.tp-badge.s-pending { background: #ede9fe; color: #5b21b6; }
.tp-badge.s-solved { background: #d1fae5; color: #065f46; }
.tp-badge.s-closed { background: #e2e8f0; color: #475569; }
.tp-subject { font-size: 18px; margin: 0 0 4px; line-height: 1.6; overflow-wrap: anywhere; }
.tp-meta { font-size: 12.5px; color: var(--muted); }

.tp-steps { list-style: none; margin: 16px 0 2px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); position: relative; }
.tp-steps li { position: relative; text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.tp-steps li::before { content: ''; position: absolute; top: 15px; inset-inline-start: -50%; width: 100%; height: 3px; background: var(--line); z-index: 0; }
.tp-steps li:first-child::before { display: none; }
.tp-steps li.done::before, .tp-steps li.cur::before { background: var(--brand); }
.tp-dot { position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%; margin: 0 auto 5px; display: grid; place-items: center;
  background: #fff; border: 2.5px solid var(--line); font-weight: 800; font-size: 13px; color: var(--muted); }
.tp-steps li.done .tp-dot { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.tp-steps li.cur .tp-dot { border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand) 15%, transparent); }
.tp-steps li.cur { color: var(--ink); font-weight: 800; }
.tp-step-l { display: block; line-height: 1.4; }
.tp-hint { margin-top: 12px; background: #f5f3ff; color: #5b21b6; border-radius: 12px; padding: 8px 12px; font-size: 13.5px; font-weight: 600; }

.tp-timeline { display: flex; flex-direction: column; gap: 12px; }
.tp-msg { max-width: 88%; display: flex; flex-direction: column; }
.tp-msg.tp-new { animation: tpIn .25s ease-out; }
@keyframes tpIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tp-msg.me { align-self: flex-end; align-items: flex-end; }
.tp-msg.agent { align-self: flex-start; }
.tp-msg-who { font-size: 12px; font-weight: 700; color: #334155; margin: 0 4px 3px; display: flex; gap: 4px; align-items: center; }
.tp-msg.agent .tp-msg-who i { color: var(--brand-ink); }
.tp-msg.me .tp-msg-who { color: var(--muted); }
.tp-bubble { padding: 10px 14px; border-radius: 16px; line-height: 1.8; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tp-msg.me .tp-bubble { background: var(--brand); color: var(--on-brand); border-start-end-radius: 5px; }
.tp-msg.agent .tp-bubble { background: #f1f5f9; border: 1px solid var(--line); border-start-start-radius: 5px; }
.tp-msg-time { font-size: 11px; color: var(--muted); margin: 3px 4px 0; }
.tp-att { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tp-msg.me .tp-att { justify-content: flex-end; }
.tp-thumb img { width: 92px; height: 92px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); display: block; }
.tp-live { margin-top: 14px; font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; justify-content: center; }
.tp-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: tpPulse 2s infinite; }
@keyframes tpPulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

.tp-reply textarea { margin-bottom: 8px; }
.tp-reply-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tp-iconfile { display: inline-flex; align-items: center; gap: 5px; padding: 8px 12px; border-radius: 12px; border: 1.5px solid var(--line); cursor: pointer;
  font-size: 14px; font-weight: 600; color: #334155; background: #f8fafc; }
.tp-iconfile:hover { border-color: var(--brand-ink); color: var(--brand-ink); }
.tp-solve { margin: 0; }
.tp-closed { color: #475569; font-size: 14px; line-height: 1.8; }
.tp-closed a { color: var(--brand-ink); font-weight: 700; }
.tp-share { font-size: 13.5px; color: #334155; font-weight: 600; }
.tp-share .tp-copy { margin: 8px 0 0; }

/* CSAT */
.tp-csat { border: 2px solid color-mix(in srgb, var(--brand) 30%, transparent); }
.tp-csat p { margin: -4px 0 12px; color: var(--muted); font-size: 13.5px; }
.tp-faces { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 12px; direction: ltr; }
.tp-face { cursor: pointer; text-align: center; }
.tp-face input { position: absolute; opacity: 0; pointer-events: none; }
.tp-face-e { display: grid; place-items: center; height: 54px; font-size: 30px; border-radius: 14px; border: 2px solid var(--line); background: #f8fafc;
  color: #94a3b8; transition: all .15s; }
.tp-face.f-angry { --fc: #dc2626; } .tp-face.f-frown { --fc: #d97706; } .tp-face.f-neutral { --fc: #64748b; } .tp-face.f-smile { --fc: #16a34a; } .tp-face.f-love { --fc: #059669; }
.tp-face-l { display: block; font-size: 11.5px; color: var(--muted); margin-top: 4px; font-weight: 600; }
html[dir=rtl] .tp-face-l { direction: rtl; }
.tp-face:hover .tp-face-e { color: var(--fc); transform: translateY(-2px); }
.tp-face input:checked + .tp-face-e { color: var(--fc); border-color: var(--fc); background: color-mix(in srgb, var(--fc) 10%, #fff); transform: scale(1.06); }
.tp-face input:checked ~ .tp-face-l { color: var(--ink); }
.tp-csat textarea { margin-bottom: 10px; }
.tp-rated { text-align: center; font-weight: 700; color: #334155; }
.tp-rated > i { color: #ef4444; }
.tp-stars { color: var(--warn); margin: 0 4px; display: inline-flex; gap: 2px; direction: ltr; }
.tp-stars .off { color: #cbd5e1; }

/* not found */
.tp-empty { text-align: center; padding: 30px 20px; display: grid; gap: 10px; }
.tp-empty-ic { width: 74px; height: 74px; border-radius: 50%; margin: 0 auto 4px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); font-size: 34px; }
.tp-empty h1 { font-size: 20px; margin: 0; }
.tp-empty p { color: var(--muted); line-height: 1.8; margin: 0 0 6px; }

.tp-foot { text-align: center; font-size: 12px; color: #94a3b8; padding: 14px 12px; padding-bottom: max(14px, env(safe-area-inset-bottom)); line-height: 2; }
.tp-foot a { color: var(--muted); text-decoration: none; }
.tp-foot a:hover { color: var(--brand-ink); }
.tp-foot b { color: #475569; }
