/* =====================================================================================================================
   owns.ai  -  BOOKINGS  (/bookings, an assistant's Bookings tab, and the customer's /booking/<token>)

   Builds on app.css tokens only, so both themes hold.

   Coded By Darko G.
   ===================================================================================================================== */

/* ---- the sidebar's waiting count ---- */
.side-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 2px; display: inline-grid; place-items: center;
              font-style: normal; font-size: .7rem; font-weight: 800; color: #fff; background: linear-gradient(135deg, #F59E0B, #F97316); box-shadow: 0 4px 10px -4px rgba(245, 158, 11, .8); }

/* ---- /bookings ---- */
.bk-filter { width: auto; min-width: 190px; }
.bk-kpis .kpi-icon.is-hot { background: rgba(245, 158, 11, .16); color: var(--warning); animation: pulse 2s ease-in-out infinite; }
.bk-tabs { padding: 0 12px; }
.bk-tabs .badge:empty, .bk-tabs .badge[hidden] { display: none; }
.bk-list { min-height: 180px; }

.bk-day + .bk-day { border-top: 1px solid var(--border); }
.bk-day-head { display: flex; align-items: center; gap: 10px; padding: 14px 20px 6px; font-family: var(--font-display); font-weight: 700; font-size: .86rem; color: var(--text-2); }
.bk-day-head span { min-width: 22px; height: 20px; padding: 0 7px; border-radius: 2px; display: inline-grid; place-items: center; font-size: .72rem; background: var(--surface-3); color: var(--muted); }

.bk-row { display: grid; grid-template-columns: 108px minmax(0, 1.6fr) minmax(0, 1.2fr) auto auto; align-items: center; gap: 16px; padding: 12px 20px; cursor: pointer;
          transition: background .15s; outline: none; }
.bk-row:hover, .bk-row:focus-visible { background: var(--surface-2); }
.bk-when { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 3px; text-align: center; background: var(--grad-soft); border: 1px solid var(--line-accent); }
.bk-when b { font-family: var(--font-display); font-size: .95rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bk-when span { font-size: .74rem; color: var(--muted); }
.bk-when.is-call { background: rgba(245, 158, 11, .1); border-color: rgba(245, 158, 11, .3); }
.bk-when.is-call b { font-size: .8rem; }
.bk-who { min-width: 0; display: flex; flex-direction: column; }
.bk-who b { font-family: var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-who span { font-size: .84rem; color: var(--muted); }
.bk-who em { font-style: normal; font-size: .82rem; color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-contact { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: .84rem; }
.bk-contact a { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-contact a:hover { color: var(--brand); }
.bk-contact i { width: 16px; color: var(--muted); }
.bk-acts { display: flex; gap: 6px; justify-content: flex-end; }
.bk-acts .btn span { margin-left: 6px; }

@media (max-width: 1100px) { .bk-row { grid-template-columns: 84px minmax(0, 1fr) auto; } .bk-contact { display: none; } .bk-acts { grid-column: 2 / -1; justify-content: flex-start; } }
@media (max-width: 640px) { .bk-row { grid-template-columns: 76px minmax(0, 1fr); gap: 12px; padding: 12px 14px; } .bk-state { grid-column: 2; } .bk-acts .btn span { display: none; } }

/* ---- one booking (the detail modal and the customer's page) ---- */
.bk-detail { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.bk-dl { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 10px 14px; font-size: .94rem; }
.bk-dl + .bk-dl { border-top: 1px solid var(--border); }
.bk-dl > span { color: var(--muted); font-size: .84rem; padding-top: 1px; }
.bk-dl > div { min-width: 0; overflow-wrap: anywhere; }
.bk-move { margin-top: 16px; }
.bk-move .row .input { width: auto; flex: 1; min-width: 140px; }
.modal-footer .grow { flex: 1; }

/* ---- an assistant's Bookings tab ---- */
.bks-modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.bks-mode { display: flex; flex-direction: column; gap: 3px; padding: 14px; text-align: left; font: inherit; color: var(--text); cursor: pointer; border-radius: 3px;
            border: 1px solid var(--border); background: var(--surface-2); transition: border-color .2s, box-shadow .25s, transform .25s var(--ease); }
.bks-mode:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.bks-mode i { font-size: 1.15rem; color: var(--brand); margin-bottom: 4px; }
.bks-mode b { font-family: var(--font-display); font-size: .92rem; }
.bks-mode span { font-size: .8rem; color: var(--muted); }
.bks-mode.is-active { border-color: rgba(0, 155, 219, .7); box-shadow: 0 0 0 3px rgba(0, 155, 219, .16); background: var(--grad-soft); }
.bks-services { display: flex; flex-direction: column; gap: 8px; }
.bks-svc { display: grid; grid-template-columns: minmax(0, 1.2fr) 120px minmax(0, 1.4fr) auto; gap: 8px; align-items: center; }
.bks-week { display: flex; flex-direction: column; gap: 6px; }
.bks-day { display: grid; grid-template-columns: 170px 150px max-content 150px minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px 10px; border-radius: 3px; background: var(--surface-2); }
.bks-day.is-off { opacity: .62; }
.bks-day .input { min-height: 38px; padding: 6px 10px; }
@media (max-width: 760px) { .bks-modes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .bks-svc { grid-template-columns: minmax(0, 1fr) 100px auto; } .bks-svc [data-s=note] { grid-column: 1 / -1; grid-row: 2; } .bks-day { grid-template-columns: minmax(0, 1fr); } }

/* ---- /booking/<token> ---- */
.bkp { padding-top: 48px; }
.bkp-card { max-width: 620px; margin: 0 auto; }
.bkp-top { display: flex; align-items: center; gap: 14px; }
.bkp-top h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0; }
.bkp-top .badge { margin-left: auto; }
.bkp-ic { width: 54px; height: 54px; flex: none; border-radius: 4px; display: grid; place-items: center; font-size: 1.4rem; color: #fff; background: var(--grad); box-shadow: var(--glow); }

/* ---- the dashboard home's "waiting for you" banner ---- */
.d-bk-alert { align-items: center; color: var(--text-2); text-decoration: none; transition: transform .25s var(--ease), box-shadow .3s; }
.d-bk-alert:hover { color: var(--text); transform: translateY(-1px); box-shadow: var(--shadow); }
.d-bk-alert i { margin-top: 0; }
.d-bk-go { margin-left: auto; white-space: nowrap; font-weight: 700; color: var(--warning); }

/* ---- a lead's conversation, in its detail window ---- */
.bk-chat { display: flex; flex-direction: column; gap: 10px; max-height: 380px; overflow-y: auto; margin-top: 8px; padding: 14px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border); }
.bk-msg { max-width: 86%; padding: 10px 13px; border-radius: 3px; background: var(--surface); border: 1px solid var(--border); font-size: .9rem; }
.bk-msg.is-visitor { align-self: flex-end; background: var(--grad-soft); border-color: rgba(0, 155, 219, .25); }
.bk-msg-who { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 4px; font-size: .74rem; font-weight: 700; color: var(--muted); }
.bk-msg-who span { font-weight: 500; }
.bk-msg-text > :last-child { margin-bottom: 0; }
.bh-fields { gap: 18px; padding: 6px 0 2px; }

/* =====================================================================================================================
   SUPPORT TICKETS  (/tickets, js/tickets.js) - the rows and the detail window build on the bookings' own (.bk-*)
   ===================================================================================================================== */
.tk-search { width: 220px; }
.bk-kpis .kpi-icon.is-danger { background: rgba(244, 63, 94, .14); color: var(--danger); }
.tk-num b { font-size: .92rem; letter-spacing: .01em; }
.tk-row.is-urgent { box-shadow: inset 3px 0 0 var(--danger); }
.tk-row.is-urgent .tk-num { background: rgba(244, 63, 94, .08); border-color: rgba(244, 63, 94, .3); }
.tk-state { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.tk-badges { gap: 6px; }
.tk-details { white-space: normal; line-height: 1.55; }
.tk-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.tk-acts { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.tk-act { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; padding: 6px 0; font-size: .88rem; }
.tk-act > i { width: 28px; height: 28px; border-radius: 3px; display: grid; place-items: center; font-size: .8rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }
.tk-act.is-reply > i { color: var(--brand); background: var(--grad-soft); border-color: var(--line-accent); }
.tk-act-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding-top: 4px; }
.tk-act-head b { font-weight: 600; }
.tk-act-head span { font-size: .76rem; color: var(--muted); }
.tk-act-text { margin-top: 6px; padding: 10px 12px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
@media (max-width: 760px) { .tk-grid { grid-template-columns: minmax(0, 1fr); } .tk-search { width: 100%; } }

/* =====================================================================================================================
   CONNECTED APPS  (/connectors, js/connectors.js) - Jobber, ServiceM8, Housecall Pro, simPRO, webhooks
   ===================================================================================================================== */
.cn-h { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; margin: 28px 0 12px; }
.cn-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.cn-step { display: flex; gap: 12px; padding: 16px; border-radius: var(--r); border: 1px solid var(--line-accent); background: var(--grad-soft); }
.cn-step b { font-family: var(--font-display); font-size: .92rem; }
.cn-step b i { color: var(--brand); margin-right: 4px; }
.cn-step p { margin: 4px 0 0; font-size: .84rem; color: var(--text-2); }
.cn-step-n { flex: none; width: 28px; height: 28px; border-radius: 2px; display: grid; place-items: center; font: 800 .85rem var(--font-display); color: #fff; background: var(--grad); }

.cn-logo { --cn: #64748B; flex: none; width: 44px; height: 44px; border-radius: 3px; display: grid; place-items: center; font: 800 .82rem var(--font-display); letter-spacing: -.02em;
           color: #fff; background: var(--cn); box-shadow: 0 6px 14px -8px var(--cn); }
.cn-logo-sm { width: 24px; height: 24px; font-size: .6rem; box-shadow: none; }

.cn-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cn-card { display: flex; flex-direction: column; padding: 20px; }
.cn-card-head { display: flex; align-items: center; gap: 12px; }
.cn-card-head > div { display: flex; flex-direction: column; min-width: 0; }
.cn-card-head b { font-family: var(--font-display); }
.cn-card-head span { font-size: .8rem; color: var(--muted); }
.cn-blurb { margin: 14px 0 8px; font-size: .88rem; color: var(--text-2); flex: 1; }
.cn-creates { margin: 0 0 14px; font-size: .8rem; color: var(--muted); }
.cn-creates i { color: var(--brand); margin-right: 4px; }
.cn-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.cn-list { display: grid; gap: 16px; }
.cn-conn { padding: 20px; }
.cn-conn-head { display: flex; align-items: center; gap: 14px; }
.cn-conn-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cn-conn-name b { font-family: var(--font-display); font-size: 1.02rem; }
.cn-conn-name span { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cn-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.cn-stat { padding: 10px 12px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); display: flex; flex-direction: column; }
.cn-stat b { font: 800 1.3rem var(--font-display); font-variant-numeric: tabular-nums; }
.cn-stat span { font-size: .76rem; color: var(--muted); }
.cn-stat.is-hot { border-color: rgba(244, 63, 94, .35); background: rgba(244, 63, 94, .06); }
.cn-stat.is-hot b { color: var(--danger); }
.cn-summary { margin: 12px 0 0; font-size: .86rem; color: var(--text-2); }
.cn-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.cn-acts .grow { flex: 1; }
.cn-danger:hover { color: var(--danger); border-color: rgba(244, 63, 94, .4); }

.cn-log-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 12px 20px; }
.cn-log-row + .cn-log-row { border-top: 1px solid var(--border); }
.cn-log-row .cn-logo { width: 34px; height: 34px; font-size: .66rem; }
.cn-log-who { min-width: 0; display: flex; flex-direction: column; }
.cn-log-who b { font-family: var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cn-log-who span { font-size: .82rem; color: var(--muted); }
.cn-log-who em { font-style: normal; font-size: .8rem; color: var(--danger); margin-top: 2px; }
.cn-log-state { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.cn-log-acts { display: flex; gap: 6px; justify-content: flex-end; }

.cn-bots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.cn-set .switch { margin-right: 18px; }
.cn-set code { font-size: .78rem; }

.cn-sync { display: flex; flex-direction: column; gap: 8px; }
.cn-sync-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: .9rem; }
.cn-sync-err { flex-basis: 100%; font-size: .8rem; color: var(--danger); }

@media (max-width: 1100px) { .cn-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
    .cn-steps, .cn-grid, .cn-bots { grid-template-columns: minmax(0, 1fr); }
    .cn-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cn-log-row { grid-template-columns: 34px minmax(0, 1fr); padding: 12px 14px; }
    .cn-log-state, .cn-log-acts { grid-column: 2; align-items: flex-start; justify-content: flex-start; }
}

/* ---- connected apps on a plan without them ---- */
.cn-upgrade { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 18px 20px; margin-bottom: 18px; background: var(--grad-soft); border-color: var(--line-accent); }
.cn-upgrade > div:nth-child(2) { flex: 1; min-width: 220px; }
.cn-upgrade b { font-family: var(--font-display); }
.cn-upgrade p { margin: 4px 0 0; font-size: .88rem; color: var(--text-2); }
.cn-upgrade-icon { flex: none; width: 44px; height: 44px; border-radius: 3px; display: grid; place-items: center; color: #fff; background: var(--grad); }
