/*
 * my.afftrack.com UI v2 - additions on top of the AffTrack admin v2 look
 * Added 2026-09-29. Load order: vendor Bootstrap 5 -> admin-v2.css -> components.css -> this file.
 *
 * admin-v2.css and components.css are copied unchanged from the v3 admin (instance 191 pilot),
 * so both products share one look. Everything specific to my.afftrack lives here:
 *   - brand tokens (AffTrack green instead of a per-instance color)
 *   - sidebar section labels, nav badges and action links
 *   - public (signed-out) card layout for login / password reset / terms
 *   - ticket conversation thread, usage meters, invoice document + print
 *   - toasts, copy fields, progress bar
 */

:root {
    --at-brand: #3d7a16;
    --at-brand-rgb: 61, 122, 22;
    --at-brand-contrast: #ffffff;
    --at-accent: #8dc63f;
    --at-success: #1e6b36;
    --at-warning: #8a5a00;
}

/* ------------------------------------------------------------------ */
/* Sidebar extras                                                      */
/* ------------------------------------------------------------------ */

.at-sidebar-brand img {
    max-height: 26px;
}

.at-nav-label {
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #98a2b3;
    padding: 14px 10px 4px;
}

.at-nav a.at-nav-link.at-nav-top {
    padding-left: 10px;
    font-weight: 500;
    color: var(--at-text);
}

.at-nav a.at-nav-link.at-nav-top.active {
    font-weight: 600;
}

.at-nav a.at-nav-link.at-nav-top > i {
    width: 18px;
    text-align: center;
    color: var(--at-text-muted);
}

.at-nav a.at-nav-link.at-nav-top.active > i {
    color: var(--at-brand);
}

.at-nav button.at-nav-link {
    width: 100%;
    background: none;
    border: 0;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: var(--at-radius-sm);
    color: var(--at-text);
    font-weight: 500;
    font-size: .8125rem;
}

.at-nav button.at-nav-link:hover {
    background: var(--at-surface-2);
}

.at-nav button.at-nav-link > i {
    width: 18px;
    text-align: center;
    color: var(--at-text-muted);
}

.at-nav-badge {
    margin-left: auto;
    min-width: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--at-surface-2);
    border: 1px solid var(--at-border);
    color: #475467;
    font-size: .6875rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.at-nav-badge.hot {
    background: #fdecec;
    border-color: #f1b5b5;
    color: var(--at-danger);
}

.at-nav-sub {
    font-size: .6875rem;
    color: var(--at-text-muted);
    margin-left: auto;
    white-space: nowrap;
}

/* Topbar extras ------------------------------------------------------ */

.at-jump {
    display: flex;
    align-items: stretch;
    flex: 0 1 420px;
    height: 36px;
    background: var(--at-surface-2);
    border: 1px solid var(--at-border);
    border-radius: 8px;
    overflow: hidden;
}

.at-jump:focus-within {
    background: var(--at-surface);
    border-color: var(--at-brand);
    box-shadow: 0 0 0 3px rgba(var(--at-brand-rgb), .15);
}

.at-jump select,
.at-jump input {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none;
    font-size: .8125rem;
    color: var(--at-text);
}

.at-jump select {
    border-right: 1px solid var(--at-border) !important;
    padding: 0 8px 0 10px;
    max-width: 110px;
    font-weight: 600;
}

.at-jump input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0 10px;
}

.at-jump button {
    border: 0;
    background: none;
    color: var(--at-text-muted);
    padding: 0 12px;
}

.at-balance {
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

a.at-balance:hover { text-decoration: none; filter: brightness(.97); }
.at-balance.due { background: #fdecec; color: #a11c1c; }
.at-balance.credit { background: #e3f4e8; color: #1e6b36; }

.at-topbar .btn {
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .at-topbar .at-hide-xs {
        display: none !important;
    }
}

/* ------------------------------------------------------------------ */
/* Public (signed-out) pages                                           */
/* ------------------------------------------------------------------ */

body.at-v2-public {
    background:
        radial-gradient(1200px 600px at 110% -10%, rgba(141, 198, 63, .18), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(var(--at-brand-rgb), .10), transparent 60%),
        var(--at-bg) !important;
}

.at-public {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 16px 24px;
}

.at-public-logo {
    margin-bottom: 22px;
}

.at-public-logo img {
    height: 34px;
    width: auto;
}

.at-public-card {
    width: 100%;
    max-width: 420px;
    background: var(--at-surface);
    border: 1px solid var(--at-border);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(16, 24, 40, .08);
    padding: 28px;
}

.at-public-card.wide {
    max-width: 880px;
}

.at-public-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -.01em;
    margin: 0 0 4px;
}

.at-public-sub {
    color: var(--at-text-muted);
    font-size: .8125rem;
    margin: 0 0 20px;
}

.at-public-foot {
    margin-top: auto;
    padding-top: 24px;
    font-size: .75rem;
    color: var(--at-text-muted);
    text-align: center;
}

.at-public-foot a {
    color: var(--at-text-muted);
}

.at-link-btn {
    background: none;
    border: 0;
    padding: 0;
    color: var(--at-brand);
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
}

.at-link-btn:hover {
    text-decoration: underline;
}

/* ------------------------------------------------------------------ */
/* Callouts                                                            */
/* ------------------------------------------------------------------ */

.at-callout {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    border-radius: var(--at-radius);
    border: 1px solid var(--at-border);
    background: var(--at-surface);
    padding: 14px 16px;
    margin-bottom: 16px;
    box-shadow: var(--at-shadow);
}

.at-callout > i {
    font-size: 1.125rem;
    margin-top: 2px;
}

.at-callout-title {
    font-weight: 700;
    margin: 0 0 2px;
    font-size: .875rem;
}

.at-callout p {
    margin: 0;
    font-size: .8125rem;
}

.at-callout-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.at-callout.danger { border-color: #f1b5b5; background: #fdf3f3; color: #7a1a1a; }
.at-callout.warning { border-color: #f5d38a; background: #fffaf0; color: #6b4a00; }
.at-callout.info { border-color: #b9dcf3; background: #f3f9fd; color: #134e75; }
.at-callout.success { border-color: #b8e0c3; background: #f3faf5; color: #1e6b36; }

@media (max-width: 767.98px) {
    .at-callout { flex-wrap: wrap; }
    .at-callout-actions { margin-left: 0; }
}

/* Numbered steps ----------------------------------------------------- */

.at-steps {
    list-style: none;
    counter-reset: at-step;
    margin: 0;
    padding: 0;
}

.at-steps > li {
    counter-increment: at-step;
    position: relative;
    padding: 0 0 14px 38px;
    font-size: .8125rem;
}

.at-steps > li::before {
    content: counter(at-step);
    position: absolute;
    left: 0;
    top: -2px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(var(--at-brand-rgb), .10);
    color: var(--at-brand);
    font-weight: 700;
    font-size: .75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.at-steps > li:last-child {
    padding-bottom: 0;
}

/* Progress ------------------------------------------------------------- */

.at-progress {
    height: 10px;
    border-radius: 999px;
    background: var(--at-surface-2);
    border: 1px solid var(--at-border);
    overflow: hidden;
}

.at-progress > div {
    height: 100%;
    background: var(--at-brand);
    border-radius: 999px;
    transition: width .6s ease;
}

.at-meter {
    height: 6px;
    border-radius: 999px;
    background: var(--at-surface-2);
    overflow: hidden;
    margin-top: 8px;
}

.at-meter > div {
    height: 100%;
    background: var(--at-brand);
}

.at-meter.over > div {
    background: var(--at-danger);
}

/* Link rows (portal links on an instance) ------------------------------- */

.at-linkrow {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--at-border);
}

.at-linkrow:last-child {
    border-bottom: 0;
}

.at-linkrow-main {
    flex: 1 1 auto;
    min-width: 0;
}

.at-linkrow-url {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .75rem;
    color: var(--at-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.at-linkrow-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.at-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .75rem;
    background: var(--at-surface-2);
    border: 1px solid var(--at-border);
    border-radius: 4px;
    padding: 1px 6px;
    overflow-wrap: anywhere;
}

pre.at-pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .75rem;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--at-radius-sm);
    padding: 12px 14px;
    margin: 0;
    max-height: 420px;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ */
/* Ticket conversation                                                 */
/* ------------------------------------------------------------------ */

.at-thread {
    list-style: none;
    margin: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.at-msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    max-width: 92%;
}

.at-msg.staff {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.at-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .75rem;
    text-transform: uppercase;
    background: #eef0f3;
    color: #475467;
}

.at-msg.staff .at-msg-avatar {
    background: rgba(var(--at-brand-rgb), .12);
    color: var(--at-brand);
}

.at-msg-bubble {
    background: var(--at-surface-2);
    border: 1px solid var(--at-border);
    border-radius: 12px;
    padding: 10px 14px;
    min-width: 0;
}

.at-msg.staff .at-msg-bubble {
    background: rgba(var(--at-brand-rgb), .06);
    border-color: rgba(var(--at-brand-rgb), .25);
}

.at-msg.internal .at-msg-bubble {
    background: #fffaf0;
    border-color: #f5d38a;
    border-style: dashed;
}

.at-msg-meta {
    font-size: .6875rem;
    color: var(--at-text-muted);
    margin-bottom: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    align-items: center;
}

.at-msg-meta strong {
    color: var(--at-text);
    font-size: .75rem;
}

.at-msg-body {
    font-size: .8125rem;
    overflow-wrap: anywhere;
    line-height: 1.55;
}

.at-msg-body img {
    max-width: 100%;
    height: auto;
}

.at-msg.first .at-msg-bubble {
    border-left: 3px solid var(--at-accent);
}

/* ------------------------------------------------------------------ */
/* Invoice document                                                    */
/* ------------------------------------------------------------------ */

.at-doc {
    max-width: 880px;
}

.at-doc .at-card-body {
    padding: 28px 32px;
}

.at-doc-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.at-doc-head img {
    height: 26px;
}

.at-doc-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0;
    text-align: right;
}

.at-doc-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
    font-size: .8125rem;
}

.at-doc-parties address {
    margin: 0;
    font-style: normal;
    line-height: 1.6;
}

.at-doc-totals {
    margin-left: auto;
    max-width: 320px;
    font-size: .8125rem;
}

.at-doc-totals > div {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--at-border);
    font-variant-numeric: tabular-nums;
}

.at-doc-totals > div.grand {
    border-bottom: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    padding-top: 10px;
}

.at-doc-terms {
    font-size: .75rem;
    color: var(--at-text-muted);
    line-height: 1.6;
}

@media (max-width: 575.98px) {
    .at-doc .at-card-body { padding: 18px 16px; }
    .at-doc-parties { grid-template-columns: 1fr; }
    .at-doc-title { text-align: left; }
}

/* Legal / long text ------------------------------------------------------ */

.at-prose {
    font-size: .875rem;
    line-height: 1.7;
    color: var(--at-text);
}

.at-prose h1 { font-size: 1.375rem; font-weight: 700; letter-spacing: -.01em; margin-bottom: 1rem; }
.at-prose h2, .at-prose h3 { font-size: 1.0625rem; font-weight: 700; margin-top: 1.5rem; }
.at-prose p { margin-bottom: 1rem; }
.at-prose b, .at-prose strong { color: var(--at-text); }

/* ------------------------------------------------------------------ */
/* Toasts                                                              */
/* ------------------------------------------------------------------ */

.at-toasts {
    position: fixed;
    top: 70px;
    right: 18px;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(380px, calc(100vw - 32px));
}

.at-toast {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: var(--at-surface);
    border: 1px solid var(--at-border);
    border-left-width: 4px;
    border-radius: var(--at-radius);
    box-shadow: 0 12px 28px rgba(16, 24, 40, .14);
    padding: 12px 12px 12px 14px;
    font-size: .8125rem;
    animation: at-toast-in .2s ease;
}

.at-toast.error { border-left-color: var(--at-danger); }
.at-toast.error > i { color: var(--at-danger); }
.at-toast.success { border-left-color: #1baf5a; }
.at-toast.success > i { color: #1baf5a; }
.at-toast.warning { border-left-color: #e0a100; }
.at-toast.warning > i { color: #c58a00; }
.at-toast.info { border-left-color: #2a78d6; }
.at-toast.info > i { color: #2a78d6; }

.at-toast > i {
    margin-top: 2px;
}

.at-toast-title {
    font-weight: 700;
}

.at-toast-body {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.at-toast .btn-close {
    font-size: .625rem;
    margin-top: 3px;
}

@keyframes at-toast-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ */
/* Misc                                                                */
/* ------------------------------------------------------------------ */

.at-modern .table-responsive {
    border-radius: 0 0 var(--at-radius) var(--at-radius);
}

.at-modern .form-check-label {
    font-size: .8125rem;
}

.at-kpi-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--at-brand-rgb), .10);
    color: var(--at-brand);
    font-size: .8125rem;
    float: right;
}

.at-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.at-bar-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.at-bar-list li {
    display: grid;
    grid-template-columns: 140px 1fr 48px;
    gap: 10px;
    align-items: center;
    padding: 5px 0;
    font-size: .8125rem;
}

.at-bar-list .bar {
    height: 8px;
    border-radius: 999px;
    background: var(--at-surface-2);
    overflow: hidden;
}

.at-bar-list .bar > span {
    display: block;
    height: 100%;
    background: var(--at-brand);
    border-radius: 999px;
}

.at-bar-list .n {
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.at-modern iframe.at-frame {
    width: 100%;
    border: 0;
    display: block;
}

/* DataTables 3 right-aligns columns it detects as numbers/dates; keep ids and dates left unless the cell says otherwise */
.at-modern table.dataTable th.dt-type-numeric:not(.text-end):not(.at-right),
.at-modern table.dataTable td.dt-type-numeric:not(.text-end):not(.at-right),
.at-modern table.dataTable th.dt-type-date:not(.text-end):not(.at-right),
.at-modern table.dataTable td.dt-type-date:not(.text-end):not(.at-right) {
    text-align: left;
}

.at-modern table.dataTable th.dt-type-numeric:not(.text-end):not(.at-right) .dt-column-header,
.at-modern table.dataTable th.dt-type-date:not(.text-end):not(.at-right) .dt-column-header {
    flex-direction: row;
}

/* Phones: two KPI tiles per row, wide tables scroll inside their card */
@media (max-width: 575.98px) {
    .at-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .at-kpi {
        padding: 12px;
    }

    .at-kpi-value {
        font-size: 1.25rem;
    }

    .at-kpi-icon {
        display: none;
    }

    .at-modern .dt-container .dt-layout-table,
    .at-modern .dt-container > .row:has(table) {
        overflow-x: auto;
        display: block;
    }
}

.at-modern td.at-num,
.at-modern td.text-nowrap {
    white-space: nowrap;
}

/* TinyMCE sits inside cards */
.at-modern .tox-tinymce {
    border-radius: var(--at-radius-sm) !important;
    border-color: var(--at-border-strong) !important;
}

/* Print: invoices and anything else print just the content */
@media print {
    .at-sidebar,
    .at-topbar,
    .at-backdrop,
    .at-toasts,
    .at-page-actions,
    .at-no-print,
    .modal {
        display: none !important;
    }

    .at-main {
        margin-left: 0 !important;
    }

    .at-content {
        padding: 0 !important;
    }

    body.at-v2 {
        background: #fff !important;
    }

    .at-card {
        box-shadow: none !important;
        border: 0 !important;
    }
}
