/* Central UI primitives used by components/ui and ui catalog page */

.ui-catalog-layout {
    padding-bottom: 1rem;
}

.ui-section-card {
    border-radius: 14px;
}

.ui-section-card .pricing-section-body {
    display: grid;
    gap: 0.75rem;
}

.ui-section-description {
    margin-bottom: 0.5rem;
}

/* Emailing integration inventory */
.emailing-page .emailing-table-wrap {
    border: 1px solid rgba(117, 105, 95, 0.26);
    border-radius: 6px;
    overflow-x: auto;
}

.emailing-page .emailing-table {
    background: rgba(255, 255, 255, 0.18);
    border-collapse: collapse;
    table-layout: auto;
    width: 100%;
}

.emailing-page .emailing-table-heading {
    background: rgba(117, 105, 95, 0.08);
    border-bottom: 1px solid rgba(117, 105, 95, 0.28);
    color: #5f554d;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    padding: 0.66rem 0.72rem;
    text-transform: uppercase;
    vertical-align: bottom;
}

.emailing-page .emailing-table-cell {
    border-bottom: 1px solid rgba(117, 105, 95, 0.16);
    color: #332d28;
    font-size: 0.9rem;
    padding: 0.66rem 0.72rem;
    vertical-align: top;
}

.emailing-page .emailing-strong-text {
    color: #2b2724;
    font-weight: 700;
}

.emailing-page .emailing-code-text {
    background: rgba(117, 105, 95, 0.08);
    border: 1px solid rgba(117, 105, 95, 0.18);
    border-radius: 4px;
    color: #4b4038;
    font-size: 0.84rem;
    padding: 0.05rem 0.28rem;
}

.emailing-page .emailing-plain-status {
    color: #5f554d;
    font-size: 0.84rem;
    font-weight: 700;
    white-space: nowrap;
}

.emailing-page .emailing-inventory-chip {
    border-radius: 6px;
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 0.14rem 0.46rem;
    white-space: nowrap;
}

.emailing-page .emailing-inventory-chip-success {
    background: rgba(72, 145, 86, 0.16);
    border: 1px solid rgba(72, 145, 86, 0.32);
    color: #2f6f3b;
}

.emailing-page .emailing-inventory-chip-warning {
    background: #f4c95d;
    border: 1px solid #d8a52f;
    color: #4f3605;
}

.emailing-page .emailing-inventory-chip-info {
    background: rgba(74, 137, 199, 0.14);
    border: 1px solid rgba(74, 137, 199, 0.30);
    color: #315f92;
}

.emailing-page .emailing-inventory-chip-secondary {
    background: rgba(95, 107, 117, 0.12);
    border: 1px solid rgba(95, 107, 117, 0.24);
    color: #4d5962;
}

.dark-theme .emailing-page .emailing-table-wrap {
    border-color: rgba(255, 255, 255, 0.18);
}

.dark-theme .emailing-page .emailing-table {
    background: rgba(255, 255, 255, 0.025);
}

.dark-theme .emailing-page .emailing-table-heading {
    background: rgba(255, 255, 255, 0.055);
    border-bottom-color: rgba(255, 255, 255, 0.22);
    color: #cfd6de;
}

.dark-theme .emailing-page .emailing-table-cell {
    border-bottom-color: rgba(255, 255, 255, 0.12);
    color: #eef2f5;
}

.dark-theme .emailing-page .emailing-strong-text {
    color: #f2f5f8;
}

.dark-theme .emailing-page .emailing-code-text {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.16);
    color: #f4f6f8;
}

.dark-theme .emailing-page .emailing-plain-status {
    color: #d8dee5;
}

.dark-theme .emailing-page .emailing-inventory-chip-success {
    background: rgba(74, 163, 96, 0.30);
    border-color: rgba(123, 204, 139, 0.70);
    color: #d6f1dc;
}

.dark-theme .emailing-page .emailing-inventory-chip-warning {
    background: rgba(219, 166, 53, 0.30);
    border-color: rgba(232, 189, 91, 0.72);
    color: #ffe2a1;
}

.dark-theme .emailing-page .emailing-inventory-chip-info {
    background: rgba(74, 137, 199, 0.34);
    border-color: rgba(121, 174, 228, 0.70);
    color: #d8eaff;
}

.dark-theme .emailing-page .emailing-inventory-chip-secondary {
    background: rgba(150, 160, 170, 0.26);
    border-color: rgba(185, 194, 203, 0.58);
    color: #edf1f5;
}

/* Reusable app scrollbar for contained scroll regions */
.ui-standard-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: var(--color-beige-dark, #BBA998) transparent;
}

.ui-standard-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.ui-standard-scrollbar::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.ui-standard-scrollbar::-webkit-scrollbar-thumb {
    background-color: var(--color-beige-dark, #BBA998);
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.ui-standard-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: var(--color-brown, #8B7969);
}

.dark-theme .ui-standard-scrollbar {
    scrollbar-color: #555 transparent;
}

.dark-theme .ui-standard-scrollbar::-webkit-scrollbar-thumb {
    background-color: #555;
}

.dark-theme .ui-standard-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: #777;
}

/* Reusable callback-free (i) info disclosure */
.ui-info {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
}

.ui-info > summary,
.ui-info-btn {
    list-style: none;
    width: 1.05rem;
    height: 1.05rem;
    line-height: 1rem;
    text-align: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.7rem;
    font-style: italic;
    font-weight: 700;
    font-family: Georgia, serif;
    border: 1px solid rgba(146, 183, 194, 0.6);
    color: var(--color-slate-dark, #6E868D);
    background: transparent;
    opacity: 0.7;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.ui-info > summary::-webkit-details-marker {
    display: none;
}

.ui-info > summary::marker {
    content: "";
}

.ui-info-has-content > summary,
.ui-info-has-content .ui-info-btn {
    opacity: 1;
    background: rgba(146, 183, 194, 0.2);
}

.ui-info > summary:hover,
.ui-info[open] > summary,
.ui-info-btn:hover,
.ui-info[open] .ui-info-btn {
    opacity: 1;
    background: rgba(146, 183, 194, 0.28);
}

.ui-info-pop {
    flex-basis: 100%;
    margin-top: 0.3rem;
    min-width: 12rem;
    max-width: 18rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    background: rgba(139, 121, 105, 0.1);
    border: 1px solid rgba(187, 169, 152, 0.5);
    box-shadow: 0 8px 18px rgba(117, 105, 95, 0.16);
    color: var(--text-color, #212529);
}

.ui-info-copy,
.ui-info-empty {
    font-size: 0.78rem;
    color: var(--text-color-muted, #6c757d);
}

.ui-info-link {
    font-size: 0.8rem;
}

.ui-info-cta {
    font-weight: 700;
}

.ui-info-link-trigger {
    justify-content: center;
    text-decoration: none;
}

.ui-field {
    display: grid;
    gap: 0.35rem;
}

.ui-field .form-label {
    margin-bottom: 0;
    font-size: 0.9rem;
}

.field-badge {
    font-family: var(--font-family-base, 'Inter', sans-serif);
    font-size: 0.6rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-brown-light, #BBA998);
    background-color: rgba(187, 169, 152, 0.15);
    padding: 0.08rem 0.4rem;
    border-radius: 10px;
    white-space: nowrap;
}

.ui-field .lang-input,
.ui-field .form-control {
    min-height: 40px;
}

.ui-input-group .input-group-text {
    min-width: 42px;
    justify-content: center;
}

.ui-stepper-group {
    flex-wrap: nowrap;
    overflow: hidden;
}

/* Hide native spinners when using custom stepper arrows */
.ui-stepper-group input[type="number"] {
    -moz-appearance: textfield;
    background-image: none !important;
    padding-right: 0.35rem !important;
}

.ui-stepper-group input[type="number"]::-webkit-outer-spin-button,
.ui-stepper-group input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
    display: none;
}

/* Flatten the right edge of the input so it joins the stepper cleanly */
.ui-stepper-group input.form-control[type="number"] {
    border-right: 0 !important;
    border-radius: 8px 0 0 8px !important;
}

/* When percent badge is present after the stepper, close the right edge there */
.ui-percent-stepper-group .input-group-text {
    border-left: 0;
    border-radius: 0 8px 8px 0;
}

.ui-upload-dropzone {
    min-height: 88px;
}

.dark-theme .ui-section-card .pricing-section-body {
    color: #e0e0e0;
}

/* === REUSABLE TOGGLE SWITCH (app_switch) === */
.ui-switch-field {
    gap: 0.25rem;
}

.ui-switch .form-check-input {
    width: 2.4rem;
    height: 1.25rem;
    margin-top: 0.1rem;
    cursor: pointer;
    background-color: #e9dccb;
    border-color: var(--color-beige-dark, #BBA998);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ui-switch .form-check-input:focus {
    border-color: var(--color-slate, #92B7C2);
    box-shadow: 0 0 0 2px rgba(146, 183, 194, 0.25);
}

.ui-switch .form-check-input:checked {
    background-color: var(--color-slate, #92B7C2);
    border-color: var(--color-slate-dark, #6E868D);
}

.ui-switch .form-check-label {
    cursor: pointer;
    margin-left: 0.5rem;
    color: var(--text-color, #212529);
}

.ui-switch .form-check-input:disabled,
.ui-switch .form-check-input[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.ui-switch-description {
    font-size: 0.8rem;
}

/* Dark mode */
.dark-theme .ui-switch .form-check-input {
    background-color: #3a3a3a;
    border-color: #555;
}

.dark-theme .ui-switch .form-check-input:checked {
    background-color: var(--color-slate, #92B7C2);
    border-color: var(--color-slate-dark, #6E868D);
}

.dark-theme .ui-switch .form-check-label {
    color: #e0e0e0;
}

/* === REUSABLE CHECKBOX (app_checkbox) === */
.ui-checkbox-field {
    gap: 0.25rem;
}

/* `.ui-checkbox .form-check-input` styles app_checkbox; `.ui-checkbox-input`
   styles a checkbox input directly (e.g. dcc.Checklist via inputClassName, where
   there is no .ui-checkbox wrapper) so checklists share the same look. */
.ui-checkbox .form-check-input,
input.ui-checkbox-input {
    width: 1.15rem;
    height: 1.15rem;
    margin-top: 0.15rem;
    cursor: pointer;
    background-color: #fff;
    border-color: var(--color-beige-dark, #BBA998);
    /* accent-color recolors a *native* checkbox (e.g. a dcc.Checklist input
       without Bootstrap's appearance:none); background-color above handles the
       Bootstrap-styled case. */
    accent-color: var(--color-slate, #92B7C2);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ui-checkbox .form-check-input:focus,
input.ui-checkbox-input:focus {
    border-color: var(--color-slate, #92B7C2);
    box-shadow: 0 0 0 2px rgba(146, 183, 194, 0.25);
}

.ui-checkbox .form-check-input:checked,
input.ui-checkbox-input:checked {
    background-color: var(--color-slate, #92B7C2);
    border-color: var(--color-slate-dark, #6E868D);
}

.ui-checkbox .form-check-label {
    cursor: pointer;
    margin-left: 0.4rem;
    color: var(--text-color, #212529);
}

.ui-checkbox .form-check-input:disabled,
.ui-checkbox .form-check-input[disabled],
input.ui-checkbox-input:disabled,
input.ui-checkbox-input[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.ui-checkbox-description {
    font-size: 0.8rem;
}

/* Dark mode */
.dark-theme .ui-checkbox .form-check-input,
.dark-theme .ui-checkbox-input {
    background-color: #2e2e2e;
    border-color: #555;
}

.dark-theme .ui-checkbox .form-check-input:checked,
.dark-theme .ui-checkbox-input:checked {
    background-color: var(--color-slate, #92B7C2);
    border-color: var(--color-slate-dark, #6E868D);
}

.dark-theme .ui-checkbox .form-check-label {
    color: #e0e0e0;
}

.dark-theme .ui-info > summary,
.dark-theme .ui-info-btn {
    border-color: rgba(146, 183, 194, 0.5);
    color: #cfe6ee;
}

.dark-theme .ui-info-pop {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

/* === REUSABLE EXPANDABLE CARD (app_expandable_card) === */
.ui-catalog-expandable-stack {
    display: grid;
    gap: 0.65rem;
}

.ui-expandable-card {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background-color: #fffdfa;
    border: 1px solid rgba(187, 169, 152, 0.55);
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(117, 105, 95, 0.08);
    transition: box-shadow 0.25s ease, background-color 0.2s ease, transform 0.2s ease;
}

.ui-expandable-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 9px;
    border-top-left-radius: 14px;
    border-bottom-left-radius: 14px;
    background-color: var(--color-brown, #8B7969);
    transition: background-color 0.2s ease;
}

.ui-expandable-card:hover,
.ui-expandable-card:focus-within,
.ui-expandable-card:focus {
    background-color: #ffffff;
    box-shadow: 0 8px 22px rgba(117, 105, 95, 0.18);
    transform: translateY(-1px);
    outline: none;
}

.ui-expandable-card-accent-info::before { background-color: var(--color-slate, #92B7C2); }
.ui-expandable-card-accent-success::before { background-color: var(--color-olive, #4E6B3F); }
.ui-expandable-card-accent-warning::before { background-color: #b3591c; }
.ui-expandable-card-accent-danger::before { background-color: var(--color-danger, #dc3545); }

.ui-expandable-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 56px;
    padding: 0.75rem 1.1rem 0.75rem 1.6rem;
}

.ui-expandable-card-title-block {
    flex: 0 1 220px;
    min-width: 160px;
    display: grid;
    gap: 0.1rem;
}

.ui-expandable-card-title,
.ui-expandable-card-subtitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-expandable-card-title {
    font-size: 1rem;
    color: var(--text-color, #212529);
}

.ui-expandable-card-subtitle {
    font-size: 0.78rem;
    color: var(--color-brown-dark, #75695F);
}

.ui-expandable-card-progress {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    min-width: 220px;
    background-color: rgba(233, 220, 203, 0.35);
    border: 1px solid rgba(187, 169, 152, 0.35);
    border-radius: 999px;
    padding: 5px 12px;
}

.ui-expandable-card-progress-track {
    display: flex;
    width: 150px;
    gap: 4px;
}

.ui-expandable-card-progress-segment {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background-color: #e9ecef;
}

.ui-expandable-card-progress-done { background-color: #3f6b35; }
.ui-expandable-card-progress-current { background-color: #b3591c; }

.ui-expandable-card-progress-label {
    min-width: 52px;
    margin-left: 0.65rem;
    color: var(--color-brown-dark, #75695F);
    font-size: 0.72rem;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.ui-expandable-card-status {
    flex: 0 0 auto;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.ui-expandable-card-status-neutral {
    background: rgba(187, 169, 152, 0.2);
    color: var(--color-brown-dark, #75695F);
}

.ui-expandable-card-status-info {
    background: rgba(146, 183, 194, 0.32);
    color: #2f5964;
}

.ui-expandable-card-status-warning {
    background: rgba(179, 89, 28, 0.16);
    color: #8d4225;
}

.ui-expandable-card-status-danger {
    background: rgba(220, 53, 69, 0.14);
    color: #b02a37;
}

.ui-expandable-card-status-success {
    background: rgba(63, 107, 53, 0.14);
    color: #3f6b35;
}

.ui-expandable-card-badges {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.ui-expandable-card-details {
    max-height: 0;
    overflow: hidden;
    padding: 0 1.1rem 0 1.6rem;
    transition: max-height 0.25s ease, padding 0.25s ease;
}

.ui-expandable-card:hover .ui-expandable-card-details,
.ui-expandable-card:focus-within .ui-expandable-card-details,
.ui-expandable-card:focus .ui-expandable-card-details {
    max-height: 420px;
    padding: 0 1.1rem 1rem 1.6rem;
}

.ui-expandable-card-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.55rem 1rem;
    padding-top: 0.15rem;
    margin-bottom: 0.75rem;
    border-top: 1px solid rgba(187, 169, 152, 0.35);
}

.ui-expandable-card-meta-item {
    display: grid;
    gap: 0.15rem;
    min-width: 0;
}

.ui-expandable-card-meta-label {
    color: var(--color-brown-dark, #75695F);
    font-size: 0.72rem;
}

.ui-expandable-card-meta-value {
    min-width: 0;
    overflow: hidden;
    color: var(--text-color, #212529);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-expandable-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.ui-danger-zone {
    border: 1px solid rgba(220, 53, 69, 0.28);
    border-radius: 8px;
    background-color: rgba(220, 53, 69, 0.05);
    overflow: hidden;
    padding: 1rem 1.1rem;
    position: relative;
}

.ui-danger-zone-title {
    border-radius: 4px;
    color: #c93343;
    display: inline-flex;
    font-weight: 700;
    margin: 0 0 1rem;
    padding: 0.08rem 0.22rem;
    position: relative;
    z-index: 3;
}

.ui-danger-zone:not(.ui-danger-zone-unlocked) .ui-danger-zone-title {
    background-color: rgba(53, 38, 42, 0.96);
}

.ui-danger-zone-protected {
    border-radius: 6px;
    min-height: 3.25rem;
    position: relative;
    z-index: 1;
}

.ui-danger-zone:not(.ui-danger-zone-unlocked) .ui-danger-zone-protected > * {
    pointer-events: none;
    user-select: none;
}

.ui-danger-zone-shade {
    background:
        repeating-linear-gradient(
            135deg,
            rgba(5, 5, 5, 0.34) 0,
            rgba(5, 5, 5, 0.34) 12px,
            rgba(255, 197, 0, 0.28) 12px,
            rgba(255, 197, 0, 0.28) 24px
        ),
        rgba(20, 16, 10, 0.18);
    backdrop-filter: saturate(0.75) brightness(0.82);
    border: 0;
    border-radius: 0;
    cursor: pointer;
    inset: 0;
    position: absolute;
    z-index: 2;
}

.ui-danger-zone-shade:focus {
    outline: 2px solid rgba(255, 197, 0, 0.8);
    outline-offset: 2px;
}

.ui-danger-zone.ui-danger-zone-unlocked .ui-danger-zone-shade {
    display: none;
}

.ui-danger-zone-description {
    color: var(--text-color, #212529);
    margin: 0 0 0.85rem;
}

.ui-danger-zone-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
}

.ui-danger-zone-warning {
    border-color: rgba(179, 89, 28, 0.3);
    background-color: rgba(179, 89, 28, 0.05);
}

.ui-danger-zone-warning .ui-danger-zone-title {
    color: #8d4225;
}

.dark-theme .ui-expandable-card {
    background-color: #303030;
    border-color: #4a4a4a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
}

.dark-theme .ui-expandable-card:hover,
.dark-theme .ui-expandable-card:focus-within,
.dark-theme .ui-expandable-card:focus {
    background-color: #343434;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.dark-theme .ui-expandable-card-title,
.dark-theme .ui-expandable-card-meta-value {
    color: #f1f1f1;
}

.dark-theme .ui-expandable-card-subtitle,
.dark-theme .ui-expandable-card-progress-label,
.dark-theme .ui-expandable-card-meta-label {
    color: rgba(255, 255, 255, 0.72);
}

.dark-theme .ui-expandable-card-progress {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
}

.dark-theme .ui-expandable-card-status-neutral {
    color: #e0e0e0;
}

.dark-theme .ui-danger-zone {
    border-color: rgba(255, 107, 107, 0.34);
    background-color: rgba(255, 107, 107, 0.08);
}

.dark-theme .ui-danger-zone-title {
    color: #ff6b6b;
}

.dark-theme .ui-danger-zone-description {
    color: #f1f1f1;
}

.dark-theme .ui-danger-zone-warning {
    border-color: rgba(221, 143, 73, 0.38);
    background-color: rgba(221, 143, 73, 0.08);
}

.dark-theme .ui-danger-zone-warning .ui-danger-zone-title {
    color: #e4a15c;
}

@media (max-width: 900px) {
    .ui-expandable-card-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.65rem;
    }

    .ui-expandable-card-title-block,
    .ui-expandable-card-progress {
        width: 100%;
    }

    .ui-expandable-card-progress-track {
        width: 100%;
    }

    .ui-expandable-card-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
