/* ------------------------------------------------------------------
   Vimo Ads panel — styles layered on top of MudBlazor.
   Colours come from MudBlazor theme variables (see Theme/VimoTheme.cs) so light and dark
   themes both work without a second set of hard-coded values.
   ------------------------------------------------------------------ */

html, body {
    font-family: Vazirmatn, "Noto Naskh Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
}

/* Latin identifiers, ids and permission keys read better monospaced and left-to-right. */
.vimo-mono {
    font-family: ui-monospace, "JetBrains Mono", Consolas, monospace;
    font-size: .78rem;
    direction: ltr;
    display: inline-block;
}

/* Numbers that sit in columns must not jitter as they change. */
.vimo-num {
    font-variant-numeric: tabular-nums;
    font-size: .8rem;
    color: var(--mud-palette-text-secondary);
}

/* --- bidi fix for the RTL panel ---
   Latin words, numbers, dates, ids, usernames and phone numbers must keep their own
   left-to-right order instead of being reordered by the surrounding RTL context.
   `plaintext` derives each value's direction from its first strong character, so
   Persian text stays RTL and English/numeric content reads correctly — panel-wide. */
.mud-typography,
.mud-table-cell,
.mud-chip-content,
.mud-select-item,
.vimo-kpi-value,
.vimo-funnel-value,
.vimo-funnel-label {
    /* `isolate` fixes the ordering of embedded Latin/number runs WITHOUT changing
       text-align, so table columns stay aligned (plaintext would left-align them). */
    unicode-bidi: isolate;
}

/* ---------- boot splash ---------- */
.vimo-splash {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: var(--mud-palette-background);
}

/* ---------- app shell ---------- */
.vimo-appbar {
    border-bottom: 1px solid var(--mud-palette-lines-default);
    backdrop-filter: blur(6px);
}

.vimo-drawer {
    border-inline-start: 1px solid var(--mud-palette-lines-default);
}

.vimo-brand {
    padding-inline: 20px;
}

.vimo-brand-accent {
    color: var(--mud-palette-primary);
}

.vimo-navgroup {
    font-size: .65rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--mud-palette-text-disabled);
    padding: 18px 20px 6px;
    font-family: ui-monospace, Consolas, monospace;
}

.vimo-drawer-foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--mud-palette-lines-default);
}

.vimo-who {
    display: flex;
    flex-direction: column;
    line-height: 1.35;
    min-width: 0;
    flex: 1;
}

.vimo-who-name {
    font-size: .8rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vimo-who-role {
    font-size: .68rem;
    color: var(--mud-palette-text-secondary);
}

/* ---------- business picker in the app bar ---------- */
/* Active-business selector: a compact pill centered in the dense app bar. */
.vimo-bizpick {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding-inline: 12px 8px;
    margin-inline-start: 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--mud-palette-appbar-text) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--mud-palette-appbar-text) 14%, transparent);
    transition: background .15s ease, border-color .15s ease;
}

.vimo-bizpick:hover {
    background: color-mix(in srgb, var(--mud-palette-appbar-text) 14%, transparent);
    border-color: color-mix(in srgb, var(--mud-palette-appbar-text) 28%, transparent);
}

.vimo-bizpick-icon {
    color: var(--mud-palette-appbar-text);
    opacity: .7;
    flex: none;
}

/* Strip the text-field chrome so only the value + chevron show, vertically centered. */
.vimo-bizpick-select {
    margin: 0;
    min-width: 128px;
}

.vimo-bizpick-select .mud-input-control,
.vimo-bizpick-select .mud-input {
    margin: 0 !important;
}

.vimo-bizpick-select .mud-input-slot {
    padding: 0 !important;
    min-height: 0 !important;
}

.vimo-bizpick-select .mud-select-input,
.vimo-bizpick-select .mud-input-slot input {
    color: var(--mud-palette-appbar-text) !important;
    font-weight: 700;
    font-size: .9rem;
}

.vimo-bizpick-select .mud-input-adornment .mud-icon-root {
    color: var(--mud-palette-appbar-text) !important;
    opacity: .8;
}

/* ---------- dashboard ---------- */
.vimo-kpi {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    min-height: 118px;
}

.vimo-kpi-icon {
    position: absolute;
    inset-inline-end: 12px;
    top: 12px;
    opacity: .5;
}

.vimo-kpi-value {
    font-weight: 800;
    line-height: 1.1;
    margin-block: 4px 0;
}

.vimo-kpi-title {
    font-weight: 600;
}

.vimo-funnel-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-block: 8px;
}

.vimo-funnel-label {
    width: 96px;
    font-size: .8rem;
    text-align: start;
    flex: none;
}

.vimo-funnel-track {
    flex: 1;
    height: 22px;
    border-radius: 6px;
    background: var(--mud-palette-action-disabled-background);
    overflow: hidden;
}

.vimo-funnel-fill {
    height: 100%;
    border-radius: 6px;
    transition: width .4s ease;
    min-width: 2px;
}

.vimo-funnel-value {
    width: 64px;
    text-align: end;
    font-weight: 700;
    font-size: .85rem;
    flex: none;
}

/* ---------- page frame ---------- */
.vimo-main {
    background: var(--mud-palette-background);
    min-height: 100vh;
}

.vimo-container {
    padding-block: 24px 64px;
}

.vimo-pagehead {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.vimo-pagetitle {
    font-weight: 800;
    letter-spacing: -.01em;
}

.vimo-pagesub {
    color: var(--mud-palette-text-secondary);
    margin-top: 2px;
}

.vimo-pagehead-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.vimo-loading {
    margin-block: 24px;
}

.vimo-block {
    margin-block: 12px;
}

/* ---------- cards & grids ---------- */
.vimo-card {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 12px;
    overflow: hidden;
    background: var(--mud-palette-surface);
}

.vimo-cell-title {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* both name and the @username sub-line hug the start (right in RTL) */
    line-height: 1.4;
}

.vimo-cell-name {
    font-weight: 600;
}

.vimo-cell-sub {
    font-size: .72rem;
    color: var(--mud-palette-text-secondary);
}

.vimo-rowacts {
    display: flex;
    gap: 2px;
    justify-content: flex-start;
}

/* ---------- empty state ---------- */
.vimo-emptystate {
    border: 1px dashed var(--mud-palette-lines-default);
    border-radius: 12px;
    background: transparent;
    padding: 48px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.vimo-emptystate-icon {
    color: var(--mud-palette-text-disabled);
    margin-bottom: 4px;
}

.vimo-emptystate-text {
    color: var(--mud-palette-text-secondary);
    max-width: 46ch;
}

/* ---------- forms & dialogs ---------- */
.vimo-field {
    margin-bottom: 14px;
}

.vimo-dialog-error,
.vimo-login-error {
    margin-top: 4px;
    margin-bottom: 12px;
}

.vimo-dialog-detail {
    display: block;
    margin-top: 8px;
    color: var(--mud-palette-text-secondary);
}

/* ---------- login ---------- */
.vimo-login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(820px 380px at 50% -8%, rgba(117, 3, 39, .42), transparent 68%),
        var(--mud-palette-background);
}

.vimo-login-card {
    width: 100%;
    max-width: 372px;
    padding: 30px 26px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 16px;
    background: var(--mud-palette-surface);
}

.vimo-login-brand {
    margin-bottom: 22px;
}

.vimo-login-tag {
    color: var(--mud-palette-text-secondary);
    display: block;
}

.vimo-login-submit {
    margin-top: 4px;
}

.vimo-btn-spinner {
    margin-inline-end: 8px;
}

/* ---------- blazor error strip ---------- */
#blazor-error-ui {
    color-scheme: light only;
    background: #ffeaea;
    color: #6a1111;
    bottom: 0;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, .2);
    display: none;
    left: 0;
    padding: 10px 16px;
    position: fixed;
    width: 100%;
    z-index: 1500;
    font-size: .85rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    left: 12px;
    top: 8px;
}

/* ---------- card sub-sections ---------- */
.vimo-cardhead {
    padding: 14px 18px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.vimo-cardbody {
    padding: 18px;
}

.vimo-muted {
    color: var(--mud-palette-text-secondary);
}

.vimo-note {
    border: 1px solid var(--mud-palette-lines-default);
}

/* Long free text in a grid cell must not stretch the row. */
.vimo-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 46ch;
    white-space: normal;
}

/* Phone numbers, usernames and URLs stay left-to-right inside the RTL page. */
.vimo-ltr-input input {
    direction: ltr;
    text-align: left;
}

.vimo-gridsearch {
    max-width: 280px;
}

/* ---------- permission picker ---------- */
.vimo-perms {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    background: var(--mud-palette-background-gray);
    padding: 6px 14px 14px;
    max-height: 340px;
    overflow-y: auto;
}

.vimo-perms-group {
    margin-top: 10px;
}

.vimo-perms-grouphead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    padding-bottom: 4px;
    margin-bottom: 6px;
    position: sticky;
    top: 0;
    background: var(--mud-palette-background-gray);
    z-index: 1;
}

.vimo-perms-groupname {
    font-family: ui-monospace, Consolas, monospace;
    font-size: .7rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--mud-palette-primary);
}

.vimo-perms-toggle {
    font-size: .7rem;
    min-width: 0;
}

.vimo-perms-items {
    display: grid;
    gap: 0 12px;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.vimo-perms-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.vimo-perms-item--blocked {
    opacity: .55;
}

.vimo-perms-lock {
    color: var(--mud-palette-text-disabled);
}

.vimo-preset-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

/* ---------- permission matrix ---------- */
.vimo-matrix-scroll {
    overflow-x: auto;
    max-height: 620px;
    overflow-y: auto;
}

.vimo-matrix {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
}

.vimo-matrix th,
.vimo-matrix td {
    border-bottom: 1px solid var(--mud-palette-lines-default);
    padding: 7px 12px;
    white-space: nowrap;
}

.vimo-matrix thead th {
    position: sticky;
    top: 0;
    background: var(--mud-palette-background-gray);
    z-index: 2;
}

/* The permission column stays put while businesses scroll sideways. */
.vimo-matrix-permhead,
.vimo-matrix-perm {
    position: sticky;
    inset-inline-start: 0;
    background: var(--mud-palette-surface);
    text-align: right;
    z-index: 1;
}

.vimo-matrix-permhead {
    z-index: 3;
    background: var(--mud-palette-background-gray);
    font-size: .7rem;
    color: var(--mud-palette-text-secondary);
    font-weight: 600;
}

.vimo-matrix-bizhead {
    text-align: center;
    min-width: 132px;
}

.vimo-matrix-bizhead--out {
    opacity: .5;
}

.vimo-matrix-bizname {
    display: block;
    font-weight: 700;
    font-size: .8rem;
}

.vimo-matrix-bizmeta {
    display: block;
    font-size: .65rem;
    font-weight: 400;
    color: var(--mud-palette-text-secondary);
}

.vimo-matrix-cell {
    text-align: center;
    padding: 2px;
}

.vimo-matrix-grouprow td {
    background: var(--mud-palette-background-gray);
    font-family: ui-monospace, Consolas, monospace;
    font-size: .68rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--mud-palette-primary);
    position: sticky;
    inset-inline-start: 0;
}

.vimo-matrix-yes {
    color: var(--mud-palette-success);
    font-weight: 700;
}

.vimo-matrix-no,
.vimo-matrix-void {
    color: var(--mud-palette-text-disabled);
}

/* ---------- roles ---------- */
.vimo-rolegrid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.vimo-rolecard {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vimo-rolecard-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.vimo-rolecard-perms {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.vimo-perm-tag {
    background: var(--mud-palette-background-gray);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 5px;
    padding: 1px 7px;
    font-size: .68rem;
}

.vimo-perm-tag--more {
    color: var(--mud-palette-text-secondary);
    font-family: inherit;
}

/* ---------- leads ---------- */
.vimo-leads {
    display: grid;
    gap: 16px;
    grid-template-columns: 260px 1fr;
    align-items: start;
}

@media (max-width: 860px) {
    .vimo-leads {
        grid-template-columns: 1fr;
    }
}

.vimo-leads-cat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}

.vimo-list-on {
    background: var(--mud-palette-action-default-hover);
    font-weight: 700;
}

.vimo-upload {
    margin-block: 12px;
}

.vimo-uploadstats {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr;
    margin-top: 12px;
}

.vimo-uploadstat {
    background: var(--mud-palette-background-gray);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 9px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.vimo-uploadstat-k {
    font-size: .7rem;
    color: var(--mud-palette-text-secondary);
}

.vimo-uploadstat-v {
    font-size: 1.15rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.vimo-uploadstat-v--ok {
    color: var(--mud-palette-success);
}

/* ---------- ding composer ---------- */
.vimo-composer-head {
    margin-top: 8px;
    margin-bottom: 6px;
}

.vimo-chanlist {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    max-height: 340px;
    overflow-y: auto;
}

/* The picker groups channels under their lead category; the panel body holds the rows, so it
   supplies no padding of its own. */
.vimo-chanlist .mud-expand-panel-text {
    padding: 0;
}

.vimo-cangroup-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.vimo-cangroup-name {
    font-size: .84rem;
    font-weight: 600;
}

.vimo-cangroup-meta {
    font-size: .7rem;
    color: var(--mud-palette-text-secondary);
    /* Latin counts inside an RTL run: isolate so they cannot reorder the label around them. */
    unicode-bidi: isolate;
}

.vimo-chanrow {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.vimo-chanrow:last-child {
    border-bottom: none;
}

.vimo-chaninfo {
    display: flex;
    flex-direction: column;
    line-height: 1.35;
    min-width: 0;
    flex: 1;
}

.vimo-chaninfo-name {
    font-size: .82rem;
    font-weight: 600;
}

.vimo-chaninfo-meta {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: .68rem;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* A channel username is Latin inside an RTL line. Laying the parts out as flex items — each one its
   own bidi run — keeps "@name · 28,872 عضو" in that order instead of letting the count slide into
   the middle of the username. */
.vimo-chaninfo-meta > bdi {
    unicode-bidi: isolate;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vimo-chaninfo-sep {
    opacity: .6;
}

.vimo-chantake {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .72rem;
    color: var(--mud-palette-text-secondary);
}

.vimo-chantake-input {
    width: 92px;
}

.vimo-tally {
    background: var(--mud-palette-background-gray);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    padding: 12px 14px;
    margin-top: 12px;
}

.vimo-tally-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: .85rem;
}

.vimo-tally-line b {
    font-variant-numeric: tabular-nums;
    font-size: 1.05rem;
    color: var(--mud-palette-primary);
}

.vimo-tally-note {
    font-size: .7rem;
    color: var(--mud-palette-text-secondary);
    margin-top: 6px;
}

.vimo-recipients {
    margin-top: 10px;
}

.vimo-daterow {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr 1fr;
}

.vimo-stepper {
    margin-bottom: 8px;
}

/* ---- campaign insight ---------------------------------------------------- */

.vimo-insight-empty {
    padding: 20px 4px 8px;
    text-align: center;
}

.vimo-insight-meta {
    font-size: .8125rem;
    margin: 4px 0 8px;
}

/* Hour-of-day histogram: 24 vertical bars, so the shape of a day is readable at a
   glance. Plain CSS on purpose — the rest of this panel charts the same way and no
   charting library is pulled in for one figure. */
.vimo-hours {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 132px;
}

.vimo-hour {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    height: 100%;
    min-width: 0;
}

.vimo-hour-track {
    display: flex;
    align-items: flex-end;
    width: 100%;
    flex: 1 1 auto;
    background: var(--mud-palette-action-disabled-background);
    border-radius: 3px;
    overflow: hidden;
}

.vimo-hour-fill {
    width: 100%;
    /* An hour with no joins still shows a hairline, so a gap reads as "measured, zero"
       rather than as a rendering fault. */
    min-height: 2px;
    background: var(--mud-palette-primary);
    border-radius: 3px;
    transition: height .18s ease;
}

.vimo-hour-fill.is-peak {
    background: var(--mud-palette-success);
}

.vimo-hour-label {
    font-size: .625rem;
    line-height: 1;
    color: var(--mud-palette-text-secondary);
}

/* Settings page: label and help on one side, the input on the other, stacking on narrow screens. */
.vimo-setting {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.vimo-setting:last-child {
    border-bottom: none;
}

.vimo-setting-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.vimo-setting-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .88rem;
    font-weight: 600;
}

.vimo-setting-help {
    font-size: .72rem;
    line-height: 1.6;
    color: var(--mud-palette-text-secondary);
}

.vimo-setting-input {
    width: 280px;
    flex-shrink: 0;
}

@media (max-width: 700px) {
    .vimo-setting {
        flex-direction: column;
    }

    .vimo-setting-input {
        width: 100%;
    }
}
