/* ============================================================
   VisFlow app components (Aidithi look). Loaded together with theme.css
   on themed pages only: /C/*, login, errors and the admin shell.
   Everything is token-driven (var(--token)) so light/dark both work.
   ============================================================ */

/* ---- Page canvas for themed public pages ---- */
html[data-theme],
body.vf-themed {
    background: var(--bg-main);
    color: var(--text-primary);
}

body.vf-themed main.app-page {
    background: transparent;
}

/* Centres a card in the space above the "Powered by" footer. */
.vf-page {
    min-height: calc(100vh - var(--powered-footer-h, 48px));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.vf-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: none;
    border-radius: 18px;
    box-shadow: 0 5px 24px var(--shadow);
    padding: 28px;
}

.vf-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

    .vf-brand img {
        height: 34px;
        width: auto;
    }

.vf-title {
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--text-primary);
}

.vf-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 22px;
}

.vf-steps {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

    .vf-steps span {
        flex: 1;
        height: 5px;
        border-radius: 5px;
        background: var(--border-strong);
    }

        .vf-steps span.done {
            background: var(--accent-primary);
        }

.vf-step-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 6px;
}

/* ---- Form bits ---- */
.custom-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.custom-input {
    height: 50px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-formcontrols);
    color: var(--text-primary);
}

    .custom-input:focus {
        border-color: var(--accent-primary);
        box-shadow: none;
    }

/* ---- Buttons ---- */
.vf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent-primary);
    color: var(--accent-contrast);
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    min-height: 48px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(var(--accent-primary-rgb), .25);
}

    .vf-btn:hover,
    .vf-btn:focus {
        background: var(--accent-strong);
        color: var(--accent-contrast);
    }

    .vf-btn:disabled {
        opacity: .6;
        cursor: default;
    }

.vf-btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    color: var(--accent-primary);
    border: 2px solid var(--accent-primary);
    border-radius: 12px;
    padding: 10px 18px;
    min-height: 48px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

    .vf-btn-outline:hover,
    .vf-btn-outline:focus {
        background: var(--accent-primary);
        color: var(--accent-contrast);
    }

.vf-btn-sm {
    min-height: 34px;
    padding: 5px 12px;
    font-size: 13px;
    border-radius: 9px;
    box-shadow: none;
}

.vf-link {
    color: var(--accent-primary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
}

    .vf-link:hover {
        text-decoration: underline;
        color: var(--accent-strong);
    }

/* ---- Digital card (the pass stays white in both themes so the QR keeps its contrast) ---- */
.pass-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    color: #1b1b1f;
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .18);
    overflow: hidden;
}

.pass-qr {
    padding: 24px 24px 8px;
    text-align: center;
}

    .pass-qr img {
        width: 100%;
        max-width: 280px;
        border-radius: 12px;
    }

.pass-name {
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    margin: 8px 20px 2px;
    word-break: break-word;
}

.pass-company {
    text-align: center;
    color: #5b5b66;
    margin: 0 20px 4px;
    word-break: break-word;
}

.pass-phone {
    text-align: center;
    color: #5b5b66;
    font-size: .9rem;
    margin-bottom: 18px;
}

.pass-powered {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #ececf2;
    font-size: .8rem;
    color: #5b5b66;
}

    .pass-powered img {
        height: 22px;
        width: auto;
    }

.pass-actions {
    width: 100%;
    max-width: 400px;
}

.vf-error {
    color: var(--danger);
    font-size: .9rem;
    min-height: 1.2em;
}

/* ---- Admin pages: header, tiles, badges, tables ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

    .page-header h2,
    .page-header h4 {
        margin: 0;
        font-weight: 700;
        color: var(--text-primary);
    }

.breadcrumb-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.queue-container {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 18px var(--shadow);
}

.vf-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 900px) {
    .vf-kpis {
        grid-template-columns: repeat(2, 1fr);
    }
}

.vf-kpi {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 4px 18px var(--shadow);
}

    .vf-kpi .label {
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 1px;
        color: var(--text-secondary);
        text-transform: uppercase;
    }

    .vf-kpi .value {
        font-size: 30px;
        font-weight: 700;
        color: var(--text-primary);
        line-height: 1.2;
    }

    .vf-kpi.accent .value {
        color: var(--accent-primary);
    }

    .vf-kpi.hot .value {
        color: var(--pink);
    }

/* ---- Home dashboard: clickable KPI cards, trend chart ---- */
/* Five cards. Explicit steps (not auto-fit) so the last row is never a lone orphan:
   5 across -> 3 + 2 -> 2 + 2 with the last card full width -> 1 column.
   The double class beats the base .vf-kpis 4 / 2 column rules above. */
.vf-kpis.vf-kpis-5 {
    grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 1279px) {
    .vf-kpis.vf-kpis-5 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 899px) {
    .vf-kpis.vf-kpis-5 {
        grid-template-columns: repeat(2, 1fr);
    }

        .vf-kpis.vf-kpis-5 > :last-child {
            grid-column: 1 / -1;
        }
}

@media (max-width: 479px) {
    .vf-kpis.vf-kpis-5 {
        grid-template-columns: 1fr;
    }

        .vf-kpis.vf-kpis-5 > :last-child {
            grid-column: auto;
        }
}

a.vf-kpi-link {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: inherit;
    text-decoration: none;
    transition: transform .15s ease, border-color .15s ease;
}

    a.vf-kpi-link:hover {
        color: inherit;
        border-color: var(--accent-secondary);
        transform: translateY(-2px);
    }

    a.vf-kpi-link:focus-visible {
        outline: 2px solid var(--accent-primary);
        outline-offset: 2px;
    }

.vf-kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.vf-kpi-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    background: var(--accent-soft);
    color: var(--accent-primary);
}

    .vf-kpi-icon.hot {
        background: var(--warning-soft);
        color: var(--pink);
    }

.vf-kpi-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

    .vf-kpi-cta i {
        font-size: 10px;
        transition: transform .15s ease;
    }

a.vf-kpi-link:hover .vf-kpi-cta {
    color: var(--accent-primary);
}

    a.vf-kpi-link:hover .vf-kpi-cta i {
        transform: translateX(3px);
    }

@media (prefers-reduced-motion: reduce) {
    a.vf-kpi-link,
    .vf-kpi-cta i {
        transition: none;
    }

        a.vf-kpi-link:hover,
        a.vf-kpi-link:hover .vf-kpi-cta i {
            transform: none;
        }
}

/* The chart's controls sit in one row above its card, never inside it. */
.vf-dash-section {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 28px 0 12px;
}

    .vf-dash-section h5 {
        margin: 0;
        font-weight: 700;
        color: var(--text-primary);
    }

    .vf-dash-section .sub {
        font-size: 13px;
        color: var(--text-secondary);
    }

.vf-dash-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

/* Legend doubles as the series toggle; keys are short strokes in the series colour, text stays ink. */
.vf-dash-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
}

.vf-dash-key {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 2px 4px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

    .vf-dash-key strong {
        color: var(--text-primary);
        font-weight: 700;
    }

    .vf-dash-key:hover {
        background: var(--surface-hover);
    }

    .vf-dash-key:focus-visible {
        outline: 2px solid var(--accent-primary);
        outline-offset: 1px;
    }

    .vf-dash-key[aria-pressed="false"] {
        opacity: .5;
    }

.vf-dash-swatch {
    width: 16px;
    height: 3px;
    border-radius: 2px;
}

    .vf-dash-swatch.s1 { background: var(--series-1); }
    .vf-dash-swatch.s2 { background: var(--series-2); }
    .vf-dash-swatch.s3 { background: var(--series-3); }

.vf-dash-chart {
    position: relative;
    height: 340px;
}

.vf-dash-table {
    max-height: 340px;
    overflow: auto;
}

    /* Day cells are row headers for screen readers but should read as plain data, not as column-header caps. */
    .vf-dash-table .vf-table tbody th {
        font-size: inherit;
        font-weight: 500;
        letter-spacing: normal;
        text-transform: none;
        color: var(--text-primary);
        white-space: nowrap;
    }

    .vf-dash-table .vf-table thead th {
        position: sticky;
        top: 0;
        background: var(--bg-surface);
    }

@media (max-width: 576px) {
    /* The collapsed sidebar + page padding already leave little width, so the chart panel gives some back. */
    .queue-container.vf-dash-card {
        padding: 14px;
    }

    .vf-dash-chart {
        height: 280px;
    }

    .vf-dash-table {
        max-height: 280px;
    }
}

.vf-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

    .vf-tabs a {
        padding: 7px 16px;
        border-radius: 999px;
        font-size: 13px;
        font-weight: 600;
        text-decoration: none;
        color: var(--text-secondary);
        border: 1px solid var(--border);
        background: var(--bg-surface);
    }

        .vf-tabs a:hover {
            color: var(--accent-primary);
            background: var(--surface-hover);
        }

        .vf-tabs a.active {
            background: var(--accent-primary);
            border-color: var(--accent-primary);
            color: var(--accent-contrast);
        }

.vf-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.vf-badge-new {
    color: var(--info);
    background: var(--info-soft);
}

.vf-badge-viewed {
    color: var(--success);
    background: var(--success-soft);
}

.vf-badge-hot {
    color: var(--pink);
    background: var(--warning-soft);
}

.vf-badge-muted {
    color: var(--text-secondary);
    background: var(--bg-inset);
}

.vf-table {
    width: 100%;
    margin-bottom: 0;
}

    .vf-table th {
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 1px;
        text-transform: uppercase;
        color: var(--text-secondary);
        white-space: nowrap;
    }

    .vf-table td {
        vertical-align: middle;
    }

.vf-row-new td:first-child {
    box-shadow: inset 3px 0 0 var(--accent-secondary);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 20px;
    border: 2px dashed var(--border-strong);
    border-radius: 14px;
    color: var(--text-secondary);
}

    .empty-state .icon {
        width: 70px;
        height: 70px;
        border-radius: 50%;
        background: var(--accent-soft);
        color: var(--accent-primary);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 28px;
        margin-bottom: 14px;
    }

/* ---- Visitor detail ---- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
}

.info-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-inset);
}

    .info-item .chip {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--accent-primary);
        background: var(--accent-soft);
    }

    .info-item .lbl {
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 1px;
        text-transform: uppercase;
        color: var(--text-secondary);
    }

    .info-item > div:last-child {
        min-width: 0;
    }

    .info-item .val {
        font-weight: 600;
        color: var(--text-primary);
        overflow-wrap: break-word;
    }

/* ---- Visitor trail (ported from Aidithi _VisitorTrail) ---- */
.visitor-trail-card {
    overflow: hidden;
    background: var(--bg-surface);
    border-radius: 18px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .05);
    border: 1px solid var(--border);
}

.visitor-trail-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.visitor-trail-heading {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
}

.visitor-trail-body {
    min-height: 140px;
    padding: 24px;
}

.empty-trail {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    padding: 12px;
    text-align: center;
}

.empty-trail-title {
    margin: 0 0 6px;
    color: var(--accent-primary);
    font-size: 17px;
    font-weight: 700;
}

.empty-trail-text {
    max-width: 420px;
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

.visitor-trail-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.trail-item {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 17px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-surface);
}

.trail-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    color: var(--accent-primary);
    background: var(--accent-soft);
    border-radius: 10px;
}

.trail-description {
    margin: 0 0 5px;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.trail-user {
    display: inline-block;
    padding: 5px 9px;
    color: var(--info);
    background: var(--bg-inset);
    border-radius: 8px;
    font-size: 12px;
}

/* ---- Admin shell: sidebar brand (navy logo needs a light pill on the dark sapphire sidebar) ---- */
.sidebar-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 12px;
    padding: 8px 12px;
}

    .sidebar-brand img {
        height: 24px;
        width: auto;
    }

@media (max-width: 768px) {
    .sidebar-brand {
        padding: 6px;
    }

        .sidebar-brand img {
            height: 18px;
        }
}
