/*
 * Internal UI contracts
 *
 * This file is loaded after page-level styles. It is the canonical owner of
 * internal application buttons and the documented normal/dense data scales.
 * Public marketing controls and authentication controls remain independent.
 */

:root {
    --button-height: var(--control-height, 44px);
    --button-height-small: var(--control-height-sm, 38px);
    --button-font-size: var(--type-control, 15px);
    --button-font-size-small: var(--type-compact, 14px);
    --data-font-size: 15px;
    --data-font-size-dense: var(--type-support, 14px);
    --data-heading-font-size: var(--type-micro, 13px);
}

/* Canonical internal button API */

:root .button {
    position: relative;
    display: inline-flex;
    min-width: 0;
    min-height: var(--button-height);
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    appearance: none;
    background: var(--color-surface);
    color: var(--color-text-soft);
    font-family: inherit;
    font-size: var(--button-font-size);
    font-weight: 680;
    line-height: 1.3;
    text-align: center;
    text-decoration: none;
    overflow-wrap: break-word;
    white-space: normal;
    cursor: pointer;
    transition:
        background var(--transition-fast),
        border-color var(--transition-fast),
        color var(--transition-fast),
        box-shadow var(--transition-fast),
        transform var(--transition-fast);
}

:root .button svg {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
}

:root .button-primary {
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: var(--color-text-inverse);
    box-shadow: 0 1px 2px rgba(49, 46, 129, 0.24);
}

:root .button-primary:hover:not(:disabled):not([aria-disabled="true"]) {
    border-color: var(--color-accent-hover);
    background: var(--color-accent-hover);
    color: var(--color-text-inverse);
    transform: translateY(-1px);
}

:root .button-secondary {
    border-color: var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-soft);
}

:root .button-secondary:hover:not(:disabled):not([aria-disabled="true"]) {
    border-color: var(--color-border-strong);
    background: var(--color-surface-subtle);
    color: var(--color-text);
}

:root .button-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--color-text-soft);
}

:root .button-ghost:hover:not(:disabled):not([aria-disabled="true"]) {
    border-color: transparent;
    background: var(--color-surface-muted);
    color: var(--color-text);
}

:root .button-danger,
:root .team-danger-button {
    border-color: var(--color-danger);
    background: var(--color-danger);
    color: var(--color-text-inverse);
}

:root .button-danger:hover:not(:disabled):not([aria-disabled="true"]),
:root .team-danger-button:hover:not(:disabled):not([aria-disabled="true"]) {
    border-color: #8f1d14;
    background: #8f1d14;
    color: var(--color-text-inverse);
}

:root .button.button-small {
    min-height: var(--button-height-small);
    padding: 8px 12px;
    font-size: var(--button-font-size-small);
    line-height: 1.3;
}

:root .button.button-icon {
    width: var(--button-height);
    min-width: var(--button-height);
    height: var(--button-height);
    padding: 0;
    white-space: nowrap;
}

:root .button.button-small.button-icon {
    width: var(--button-height-small);
    min-width: var(--button-height-small);
    height: var(--button-height-small);
}

:root .button[aria-disabled="true"],
:root .button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    pointer-events: none;
    transform: none;
}

:root .button[aria-busy="true"],
:root .button-loading {
    cursor: wait;
}

:root .button[aria-busy="true"]::before,
:root .button-loading::before {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    content: "";
    animation: component-spin 700ms linear infinite;
}

/* Normal data tables remain spacious; wide financial tables opt into dense. */

:root table.data-table {
    font-size: var(--data-font-size);
    line-height: 1.5;
}

:root table.data-table tbody th,
:root table.data-table tbody td {
    font-size: var(--data-font-size);
    line-height: 1.5;
}

:root table.data-table thead th {
    font-size: var(--data-heading-font-size);
    line-height: 1.35;
}

:root table[data-dense] {
    font-size: var(--data-font-size-dense);
    line-height: 1.45;
}

:root table[data-dense] tbody th,
:root table[data-dense] tbody td {
    font-size: var(--data-font-size-dense);
    line-height: 1.45;
}

:root table[data-dense] thead th,
:root table[data-dense] thead button {
    font-size: var(--data-heading-font-size);
    line-height: 1.35;
}

:root .data-table-primary strong {
    font-size: var(--data-font-size);
    line-height: 1.4;
}

:root .data-table-primary small {
    font-size: var(--type-support, 14px);
    line-height: 1.45;
}

/* Dynamic-text geometry */

:root .event-card-title,
:root .analytics-detail-table tbody th > a,
:root .analytics-event-identity strong,
:root .margin-pipeline-event strong,
:root .attention-item-copy strong,
:root .scenario-line-primary strong,
:root .event-state-section-list a > strong,
:root .report-line-identity strong,
:root .team-person strong,
:root .scenario-lines-table tbody th > span,
:root .template-lines-table tbody th > span {
    display: -webkit-box;
    max-width: 100%;
    overflow: hidden;
    overflow-wrap: break-word;
    text-overflow: clip;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

:root .analytics-detail-table tbody th > small,
:root .analytics-detail-table tbody td > small,
:root .analytics-event-identity small,
:root .scenario-line-primary small,
:root .scenario-lines-table tbody th > small,
:root .template-lines-table tbody th > small,
:root .report-line-identity small,
:root .team-person > span,
:root .event-context-line,
:root .financial-form-context dd,
:root .invitation-details dd,
:root .team-context-facts dd,
:root .team-change-summary dd {
    max-width: 100%;
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
}

:root .data-table-numeric,
:root .status-badge,
:root .status-pill,
:root .analytics-table-status,
:root .analytics-attention,
:root .analytics-coverage-label,
:root .reports-attention,
:root .reports-row-action {
    white-space: nowrap;
}

/* Readable Coverage and Attention labels may span lines in the comparison table. */
:root .analytics-detail-table .analytics-coverage-label,
:root .analytics-detail-table .analytics-attention {
    display: inline-block;
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
    vertical-align: middle;
    border-radius: var(--radius-sm, 8px);
}

@media (max-width: 640px) {
    :root .button-full-width-mobile {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    :root .button[aria-busy="true"]::before,
    :root .button-loading::before {
        animation-duration: 1400ms;
    }
}
