/*
 * MyITSY presentation contract for the itsy_estimates client journey.
 *
 * The addon owns all wording, values, validation and acceptance behaviour.
 * The theme only styles markup below a stable data-itsy-estimates-ui root.
 */

:where([data-itsy-estimates-ui], .itsy-estimate-client) {
    --itsy-estimate-accent: var(--itsy-blue, #2171b9);
    --itsy-estimate-accent-strong: var(--itsy-blue-dark, #16598f);
    --itsy-estimate-danger: var(--itsy-red, #ba2822);
    --itsy-estimate-ink: var(--itsy-ink, #142a35);
    --itsy-estimate-muted: var(--itsy-muted, #526773);
    --itsy-estimate-line: var(--itsy-line, rgba(3, 43, 53, .16));
    --itsy-estimate-surface: var(--itsy-surface-solid, #fff);
    --itsy-estimate-soft: var(--itsy-soft-blue, #eaf4fd);
    --itsy-estimate-focus: var(--itsy-focus, #ba2822);
    --itsy-estimate-radius: var(--itsy-radius, 24px);
    --itsy-estimate-radius-small: var(--itsy-radius-small, 16px);
    --itsy-estimate-shadow: var(--itsy-shadow-small, 0 8px 26px rgba(19, 57, 75, .08));
    color: var(--itsy-estimate-ink);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where(a, button, input, select, textarea):focus-visible {
    outline: 3px solid var(--itsy-estimate-focus) !important;
    outline-offset: 3px !important;
    box-shadow: none !important;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-header], .itsy-estimate-header),
:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-summary], .itsy-estimate-summary),
:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-acceptance], .itsy-estimate-acceptance),
:where([data-itsy-estimates-ui], .itsy-estimate-client) :where(.card, .panel) {
    overflow: hidden;
    color: var(--itsy-estimate-ink);
    border: 1px solid var(--itsy-estimate-line);
    border-radius: var(--itsy-estimate-radius);
    background: var(--itsy-estimate-surface);
    box-shadow: var(--itsy-estimate-shadow);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-header], .itsy-estimate-header) {
    padding: clamp(1.4rem, 3vw, 2.5rem);
    background:
        radial-gradient(circle at 90% 12%, rgba(33, 113, 185, .13), transparent 17rem),
        var(--itsy-estimate-surface);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-header], .itsy-estimate-header) h1 {
    max-width: 22ch;
    margin: 0;
    color: var(--itsy-estimate-ink);
    font-size: clamp(1.9rem, 4vw, 3.35rem);
    line-height: 1.08;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-header], .itsy-estimate-header) p {
    max-width: 68ch;
    margin: .75rem 0 0;
    color: var(--itsy-estimate-muted);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-status], .itsy-estimate-status) {
    width: fit-content;
    min-height: 32px;
    padding: .35rem .75rem;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    color: var(--itsy-estimate-accent-strong);
    border: 1px solid currentColor;
    border-radius: 999px;
    background: var(--itsy-estimate-soft);
    font-size: .82rem;
    font-weight: 800;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-summary], .itsy-estimate-summary) {
    margin-block: 1rem;
    padding: clamp(1rem, 2.4vw, 1.65rem);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
    gap: .85rem;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-summary], .itsy-estimate-summary) > * {
    min-width: 0;
    padding: .75rem;
    border-left: 3px solid var(--itsy-estimate-accent);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-summary], .itsy-estimate-summary) :where(dt, small) {
    display: block;
    color: var(--itsy-estimate-muted);
    font-size: .78rem;
    font-weight: 700;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-summary], .itsy-estimate-summary) :where(dd, strong) {
    overflow-wrap: anywhere;
    color: var(--itsy-estimate-ink);
    font-size: 1rem;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-options], .itsy-estimate-options) {
    margin-block: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    gap: 1rem;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-option], .itsy-estimate-option) {
    position: relative;
    min-width: 0;
    padding: clamp(1.1rem, 2.5vw, 1.6rem);
    color: var(--itsy-estimate-ink);
    border: 1px solid var(--itsy-estimate-line);
    border-radius: var(--itsy-estimate-radius);
    background: var(--itsy-estimate-surface);
    box-shadow: var(--itsy-estimate-shadow);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-option], .itsy-estimate-option):where([aria-checked="true"], [data-selected="true"], .is-selected) {
    border: 3px solid var(--itsy-estimate-accent);
    background: linear-gradient(180deg, var(--itsy-estimate-soft), var(--itsy-estimate-surface) 42%);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-option], .itsy-estimate-option):where([aria-checked="true"], [data-selected="true"], .is-selected)::before {
    display: block;
    width: .75rem;
    height: .75rem;
    margin-bottom: .75rem;
    content: "";
    border: 3px solid var(--itsy-estimate-surface);
    border-radius: 50%;
    background: var(--itsy-estimate-accent);
    box-shadow: 0 0 0 2px var(--itsy-estimate-accent);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-lines], [data-itsy-estimate-table], .itsy-estimate-lines, .table-responsive) {
    max-width: 100%;
    overflow-x: auto;
    border-radius: var(--itsy-estimate-radius-small);
    -webkit-overflow-scrolling: touch;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) table {
    width: 100%;
    margin: 0;
    color: var(--itsy-estimate-ink);
    background: var(--itsy-estimate-surface);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) table :where(th, td) {
    min-width: 8rem;
    padding: .85rem 1rem;
    border-color: var(--itsy-estimate-line);
    vertical-align: top;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) table th {
    color: var(--itsy-estimate-ink);
    background: var(--itsy-estimate-soft);
    font-size: .78rem;
    letter-spacing: .035em;
    text-transform: uppercase;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where(label, legend) {
    color: var(--itsy-estimate-ink);
    font-weight: 750;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea, .form-control) {
    min-height: 46px;
    color: var(--itsy-estimate-ink);
    border: 1px solid var(--itsy-estimate-line);
    border-radius: .8rem;
    background: var(--itsy-estimate-surface);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where(input[type="checkbox"], input[type="radio"]) {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--itsy-estimate-accent);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where(.btn, button, [role="button"]) {
    min-height: 44px;
    border-radius: .8rem;
    font-weight: 750;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where(.btn-primary, [data-itsy-estimate-primary-action]) {
    color: #fff;
    border-color: var(--itsy-estimate-accent);
    background: var(--itsy-estimate-accent);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where(.btn-primary, [data-itsy-estimate-primary-action]):hover {
    color: #fff;
    border-color: var(--itsy-estimate-accent-strong);
    background: var(--itsy-estimate-accent-strong);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where(button, input, select, textarea, .btn):disabled,
:where([data-itsy-estimates-ui], .itsy-estimate-client) [aria-disabled="true"] {
    cursor: not-allowed;
    opacity: .62;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-acceptance], .itsy-estimate-acceptance) {
    margin-top: 1.25rem;
    padding: clamp(1.2rem, 3vw, 2rem);
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-legal], .itsy-estimate-legal) {
    max-width: 75ch;
    color: var(--itsy-estimate-muted);
    line-height: 1.65;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-actions], .itsy-estimate-actions) {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .75rem;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([role="alert"], .alert-danger) {
    color: #7c1712;
    border-color: var(--itsy-estimate-danger);
    background: #fff0ef;
}

:where([data-itsy-estimates-ui], .itsy-estimate-client) :where([role="status"], .alert-info, .alert-success) {
    color: #164f6f;
    border-color: var(--itsy-estimate-accent);
    background: var(--itsy-estimate-soft);
}

/* Historical native WHMCS quote rendering: deliberately view/download only. */
body.its-legacy-estimate-page {
    min-height: 100vh;
    margin: 0;
    color: #142a35;
    background: linear-gradient(145deg, #edf6fb, #f8fbfd 52%, #eaf4fd);
}

.its-legacy-skip {
    position: fixed;
    z-index: 10;
    top: .75rem;
    left: .75rem;
    padding: .7rem 1rem;
    color: #fff;
    border-radius: .6rem;
    background: #032b35;
    transform: translateY(-180%);
}

.its-legacy-skip:focus { color: #fff; transform: translateY(0); }

.its-legacy-estimate-page .invoice-container {
    max-width: 1080px;
    margin: clamp(1rem, 4vw, 3rem) auto 1rem;
    border: 1px solid rgba(3, 43, 53, .16);
    border-radius: 1.5rem;
    background: #fff;
    box-shadow: 0 18px 55px rgba(19, 57, 75, .1);
}

.its-legacy-estimate-notice {
    margin: 0 0 1.5rem;
    padding: 1rem 1.15rem;
    display: flex;
    gap: .8rem;
    align-items: flex-start;
    color: #163f52;
    border: 2px solid #2171b9;
    border-radius: 1rem;
    background: #eaf4fd;
}

.its-legacy-estimate-notice i { margin-top: .2rem; color: #2171b9; }
.its-legacy-estimate-notice strong { display: block; color: #142a35; }
.its-legacy-estimate-notice p { margin: .2rem 0 0; color: #365564; }
.its-legacy-estimate-page :focus-visible { outline: 3px solid #ba2822 !important; outline-offset: 3px !important; }

html[data-itsy-reduce-transparency="true"] :where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-header], [data-itsy-estimate-summary], [data-itsy-estimate-option], [data-itsy-estimate-acceptance], .card, .panel),
html[data-itsy-reduce-transparency="true"] :where([data-itsy-estimates-ui], .itsy-estimate-client) :where(.itsy-estimate-header, .itsy-estimate-summary, .itsy-estimate-option, .itsy-estimate-acceptance) {
    background: var(--itsy-estimate-surface) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

html[data-itsy-high-contrast="true"] :where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-header], [data-itsy-estimate-summary], [data-itsy-estimate-option], [data-itsy-estimate-acceptance], .card, .panel),
html[data-itsy-high-contrast="true"] :where([data-itsy-estimates-ui], .itsy-estimate-client) :where(.itsy-estimate-header, .itsy-estimate-summary, .itsy-estimate-option, .itsy-estimate-acceptance) {
    border: 2px solid #000;
    box-shadow: none;
}

html[data-itsy-high-contrast="true"] :where([data-itsy-estimates-ui], .itsy-estimate-client) :where(.btn-primary, [data-itsy-estimate-primary-action]) {
    color: #fff;
    border-color: #000;
    background: #005a9c;
}

@media (prefers-reduced-transparency: reduce) {
    :where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-header], [data-itsy-estimate-summary], [data-itsy-estimate-option], [data-itsy-estimate-acceptance], .card, .panel),
    :where([data-itsy-estimates-ui], .itsy-estimate-client) :where(.itsy-estimate-header, .itsy-estimate-summary, .itsy-estimate-option, .itsy-estimate-acceptance) {
        background: var(--itsy-estimate-surface) !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    :where([data-itsy-estimates-ui], .itsy-estimate-client) *,
    :where([data-itsy-estimates-ui], .itsy-estimate-client) *::before,
    :where([data-itsy-estimates-ui], .itsy-estimate-client) *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

@media (max-width: 767.98px) {
    :where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-options], .itsy-estimate-options) { grid-template-columns: 1fr; }
    :where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-actions], .itsy-estimate-actions) { flex-direction: column; }
    :where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-actions], .itsy-estimate-actions) > * { width: 100%; }
    .its-legacy-estimate-page .invoice-container { margin: .75rem; border-radius: 1rem; }
}

@media print {
    .its-legacy-estimate-notice,
    :where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-actions], .itsy-estimate-actions) { display: none !important; }
    :where([data-itsy-estimates-ui], .itsy-estimate-client) :where([data-itsy-estimate-header], [data-itsy-estimate-summary], [data-itsy-estimate-option], [data-itsy-estimate-acceptance], .card, .panel) {
        border: 1px solid #777;
        box-shadow: none;
    }
}
