/* Shared controls and dialog primitives. Page files own domain-specific variants. */
.btn {
    display: inline-block;
    padding: 10px 15px;
    border-radius: 10px;
    text-align: center;
    margin-top: 10px;
    text-decoration: none;
    transition: all 0.1s linear;
    will-change: opacity;
}

.btn-outline {
    border-radius: 10px;
    border: solid 2px #8f66ce;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.91;
    letter-spacing: normal;
    text-align: left;
    color: #fff;
    background-color: #621fc8;
}

.btn-icon {
    border-radius: 10px;
    border: solid 2px #e496da;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.91;
    letter-spacing: -0.14px;
    text-align: left;
    background-color: #e026c7;
    color: #fff;
}

.btn-icon svg {
    vertical-align: -4px;
    height: 20px;
    width: 20px;
    fill: #fff;
}

.btn-purple {
    border-radius: 10px;
    background-color: #621fc8;
    padding: 14px 26.1px 16px 24.9px;
    font-size: 17px;
    font-weight: 600;
    font-stretch: normal;
    font-style: normal;
    line-height: 1.36;
    letter-spacing: -0.14px;
    text-align: center;
    color: #fff;
    margin: 0;
    border: solid 2px #8f66ce;
}

.btn-red {
    border-radius: 10px;
    border: solid 2px #ef7e7e;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.91;
    letter-spacing: normal;
    text-align: left;
    color: #fff;
    background-color: #ff4141;
}

.btn-outline-purple {
    color: #fff;
    border-radius: 10px;
    border: solid 2px #8f66ce;
    background-color: #621fc8;
}

.btn:hover {
    cursor: pointer;
}

.btn-fill {
    background-color: transparent;
    color: #621fc8;
}

.dark-mode .btn-fill {
    color: #fff;
}

.btn-fill:hover {
    background-color: #621fc8;
    color: #fff;
}

.btn-outline-purple svg {
    padding-right: 3px;
}

.btn-icon:hover,
.btn-icon:focus,
.btn-outline-purple:focus,
.btn-outline-purple:hover,
.btn-outline-red:focus,
.btn-outline-red:hover,
.btn-outline:hover,
.btn-outline:focus {
    opacity: 0.9;
}

/*popup*/

.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 100000;
}

.popup-overlay.show-popup {
    display: block;
}

.popup {
    position: relative;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 50%;
    padding: 40px 36px;
    border-radius: 12px;
    box-shadow: 0 0 40px 0 rgba(0, 0, 0, 0.1);
    border: solid 1px #b9b9b9;
    background-color: #fff;
    z-index: 10000001;
}

.dark-mode .popup {
    background-color: rgba(26, 27, 69, 1);
    box-shadow: 3px 0 3px -3px #f8f6fc;
    border: solid 1px rgba(185, 185, 185, 0.7);
}

.close-btn {
    position: relative;
    top: -10px;
    right: -10px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    border: solid 1px #e026c7;
    background-color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    box-sizing: border-box;
}

.dark-mode .close-btn {
    background: linear-gradient(to right, #2136c7, #af02c9);
    border: 0;
}

.show-popup .close-btn {
    position: absolute;
}

.popup-heading {
    margin: 0;
    font-size: 26px;
    font-weight: normal;
    font-stretch: normal;
    font-style: normal;
    line-height: 1.2;
    letter-spacing: -0.31px;
    text-align: left;
    color: #150f4d;
}

.billing-overview-popup .popup-heading {
    color: #621fc8;
    font-weight: 600;
}

.popup-subheading {
    font-size: 17px;
    font-weight: 300;
    font-stretch: normal;
    font-style: normal;
    line-height: 1.71;
    letter-spacing: normal;
    text-align: left;
    color: #150f4d;
}

.dark-mode .popup-subheading {
    color: #fff;
}

.popup-subheading a {
    color: #e026c7;
    font-weight: 500;
    transition: all 0.1s linear;
    text-decoration: underline;
}

.popup-subheading a.active,
.popup-subheading a:hover,
.popup-subheading a:focus {
    font-weight: bold;
}

.billing-overview-popup .popup-subheading span:not(.plan-name-popup) {
    color: #e026c7;
    font-weight: 600;
}

.billing-overview-popup .popup-subheading span.plan-name-popup {
    color: #150f4d;
    font-weight: 300;
}

.popup .btn-icon svg {
    width: 22px;
    height: auto;
    vertical-align: 1px;
    margin-left: 3px;
}

.popup .btn-icon svg.download-icon {
    width: 14px;
    vertical-align: -2px !important;
    margin-left: 7px;
}

.burst-confirm-popup .total-price-popup {
    font-weight: bold;
}

.burst-popup .popup .btn-icon svg {
    vertical-align: 0;
}

.popup .popup-buttons {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.popup-content-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.popup .payment-container {
    display: flex;
    gap: 20px;
    align-items: center;
}

.popup .payment-container select {
    margin: 0;
    width: calc(100% - 175px);
}

.popup h2 > svg {
    vertical-align: -8px;
    padding-right: 9px;
}

.dark-mode .popup h2 > svg {
    fill: #fff;
}

.popup .input-wrapper {
    display: flex;
    width: 70%;
    flex-direction: column;
}

.popup .input-wrapper input {
    width: 55%;
    margin-top: 10px;
    box-sizing: border-box;
}

/* Named popup variants follow the foundations to preserve their overrides. */
.delete-desktop-consequences {
    margin: 12px 0 18px;
    padding-left: 22px;
    color: #150f4d;
    font-size: 16px;
    line-height: 1.55;
}

.delete-desktop-dialog {
    box-sizing: border-box;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
}

.delete-desktop-dialog .delete-desktop-close {
    top: 12px;
    right: 12px;
}

.dark-mode .delete-desktop-consequences {
    color: #f8f6fc;
}

.delete-desktop-confirm-label {
    display: block;
    margin-bottom: 8px;
}

.delete-desktop-dialog .delete-desktop-input-wrapper {
    width: 100%;
    max-width: 420px;
}

.delete-desktop-dialog .delete-desktop-input-wrapper input {
    width: 100%;
    margin-top: 0;
}

.delete-desktop-validation {
    margin: 8px 0 0;
    color: #842029;
    font-size: 14px;
    line-height: 1.5;
}

.delete-desktop-error {
    margin: 12px 0 0;
    color: #842029;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.5;
}

.dark-mode .delete-desktop-validation,
.dark-mode .delete-desktop-error {
    color: #f8d7da;
}

.delete-desktop-submit:disabled,
.delete-desktop-close:disabled,
.delete-desktop-cancel:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.popup .popup-input-wrapper-btn {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

.popup .popup-subheading-wrapper {
    display: flex;
    flex-direction: column;
}

.popup .popup-subheading-wrapper span {
    font-size: 18px;
    line-height: 30px;
    color: #150f4d;
    font-weight: 700;
}

.trial-convert-modal-overlay .trial-convert-modal {
    width: min(560px, calc(100% - 32px));
    max-width: 560px;
}

.trial-convert-modal {
    padding-top: 32px;
}

.trial-convert-modal-badge {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(90deg, #2136c7 0%, #af02c9 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.trial-convert-modal .popup-heading {
    font-weight: 600;
}

.trial-convert-modal .trial-convert-message {
    margin-bottom: 0;
}

.trial-convert-modal .trial-convert-error {
    display: none;
    margin-top: 8px;
    margin-bottom: 0;
    color: #e55353;
    font-weight: 500;
}

.trial-convert-modal .trial-convert-error.visible {
    display: block;
}

.trial-convert-modal .trial-convert-actions {
    flex-wrap: wrap;
    margin-top: 24px;
    align-items: center;
}

.trial-convert-modal .trial-convert-action-btn {
    cursor: pointer;
    min-height: 52px;
    border-radius: 12px;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    padding: 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        filter 0.15s ease;
}

.trial-convert-modal .trial-convert-action-btn:hover {
    transform: translateY(-1px);
}

.trial-convert-modal .trial-convert-action-btn:focus-visible {
    outline: 2px solid #150f4d;
    outline-offset: 2px;
}

.trial-convert-modal .trial-convert-cancel-btn {
    border: solid 1px #cf56de;
    color: #7b2ab7;
    background: #fff;
}

.trial-convert-modal .trial-convert-primary-btn {
    border: solid 1px #6a35da;
    color: #fff;
    background: linear-gradient(86deg, #2579f4 0%, #8a2de0 60%, #d81dc1 100%);
    box-shadow: 0 10px 24px rgba(101, 58, 201, 0.28);
}

.trial-convert-modal .trial-convert-primary-btn .trial-convert-primary-arrow {
    flex-shrink: 0;
}

.trial-convert-modal .trial-convert-primary-btn[disabled] {
    opacity: 0.65;
    pointer-events: none;
}

@media (max-width: 600px) {
    .trial-convert-modal .trial-convert-actions {
        gap: 12px;
    }

    .trial-convert-modal .trial-convert-cancel-btn,
    .trial-convert-modal .trial-convert-primary-btn {
        width: 100%;
        justify-content: center;
        font-size: 20px;
    }
}

/* Shared page/card layout. */
.app-page {
    height: auto;
    min-height: 100vh;
}

.app-page > .main-container,
.app-page > .main-container > .content {
    min-width: 0;
}

.app-page > .main-container > .content {
    padding-bottom: 30px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 30px;
}

/* Reuse .box for the card surface; the collection owns width and spacing. */
.card-grid > .box {
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 32px 30px;
}

.card-grid > .box.full-width-box {
    width: auto;
    grid-column: 1 / -1;
}

.ui-card-title,
.box-header .ui-card-title {
    margin: 0;
    color: #150f4d;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.24px;
}

.ui-card-description {
    margin: 8px 0 0;
}

.disclosure-toggle {
    appearance: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

/* Keep standalone chevrons beside wrapping labels; status groups may still wrap. */
.disclosure-toggle:has(> [data-disclosure-icon]) {
    flex-wrap: nowrap;
}

.disclosure-toggle [data-disclosure-icon] {
    flex-shrink: 0;
}

.disclosure-toggle[aria-expanded="true"] [data-disclosure-icon] {
    transform: rotate(180deg);
}

.disclosure-panel {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

/* Keep long native options within the control in narrow WebKit layouts. */
.disclosure-panel select {
    white-space: normal;
}

/* Author display rules (including the stack variant) must not override hidden. */
.disclosure-panel[hidden] {
    display: none !important;
}

.disclosure-panel--stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dark-mode .disclosure-panel {
    border-top-color: rgba(255, 255, 255, 0.2);
}

@media (max-width: 1330px) {
    .card-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 600px) {
    .card-grid > .box {
        padding: 24px 20px;
    }
}

/* Text remains in the accessibility tree while being visually clipped. */
.visually-hidden,
.custom-checkbox > input {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Compact disclosure used inside configuration forms. */
.disclosure-toggle--compact {
    justify-content: flex-start;
    width: auto;
    gap: 8px;
    user-select: none;
}

.disclosure-toggle--compact:hover {
    opacity: 0.8;
}

.disclosure-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #150f4d;
}

.dark-mode .disclosure-title {
    color: #fff;
}

.disclosure-panel--compact {
    overflow: hidden;
    margin-top: 15px;
    padding-top: 15px;
}

/* Alerts: shared structure and explicit desktop palette variant. */
.alert {
    position: relative;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 6px;
    text-align: left;
}

.alert-danger {
    color: #842029;
    background-color: #f8d7da;
    border-color: #f5c2c7;
}

.alert-success {
    color: #0f5132;
    background-color: #d1e7dd;
    border-color: #badbcc;
}

.alert-info {
    color: #084298;
    background-color: #cff4fc;
    border-color: #b6effb;
}

.dark-mode .alert-danger {
    color: #fecaca !important;
    background-color: #4c1d24;
    border-color: #b91c1c;
}

.dark-mode .alert-success {
    color: #bbf7d0 !important;
    background-color: #143d2a;
    border-color: #15803d;
}

.dark-mode .alert-info {
    color: #bae6fd !important;
    background-color: #164e63;
    border-color: #0284c7;
}

.dark-mode .alert-danger span,
.dark-mode .alert-success span,
.dark-mode .alert-info span {
    color: inherit !important;
}

.alert-dismissible > .close-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: auto;
    height: auto;
    padding: 0.75rem 1.25rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.alert-dismissible > .close-btn:hover,
.alert-dismissible > .close-btn:focus-visible {
    opacity: 0.7;
}

.alert-dismissible {
    padding-right: 3.5rem;
}

.alert--desktop.alert {
    position: static;
    border-radius: 0.375rem;
}

.alert--desktop.alert-warning {
    color: #664d03;
    background-color: #fff3cd;
    border-color: #ffecb5;
}

.dark-mode .alert--desktop.alert-danger {
    color: #ffb4ab !important;
    background-color: #4f1d22;
    border-color: #842029;
}

.dark-mode .alert--desktop.alert-success {
    color: #a3cfbb !important;
    background-color: #123c2a;
    border-color: #2f6f4e;
}

.dark-mode .alert--desktop.alert-warning {
    color: #ffe69c;
    background-color: #493a0e;
    border-color: #806513;
}

/* Inline forms keep their sizing and control treatment in their page variants. */
.form-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.form-inline--billing {
    gap: 8px;
    margin-top: 4px;
}

/* Shared badge shapes and billing-role colors. */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-muted {
    background-color: #edf2f7;
    color: #2d3748;
}

.dark-mode .badge-muted {
    background-color: #4a5568;
    color: #e2e8f0 !important;
}

.badge-compact,
:where(.user-lookup-card) .role-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-billing-role,
.badge-billing-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}

.badge-billing-role {
    font-size: 0.75em;
    margin-left: 4px;
}

.badge-billing-status {
    font-size: 0.8em;
}

.role-OWNER {
    background: #6f42c1;
    color: #fff;
}
.role-BILLING_ADMIN {
    background: #0d6efd;
    color: #fff;
}
.role-SPENDER {
    background: #198754;
    color: #fff;
}
.role-VIEWER {
    background: #6c757d;
    color: #fff;
}

/* Desktop routes retain their existing responsive popup treatment. */
@media (max-width: 1330px) {
    :where(.desktop-layout) .popup {
        max-width: 70%;
    }
}
@media (max-width: 991px) {
    :where(.desktop-layout) .popup {
        max-width: 80%;
    }
}

@media (max-width: 600px) {
    :where(.desktop-layout) .popup {
        width: calc(100% - 24px);
        max-width: calc(100% - 24px);
        padding: 28px 20px;
    }

    :where(.desktop-layout) .popup .popup-buttons {
        align-items: stretch;
        flex-direction: column;
        flex-wrap: wrap;
    }

    :where(.desktop-layout) .popup .popup-buttons .btn,
    :where(.desktop-layout) .popup .popup-buttons .btn-icon,
    :where(.desktop-layout) .popup .popup-buttons .btn-outline {
        box-sizing: border-box;
        width: 100%;
    }
}

/* Form and details dialogs share named surfaces; .modal remains a JS backdrop hook. */
.form-dialog .modal-header,
.details-dialog .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Modal styles */
.form-dialog {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.form-dialog .dialog-surface {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 500px;
}

.dark-mode .form-dialog .dialog-surface {
    background: #1a1b45;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #f7f7ff;
}

.dark-mode .form-dialog .modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.14);
}

.dark-mode .form-dialog .modal-header h3 {
    color: #f7f7ff;
}

.dark-mode .form-dialog .dialog-surface input,
.dark-mode .form-dialog .dialog-surface select {
    background: #101140;
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.form-dialog .modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.form-dialog .modal-header h3 {
    margin: 0;
    color: #111827;
}

.form-dialog .close {
    background: transparent;
    border: 0;
    color: #6b7280;
    float: right;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
}

.form-dialog .close:hover,
.form-dialog .close:focus {
    color: #374151;
}

.form-dialog .modal-body {
    padding: 1.5rem;
}

body.modal-open {
    overflow: hidden;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 10000;
}

.details-dialog .dialog-surface {
    background: #ffffff;
    border-radius: 12px;
    max-width: 720px;
    width: 100%;
    box-shadow: 0 20px 45px rgba(30, 41, 59, 0.25);
    display: flex;
    flex-direction: column;
}

.dark-mode .details-dialog .dialog-surface {
    background: #1f2937;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6);
}

.details-dialog .modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.dark-mode .details-dialog .modal-header {
    border-bottom-color: #374151;
}

.details-dialog .modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: #150f4d;
}

.dark-mode .details-dialog .modal-header h3 {
    color: #e2e8f0;
}

.details-dialog .modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #4a5568;
    cursor: pointer;
}

.details-dialog .modal-close:hover,
.details-dialog .modal-close:focus {
    color: #1f2937;
}

.dark-mode .details-dialog .modal-close {
    color: #cbd5f5;
}

.dark-mode .details-dialog .modal-close:hover,
.dark-mode .details-dialog .modal-close:focus {
    color: #f1f5f9;
}

.details-dialog .modal-body {
    padding: 24px;
    max-height: 70vh;
    overflow: auto;
}

.details-dialog .modal-pre {
    margin: 0;
    font-family: "Courier New", monospace;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: #1f2937;
}

.dark-mode .details-dialog .modal-pre {
    color: #f9fafb;
}

/* Used for checkbox/radio inputs inside .form-inline layouts where the label wraps the control. */
.form-inline-label {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Form-dialog fields preserve their existing control and action layout. */
.form-dialog .form-group {
    margin-bottom: 1.5rem;
}

.form-dialog .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-dialog .form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    box-sizing: border-box;
}

.form-dialog .form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-dialog .form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #6b7280;
    font-size: 0.75rem;
}

.form-dialog .form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}
