/* Shared UI components: empty states, skeletons, toasts, responsive tables, cards */

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1.5rem;
    background: #fff;
    border-radius: 16px;
    border: 1px dashed #cbd5e1;
    color: #475569;
}

.empty-state-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 1.25rem;
}

.empty-state h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
}

.empty-state p {
    margin: 0 0 1.25rem 0;
    max-width: 360px;
    line-height: 1.5;
    font-size: 0.95rem;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s infinite;
    border-radius: 6px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
    margin-bottom: 1rem;
}

.skeleton-title {
    height: 18px;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-line {
    height: 12px;
    margin-bottom: 0.75rem;
}

.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 75%; }
.skeleton-line.long { width: 100%; }

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 360px;
    width: 100%;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    animation: toast-in 0.3s ease-out;
    pointer-events: auto;
}

.toast.toast-success { border-left: 4px solid #22c55e; }
.toast.toast-error { border-left: 4px solid #dc2626; }
.toast.toast-warning { border-left: 4px solid #f59e0b; }
.toast.toast-info { border-left: 4px solid #2563eb; }

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-success .toast-icon { color: #22c55e; }
.toast-error .toast-icon { color: #dc2626; }
.toast-warning .toast-icon { color: #f59e0b; }
.toast-info .toast-icon { color: #2563eb; }

.toast-content {
    flex: 1;
    font-size: 0.9rem;
    color: #334155;
}

.toast-content strong {
    display: block;
    color: #0f172a;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.toast-close {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0;
    line-height: 1;
}

.toast-close:hover { color: #475569; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(20px); }
}

.toast.hiding {
    animation: toast-out 0.3s ease-in forwards;
}

/* Cards */
.card-modern {
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    padding: 1.5rem;
    transition: box-shadow 0.2s, transform 0.2s;
}

.card-modern:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.card-modern h3 {
    margin: 0 0 0.75rem 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
}

.card-modern p {
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

/* Responsive Tables */
.responsive-table-wrapper {
    overflow-x: auto;
    /* Without min-width:0 a scroll container inside a flex or grid parent is still sized by
       its content, so overflow-x:auto silently does nothing and the page scrolls sideways
       instead of the table. */
    min-width: 0;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #fff;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 640px;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.data-table th {
    background: #f8fafc;
    font-weight: 700;
    color: #475569;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table td strong {
    color: #0f172a;
}

/* Keep the actions cell a normal table-cell (NOT display:flex) so its bottom border lines up
   with the rest of the row — a flex td renders its border at the flex box's height, which is
   shorter than a tall row and shows as a broken/floating divider. Children lay out inline. */
.data-table .actions {
    white-space: nowrap;
    vertical-align: middle;
}

.data-table .actions > a,
.data-table .actions > .inline {
    display: inline-block;
    vertical-align: middle;
}

.data-table .actions > * + * {
    margin-left: 0.5rem;
}

/* .form is a CSS grid (site.css sets `.form{display:grid}`), so a grid item stretches to the
   full column width by default — which made every submit button span the whole form. Keep
   submit buttons their natural size, left-aligned. Full-width is still available via .w-100. */
.form > button:not(.w-100),
.form > .btn:not(.w-100) {
    justify-self: start;
}

/* The base .btn in site.css never set a cursor, so buttons showed the default arrow. */
.btn {
    cursor: pointer;
}

/* Mobile card table */
@media (max-width: 768px) {
    .data-table {
        min-width: unset;
    }

    .data-table thead {
        display: none;
    }

    .data-table tr {
        display: block;
        border-bottom: 1px solid #e2e8f0;
        padding: 1rem;
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: none;
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        font-size: 0.8rem;
    }

    .data-table .actions {
        justify-content: flex-end;
    }
}

/* Buttons */
.btn-modern {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-modern-primary {
    background: #2563eb;
    color: #fff;
}

.btn-modern-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-modern-secondary {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
}

.btn-modern-secondary:hover {
    background: #e2e8f0;
}

.btn-modern-ghost {
    background: transparent;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.btn-modern-ghost:hover {
    background: #f8fafc;
    color: #334155;
}

/* Form UX */
.form-modern .form-group {
    margin-bottom: 1.25rem;
}

.form-modern label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.4rem;
}

.form-modern input,
.form-modern select,
.form-modern textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 0.95rem;
    background: #fff;
    color: #111827;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-modern input:focus,
.form-modern select:focus,
.form-modern textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-modern .text-danger {
    color: #dc2626;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* Metric grid */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.2s, transform 0.2s;
}

.metric:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.metric span {
    display: block;
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.metric strong {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0.15rem 0;
}

.metric small {
    display: block;
    font-size: 0.75rem;
    color: #94a3b8;
}

.metric.primary .metric-icon { background: #eff6ff; color: #2563eb; }
.metric.positive .metric-icon { background: #f0fdf4; color: #22c55e; }
.metric.negative .metric-icon { background: #fef2f2; color: #dc2626; }
.metric.warning .metric-icon { background: #fffbeb; color: #f59e0b; }
.metric.neutral .metric-icon { background: #f1f5f9; color: #64748b; }

/* Grids */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* Job grid */
.job-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.job-card {
    display: flex;
    flex-direction: column;
}

.job-card .job-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.job-card .job-top .expires {
    color: #64748b;
}

.job-card .job-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 1rem;
}

/* Timeline */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notice {
    position: relative;
}

.notice.unread {
    border-left: 4px solid #2563eb;
}

.notice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.notice h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.notice p {
    margin: 0;
    color: #64748b;
}

/* Mobile utilities */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .stack-mobile { flex-direction: column !important; }
    .full-mobile { width: 100% !important; }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .job-grid {
        grid-template-columns: 1fr;
    }

    .job-card .job-actions {
        flex-direction: column;
    }

    .job-card .job-actions form {
        width: 100%;
    }

    .job-card .job-actions .btn {
        width: 100%;
    }
}

@media (min-width: 769px) {
    .hide-desktop { display: none !important; }
}

/* ---------------------------------------------------------------------------
   Sidebar pending-work count (Patient Requests). Driven by js/pending-count.js.

   Added here rather than to site.css because that file has a UTF-16 tail the
   browser discards; this file is clean ASCII. The class is new and used by
   exactly one element, so no existing page can be affected.

   .nav-section a is display:flex, so margin-left:auto parks the pill on the
   right edge of the link regardless of how long the label is.
   --------------------------------------------------------------------------- */
.nav-count {
    margin-left: auto;
    min-width: 1.4rem;
    padding: 0 .4rem;
    height: 1.4rem;
    border-radius: 999px;
    background: #d92d20;
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
    line-height: 1.4rem;
    text-align: center;
    /* tabular so 8 -> 9 -> 10 does not make the pill jitter */
    font-variant-numeric: tabular-nums;
}

/* ── Pager ───────────────────────────────────────────────────────────────────
 *
 * `_Pager.cshtml` has been rendering <nav class="pager"> with a .pager-status span
 * since it was written, and NEITHER class was ever styled — not in site.css (checked
 * both its ASCII and UTF-16 halves), not here. So the control came out as an unstyled
 * inline run at the very bottom of the page: no spacing, no alignment, nothing to mark
 * it as navigation. Easy to scroll past without realising it is there, which is what
 * "I can't see the pagination" was.
 *
 * Affects every paged page, not just Chat History — Support History, Earnings and
 * Clinic Payouts all use the same partial.
 */
.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e2e8f0;
}

.pager-status {
    color: #475569;
    font-size: 0.9rem;
    font-weight: 600;
    /* Digits in a fixed-width slot, so "Page 9 of 10" does not shift the buttons. */
    font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
    /* Thumb-sized targets, status on its own line above them. */
    .pager {
        gap: 0.5rem;
    }

    .pager-status {
        order: -1;
        width: 100%;
        text-align: center;
    }

    .pager .btn {
        flex: 1 1 0;
        justify-content: center;
    }
}

/* ── Filter toolbar ──────────────────────────────────────────────────────────
 *
 * `.toolbar` and `.input` are referenced by every filter form in the portal
 * (_EarningsView, Admin/Earnings, SuperAdmin/Payouts, SuperAdmin/ClinicPayouts) and
 * NEITHER class has ever been defined — not in site.css's live region, not in its
 * UTF-16 tail, not anywhere. Checked by byte offset, same as `.pager`.
 *
 * So the fields were styled only by site.css's bare `input,textarea,select{width:100%}`,
 * and each <label> was an unstyled flex item sized by its content. That is fine for a
 * text box, but an <input type="date"> carries an intrinsic minimum width (the browser's
 * own dd/mm/yyyy + calendar UI, ~130-190px) and a flex item defaults to min-width:auto —
 * so the Date label could not shrink and pushed out of the card on a narrow screen.
 *
 * min-width:0 is the fix; the flex-basis just makes the row wrap tidily instead of
 * cramming three filters onto one line.
 */
.toolbar label {
    display: flex;
    flex-direction: column;
    flex: 1 1 170px;
    min-width: 0;
}

.toolbar label input,
.toolbar label select,
.toolbar .input {
    width: 100%;
    min-width: 0;
}

/* Buttons keep their natural width next to the fields. */
.toolbar > .btn,
.toolbar > button {
    flex: 0 0 auto;
}

@media (max-width: 480px) {
    /* One filter per line, then the buttons share a row underneath. */
    .toolbar label {
        flex-basis: 100%;
    }

    .toolbar > .btn,
    .toolbar > button {
        flex: 1 1 0;
        justify-content: center;
    }
}

/* ── Inline forms: Mark Paid + Ref, Approve/Deactivate ───────────────────────
 *
 * site.css defines `.inline { display: inline }` and nothing else, so an inline form
 * had no way to space its children — the Ref input and the Mark Paid button on
 * SuperAdmin → Clinic Payouts sat welded together with no gap.
 *
 * Two of the three classes that form uses were not styled at all:
 *   .input-sm  absent from the codebase entirely
 *   .btn-sm    present only in site.css's UTF-16 tail, which browsers discard
 *              (R-LIOS-029) — so it also silently did nothing in _Layout's profile
 *              card and on the Profile pages
 *
 * inline-flex keeps the form inline in the table cell while giving it gap and
 * alignment. Used by ClinicPayouts, Admin/Doctors, SuperAdmin/Facilities and
 * Doctor/Reschedules, all of which wrap buttons, so all four gain the spacing.
 */
.inline {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* The global `input { width:100%; margin-top:6px }` in site.css is meant for stacked
   form fields and misaligns an input sitting in a row, so both are overridden here. */
.input-sm {
    width: auto;
    flex: 1 1 130px;
    min-width: 0;
    margin-top: 0;
    padding: 0.45rem 0.6rem;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font: inherit;
    font-size: 0.85rem;
}

.input-sm:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-sm {
    padding: 0.45rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 8px;
    white-space: nowrap;
}

@media (max-width: 768px) {
    /* In card mode the cell is narrow, so stack the field above the button with the
       same gap rather than squeezing them side by side. */
    .inline {
        display: flex;
        width: 100%;
    }

    .input-sm {
        flex-basis: 100%;
    }

    .inline .btn-sm {
        flex: 1 1 0;
        justify-content: center;
    }
}
