/* Components of the admin UI. Each block is one component; pages combine them and add nothing of
   their own (no inline styles in Blade). Tables get a scrolling wrapper everywhere and, with the
   .stack class, turn into labelled cards under 720px (each cell reads its data-label). */

/* ---------- cards and stats ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4) var(--space-5); margin-bottom: var(--space-4); box-shadow: var(--shadow-sm); }
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.card-head h2 { margin: 0; flex: 1 1 auto; }
.card-head .small { margin: 0; }
/* a second heading or block further down the same card */
.card .spaced { margin-top: var(--space-4); }
.stat { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.stat:last-child { border-bottom: 0; }
.stat > span:first-child { color: var(--muted); }
.stat strong, .stat .value { text-align: end; }
details.collapsible { margin-bottom: var(--space-4); }
details.collapsible > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .6rem; padding: var(--space-3) var(--space-5); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font-weight: 700; color: var(--brand); box-shadow: var(--shadow-sm); }
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary .chev { margin-inline-start: auto; transition: transform .15s; color: var(--muted); }
details.collapsible[open] > summary { border-end-start-radius: 0; border-end-end-radius: 0; border-bottom-color: transparent; }
details.collapsible[open] > summary .chev { transform: rotate(180deg); }
details.collapsible > .card { border-start-start-radius: 0; border-start-end-radius: 0; margin-bottom: 0; }
details.collapsible > summary .hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
.tech { font-size: .85rem; color: var(--muted); margin-top: .35rem; }
.tech summary { cursor: pointer; color: var(--brand); font-weight: 600; display: inline; }
.tech .rows { margin: .35rem 0 0; display: grid; gap: .15rem .75rem; grid-template-columns: max-content 1fr; }
.empty { text-align: center; color: var(--muted); padding: var(--space-5) var(--space-3); }
.empty .icon { color: var(--line-strong); margin-bottom: .35rem; }
.empty p { margin: 0 0 .5rem; }

/* ---------- badges and chips ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .6rem; border-radius: var(--radius-pill); font-size: .8rem; font-weight: 700; background: var(--brand-soft); color: var(--brand); white-space: nowrap; line-height: 1.5; }
.badge.ok { background: var(--ok-soft); color: #0b6b3a; }
.badge.warn { background: var(--warn-soft); color: var(--gold-dark); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.count { min-width: 1.4rem; justify-content: center; padding: 0 .4rem; font-size: .75rem; }
.attention { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: var(--space-4); }
.attention .badge { font-size: .85rem; padding: .3rem .85rem; }
.attention a:hover { text-decoration: none; opacity: .85; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .45rem 1rem; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; line-height: 1.4; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--brand-soft); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #f0c9c3; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.small { padding: .22rem .7rem; font-size: .85rem; }
.btn.block { width: 100%; }
.btn.icon { padding: .35rem; width: 36px; height: 36px; }
.btn.small.icon { width: 30px; height: 30px; padding: .2rem; }
.btn[disabled], .btn[wire\:loading] { opacity: .55; cursor: default; pointer-events: none; }
.btn .icon { flex: none; }

/* ---------- forms ---------- */
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .6rem; font-weight: 600; }
label.inline { display: inline-flex; align-items: center; gap: .45rem; }
label.inline input { width: auto; margin: 0; }
input, select, textarea { display: block; width: 100%; max-width: 100%; min-width: 0; padding: .5rem .7rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; background: #fbfcfb; margin-top: .25rem; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(28, 69, 54, .12); }
input[type="checkbox"], input[type="radio"] { width: auto; display: inline-block; accent-color: var(--brand); }
input[type="file"] { padding: .4rem .5rem; }
textarea { resize: vertical; min-height: 4.5rem; }
.hint { color: var(--muted); font-size: .85rem; margin: -.25rem 0 .75rem; }
fieldset { border: 0; padding: 0; margin: 0 0 var(--space-4); min-width: 0; }
fieldset legend { font-weight: 700; color: var(--brand); padding: 0; margin-bottom: .5rem; font-size: 1rem; }
.fields { display: grid; gap: 0 var(--space-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.fields label { margin-bottom: .75rem; }
.fields .full { grid-column: 1 / -1; }
.inline-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.inline-form label { flex: 1 1 10rem; margin: 0; }
.inline-form label input, .inline-form label select { margin-top: .25rem; }
.inline-form > input, .inline-form > select { flex: 1 1 12rem; width: auto; margin-top: 0; }
.inline-form .btn { flex: 0 0 auto; }
.phone-row { display: flex; gap: .5rem; margin-top: .25rem; }
.phone-row select { width: auto; min-width: 118px; flex: 0 0 auto; margin-top: 0; }
.phone-row input { flex: 1; margin-top: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 calc(-1 * var(--space-5)); padding: 0 var(--space-5); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: .8rem; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--brand-tint); }
td .sub { display: block; color: var(--muted); font-size: .82rem; }
td.actions-cell { white-space: nowrap; }
td.actions-cell .btn + .btn { margin-inline-start: .3rem; }
td.num, th.num { text-align: end; white-space: nowrap; }
@media (max-width: 720px) {
    table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; }
    table.stack thead { display: none; }
    table.stack tr { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .35rem .75rem; margin-bottom: .6rem; background: var(--card); }
    table.stack tr:hover td { background: transparent; }
    table.stack td[data-label] { display: grid; grid-template-columns: 34% minmax(0, 1fr); gap: 0 .75rem; align-items: start; border: 0; padding: .3rem 0; text-align: end; }
    table.stack td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 700; text-align: start; grid-column: 1; }
    table.stack td[data-label] > * { grid-column: 2; }
    table.stack td[data-label] .sub { margin-top: .1rem; }
    table.stack td:not([data-label]) { display: flex; flex-wrap: wrap; gap: .4rem; border: 0; padding: .4rem 0 .2rem; }
    table.stack td:not([data-label]) .btn + .btn { margin: 0; }
    .table-wrap:has(> table.stack) { margin: 0; padding: 0; overflow: visible; }
}
.pagination { display: flex; gap: .4rem; margin-top: 1rem; list-style: none; padding: 0; flex-wrap: wrap; }
.pagination a, .pagination span { display: inline-block; padding: .3rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--card); }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--line); margin-bottom: var(--space-4); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
@media (max-width: 720px) { .tabs { flex-wrap: wrap; overflow: visible; } }
.tabs button { display: inline-flex; align-items: center; gap: .4rem; background: transparent; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: .5rem .9rem; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--brand); }
.tabs button.active, .tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--gold); }

/* ---------- toasts and flashes ---------- */
.toasts { position: fixed; bottom: var(--space-4); inset-inline-end: var(--space-4); z-index: 70; display: flex; flex-direction: column; gap: .5rem; width: min(440px, calc(100vw - 2rem)); }
.toast { display: flex; align-items: flex-start; gap: .6rem; background: var(--card); border: 1px solid var(--line); border-inline-start: 4px solid var(--ok); border-radius: var(--radius); padding: .7rem .9rem; box-shadow: var(--shadow); }
.toast .icon { flex: none; color: var(--ok); margin-top: .15rem; }
.toast.error { border-inline-start-color: var(--bad); }
.toast.error .icon { color: var(--bad); }
.toast .body { flex: 1; min-width: 0; }
.toast .close { flex: none; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: .1rem; border-radius: 4px; margin-top: .1rem; }
.toast .close:hover { color: var(--text); background: var(--brand-soft); }
.flash { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; background: var(--ok-soft); color: #0b6b3a; border-inline-start: 4px solid var(--ok); }
.flash.error { background: var(--bad-soft); color: var(--bad); border-inline-start-color: var(--bad); }
.flash.warn { background: var(--warn-soft); color: var(--warn); border-inline-start-color: var(--gold); }
.flash .icon { flex: none; margin-top: .2rem; }
.key-reveal { background: var(--gold-soft); border: 1px dashed var(--gold); padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }
.key-reveal code { display: block; font-size: 1.05rem; word-break: break-all; margin-top: .4rem; font-family: var(--mono); }
.timeline { margin: .5rem 0 0; padding: 0 1.2rem; font-size: .88rem; }
.timeline li { margin-bottom: .25rem; }

/* ---------- the icon ---------- */
.icon { display: inline-block; flex: none; }

/* ---------- pairing: the QR and the six digits ---------- */
.qr { text-align: center; padding: .5rem; }
.qr img, .qr svg { width: 220px; height: 220px; max-width: 100%; image-rendering: pixelated; border: 1px solid var(--line); background: #fff; border-radius: var(--radius-sm); }
.qr img { width: 260px; height: 260px; }
.pairing-code { font-family: var(--mono); font-size: 2rem; letter-spacing: .35em; font-weight: 700; margin: .5rem 0 0; color: var(--brand); }

/* ---------- dashboard: number cards, the 30-day chart ---------- */
.kpis { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: var(--space-4); }
.kpi { margin-bottom: 0; }
.kpi h2 { font-size: .95rem; margin: 0 0 .35rem; color: var(--muted); display: flex; align-items: center; gap: .4rem; }
.kpi .big { font-size: 2rem; font-weight: 700; color: var(--brand); line-height: 1.1; }
.kpi .big small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.kpi > p { margin: .1rem 0 .5rem; }
.kpi .row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .3rem 0; border-top: 1px solid var(--line); font-size: .9rem; }
.chart-scroll { overflow-x: auto; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 170px; direction: ltr; padding-top: .5rem; border-bottom: 1px solid var(--line); min-width: 420px; }
.bars .day { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 1px; height: 100%; border-radius: 3px 3px 0 0; }
.bars .day:hover { background: var(--brand-soft); }
.bars .wa, .bars .sms { flex: 1; max-width: 12px; border-radius: 2px 2px 0 0; }
.bars .wa { background: var(--brand); }
.bars .sms { background: var(--gold); }
.bars-axis { display: flex; justify-content: space-between; direction: ltr; font-size: .75rem; color: var(--muted); margin-top: .25rem; min-width: 420px; }
.legend { margin: 0; display: flex; gap: .9rem; }
.legend span::before { content: ''; display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-inline-end: .35rem; vertical-align: middle; }
.legend .wa::before { background: var(--brand); }
.legend .sms::before { background: var(--gold); }
.chart-note { margin: .4rem 0 0; }

/* ---------- usage meters (the shop's month against its packages) ---------- */
.meter { height: .55rem; background: var(--brand-soft); border-radius: var(--radius-pill); overflow: hidden; margin: .2rem 0 .3rem; }
.meter span { display: block; height: 100%; background: var(--brand); border-radius: var(--radius-pill); }
.meter.warn span { background: var(--gold); }
.meter.bad span { background: var(--bad); }
.meter-block + .meter-block { margin-top: .9rem; }
.meter-block p { margin: 0; }

/* ---------- the shop summary column ---------- */
.summary .card { margin-bottom: var(--space-3); }
.summary .stats { display: grid; grid-template-columns: 1fr; }
.summary .stat { padding: .4rem 0; }
.summary .stat .sub { white-space: nowrap; }
.summary .actions { flex-direction: column; align-items: stretch; }
.summary .actions .btn { width: 100%; }
@media (max-width: 1099px) {
    .summary { order: -1; }
    .summary .actions { flex-direction: row; }
    .summary .actions .btn { width: auto; }
}
@media (min-width: 560px) and (max-width: 1099px) { .summary .stats { grid-template-columns: 1fr 1fr; gap: 0 var(--space-5); } }

/* ---------- packages: rows that edit in place, the new-package form, the shop page's package box ---------- */
table.packages td { vertical-align: middle; }
table.packages input { margin-top: 0; }
table.packages input[type="number"] { max-width: 8rem; }
table.packages tr.editing td { background: var(--gold-soft); }
.package-new { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.package-box { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.package-box > p { margin: .1rem 0 .6rem; }
.package-pick { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.package-pick select, .package-pick input { flex: 1 1 14rem; width: auto; min-width: 0; margin-top: 0; }

/* ---------- the chat ground and the outgoing bubble: what the customer actually received ---------- */
.chat { background: var(--chat); }
.chat td, .chat th { border-bottom-color: rgba(18, 49, 37, .08); }
.chat tbody tr:hover td { background: rgba(255, 255, 255, .4); }
.chat table.stack tr { background: rgba(255, 255, 255, .55); border-color: rgba(18, 49, 37, .12); }
.bubble { display: inline-block; position: relative; max-width: 380px; min-width: 120px; background: var(--bubble); border-radius: 8px; border-start-start-radius: 0; padding: .4rem .55rem .3rem; box-shadow: 0 1px .5px rgba(18, 49, 37, .13); color: var(--text); font-size: .93rem; line-height: 1.35; text-align: start; }
.bubble .body { white-space: pre-wrap; word-break: break-word; }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: .3rem; margin-top: .15rem; font-size: .72rem; color: var(--muted); }
.bubble .meta .status { font-weight: 700; }
.ticks { display: inline-flex; align-items: center; color: var(--tick); }
.ticks svg { width: 17px; height: 12px; display: block; }
.ticks.read { color: var(--tick-read); }
.ticks.failed { color: var(--bad); }
.ticks.pending { color: var(--tick); }
.doc { display: flex; align-items: center; gap: .6rem; background: var(--bubble-deep); border-radius: 6px; padding: .5rem .6rem; margin-bottom: .3rem; }
.doc .pdf { flex: none; width: 30px; height: 36px; border-radius: 3px; background: var(--bad); color: #fff; font: 700 .6rem/36px var(--font); text-align: center; }
.doc .name { flex: 1; min-width: 0; }
.doc .name strong { display: block; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .name span { font-size: .75rem; color: var(--muted); }
.doc a.open { flex: none; width: 30px; height: 30px; border: 1.5px solid var(--muted); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); font-size: .9rem; }
.doc a.open:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); }
@media (max-width: 720px) { .bubble { max-width: 100%; } }
