/* ============================================================================
 * TraPay — legacy-content shim
 *
 * The CMS imported ~1500 legacy posts + landings whose body HTML was authored
 * against Bootstrap 3 and the old TraPay theme. The new theme doesn't ship
 * Bootstrap, so those classes were rendering bare. This file makes the legacy
 * markup look right without polluting the new theme.
 *
 * SCOPE: everything below is intentionally scoped to `.prose` so it only fires
 *        inside CMS-rendered body content (page/post/landing body), never the
 *        new-theme chrome. Keep new selectors under `.prose` too.
 *
 * Sections:
 *   1. Bootstrap 3 grid (.row / .col-*) — fluid 12-col flexbox, mobile first
 *   2. Bootstrap 3 utilities (img-responsive / pull-* / center-block / text-*)
 *   3. Bootstrap 3 buttons (.btn / .btn-warning / .btn-link)
 *   4. Bootstrap 3 panels + accordion (.panel-group / .collapse — FAQ blocks)
 *   5. Bootstrap 3 tables (.table / .table-bordered / .table-striped / .table-responsive)
 *   6. Bootstrap 3 alerts/wells
 *   7. Legacy custom (.ibox / .ibox2 / .sign / .well)
 *   8. Image alignment (img.pull-left / img.pull-right) — RTL aware
 *
 * RTL: body is rtl, so float:left/right are visual-LEFT/visual-RIGHT (per
 *       CSS spec — `float` is physical, not logical). This matches the
 *       legacy author intent which was also rtl.
 * ============================================================================ */

/* 1. Grid =================================================================== */
.tp-legacy-body .row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.75rem;
    margin-left: -0.75rem;
}
.tp-legacy-body .row > [class*="col-"] {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
    width: 100%;
    min-width: 0;
}

/* mobile-first: all cols full width by default, widen at md (768px+) */
@media (min-width: 768px) {
    .tp-legacy-body .col-md-1  { width: 8.3333%; }
    .tp-legacy-body .col-md-2  { width: 16.6667%; }
    .tp-legacy-body .col-md-3  { width: 25%; }
    .tp-legacy-body .col-md-4  { width: 33.3333%; }
    .tp-legacy-body .col-md-5  { width: 41.6667%; }
    .tp-legacy-body .col-md-6  { width: 50%; }
    .tp-legacy-body .col-md-7  { width: 58.3333%; }
    .tp-legacy-body .col-md-8  { width: 66.6667%; }
    .tp-legacy-body .col-md-9  { width: 75%; }
    .tp-legacy-body .col-md-10 { width: 83.3333%; }
    .tp-legacy-body .col-md-11 { width: 91.6667%; }
    .tp-legacy-body .col-md-12 { width: 100%; }
}
@media (min-width: 576px) {
    .tp-legacy-body .col-sm-6  { width: 50%; }
    .tp-legacy-body .col-sm-12 { width: 100%; }
}
.tp-legacy-body .col-xs-6  { width: 50%; }
.tp-legacy-body .col-xs-12 { width: 100%; }
.tp-legacy-body .mr-auto   { margin-inline-start: auto; }
.tp-legacy-body .ml-auto   { margin-inline-end: auto; }

/* 2. Utilities ============================================================== */
.tp-legacy-body .img-responsive {
    display: block;
    max-width: 100%;
    height: auto;
}
.tp-legacy-body .center-block {
    display: block;
    margin-right: auto;
    margin-left: auto;
}
.tp-legacy-body .pull-left  { float: left; }
.tp-legacy-body .pull-right { float: right; }
.tp-legacy-body .clearfix::after { content: ""; display: table; clear: both; }
.tp-legacy-body .text-center { text-align: center; }
.tp-legacy-body .text-right  { text-align: right; }
.tp-legacy-body .text-left   { text-align: left; }
.tp-legacy-body .text-muted  { color: var(--colors-neutral-500, #6b7280); }

/* legacy floated images: give them room to breathe in body copy */
.tp-legacy-body img.pull-left  { margin: 0 1rem 1rem 0; max-width: 50%; }
.tp-legacy-body img.pull-right { margin: 0 0 1rem 1rem; max-width: 50%; }
@media (max-width: 640px) {
    .tp-legacy-body img.pull-left,
    .tp-legacy-body img.pull-right {
        float: none;
        display: block;
        margin: 0.75rem auto;
        max-width: 100%;
    }
}

/* 3. Buttons ================================================================ */
.tp-legacy-body .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.625rem;
    font-weight: 600;
    font-size: 0.9375rem;
    line-height: 1.4;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none !important;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .15s ease;
}
.tp-legacy-body .btn:hover { transform: translateY(-1px); }
.tp-legacy-body .btn-warning {
    background: var(--colors-semantic-warning-base, #f59e0b);
    color: #fff;
    border-color: transparent;
}
.tp-legacy-body .btn-warning:hover {
    background: var(--colors-semantic-warning-strong, #d97706);
    color: #fff;
}
.tp-legacy-body .btn-link {
    background: transparent;
    color: var(--tp-brand, var(--color-primary, #0d3e7e));
    border: none;
    padding: 0;
    text-decoration: underline !important;
}
.tp-legacy-body .btn-link:hover {
    color: var(--colors-primary-700, #1e40af);
    transform: none;
}
.tp-legacy-body .btn-primary {
    background: var(--tp-brand, var(--color-primary, #0d3e7e));
    color: #fff;
}
.tp-legacy-body .btn-default {
    background: #fff;
    color: var(--colors-surface-foreground, #0f1b2d);
    border-color: var(--colors-neutral-200, #e5e7eb);
}

/* 4. Panels + cards + collapse (FAQ accordion) ============================== */
/* Handles BOTH Bootstrap 3 markup (.panel-group / .panel / .panel-heading /
 * .panel-body) AND Bootstrap 4 markup (.panel-group / .card / .card-header /
 * .card-body) — imported posts use either depending on when they were written. */
.tp-legacy-body .panel-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1.5rem 0;
}
.tp-legacy-body .panel,
.tp-legacy-body .panel-default,
.tp-legacy-body .panel-group > .card {
    border: 1px solid var(--colors-neutral-200, #e5e7eb);
    border-radius: 0.75rem;
    background: #fff;
    overflow: hidden;
}
.tp-legacy-body .panel-heading,
.tp-legacy-body .panel-group > .card > .card-header {
    background: var(--colors-neutral-50, #f9fafb);
    border-bottom: 1px solid var(--colors-neutral-200, #e5e7eb);
    padding: 1rem 1.25rem;
}
.tp-legacy-body .panel-heading h4,
.tp-legacy-body .panel-group > .card > .card-header h4 { margin: 0; font-size: 1rem; }
.tp-legacy-body .panel-heading .btn-link,
.tp-legacy-body .panel-group > .card > .card-header .btn-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    color: var(--colors-surface-foreground, #0f1b2d);
    font-weight: 600;
    text-decoration: none !important;
    padding: 0;
    background: transparent;
    text-align: start;
}
.tp-legacy-body .panel-heading .btn-link::after,
.tp-legacy-body .panel-group > .card > .card-header .btn-link::after {
    content: "▾";
    display: inline-block;
    font-size: 0.85rem;
    color: var(--colors-neutral-500, #6b7280);
    transition: transform .2s ease;
    flex-shrink: 0;
    margin-inline-start: 0.75rem;
}
.tp-legacy-body .panel-heading .btn-link[aria-expanded="true"]::after,
.tp-legacy-body .panel-group > .card > .card-header .btn-link[aria-expanded="true"]::after {
    transform: rotate(180deg);
    color: var(--tp-brand, var(--color-primary, #0d3e7e));
}
.tp-legacy-body .panel-heading .btn-link.collapsed::after,
.tp-legacy-body .panel-group > .card > .card-header .btn-link.collapsed::after { transform: none; }
.tp-legacy-body .panel-body,
.tp-legacy-body .panel-group > .card > .collapse > .card-body,
.tp-legacy-body .panel-group > .card > .card-body {
    padding: 1rem 1.25rem;
    color: var(--colors-neutral-700, #374151);
}
.tp-legacy-body .panel-collapse { background: #fff; }

/* collapse mechanics — JS toggles .in / .show / .open. Inline height:0 from
 * legacy markup is overridden when .in/.show/.open is set. */
.tp-legacy-body .collapse:not(.in):not(.show):not(.open) { display: none; }
.tp-legacy-body .collapse.in,
.tp-legacy-body .collapse.show,
.tp-legacy-body .collapse.open {
    display: block;
    height: auto !important;
}
.tp-legacy-body .collapsing {
    overflow: hidden;
    transition: max-height .25s ease;
}

/* 5. Tables ================================================================= */
.tp-legacy-body .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    margin: 1.25rem 0;
    border-radius: 0.5rem;
}
.tp-legacy-body .table {
    width: 100%;
    margin: 1.25rem 0;
    border-collapse: collapse;
    background: #fff;
    font-size: 0.9375rem;
}
.tp-legacy-body .table th,
.tp-legacy-body .table td {
    padding: 0.75rem 1rem;
    text-align: inherit;
    vertical-align: middle;
}
.tp-legacy-body .table-bordered,
.tp-legacy-body .table-bordered th,
.tp-legacy-body .table-bordered td {
    border: 1px solid var(--colors-neutral-200, #e5e7eb);
}
.tp-legacy-body .table-striped tbody tr:nth-of-type(odd) {
    background: var(--colors-neutral-50, #f9fafb);
}
.tp-legacy-body .table-hover tbody tr:hover {
    background: var(--colors-primary-50, #eff6ff);
}
.tp-legacy-body .table thead th {
    background: var(--colors-neutral-100, #f3f4f6);
    font-weight: 700;
    color: var(--colors-surface-foreground, #0f1b2d);
}

/* 6. Alerts + wells ========================================================= */
.tp-legacy-body .alert {
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
    border-radius: 0.625rem;
    border-left: 4px solid;
    background: var(--colors-neutral-50, #f9fafb);
    color: var(--colors-neutral-800, #1f2937);
}
.tp-legacy-body .alert-info    { border-color: #3b82f6; background: #eff6ff; }
.tp-legacy-body .alert-success { border-color: #10b981; background: #ecfdf5; }
.tp-legacy-body .alert-warning { border-color: #f59e0b; background: #fffbeb; }
.tp-legacy-body .alert-danger  { border-color: #ef4444; background: #fef2f2; }
.tp-legacy-body .well {
    background: var(--colors-neutral-50, #f9fafb);
    border: 1px solid var(--colors-neutral-200, #e5e7eb);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    margin: 1.25rem 0;
}

/* 7. Legacy custom containers (ibox / ibox2 / sign) ========================== */
.tp-legacy-body .ibox,
.tp-legacy-body .ibox2 {
    background: #fff;
    border: 1px solid var(--colors-neutral-200, #e5e7eb);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}
.tp-legacy-body .ibox2 { background: var(--colors-neutral-50, #f9fafb); }
.tp-legacy-body .sign {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: var(--colors-primary-50, #eff6ff);
    color: var(--tp-brand, var(--color-primary, #0d3e7e));
    font-size: 0.8125rem;
    font-weight: 600;
}

/* 8. Dark mode tweaks ======================================================= */
.dark .tp-legacy-body .panel,
.dark .tp-legacy-body .panel-default,
.dark .tp-legacy-body .panel-collapse,
.dark .tp-legacy-body .table,
.dark .tp-legacy-body .ibox,
.dark .tp-legacy-body .ibox2,
.dark .tp-legacy-body .well {
    background: var(--colors-surface-dark, #1f2937);
    border-color: var(--colors-neutral-700, #374151);
    color: var(--colors-neutral-200, #e5e7eb);
}
.dark .tp-legacy-body .panel-heading {
    background: var(--colors-neutral-800, #1f2937);
    border-color: var(--colors-neutral-700, #374151);
}
.dark .tp-legacy-body .panel-heading .btn-link { color: var(--colors-neutral-100, #f3f4f6); }
.dark .tp-legacy-body .table thead th { background: var(--colors-neutral-800, #1f2937); color: #f3f4f6; }
.dark .tp-legacy-body .table-striped tbody tr:nth-of-type(odd) { background: rgba(255,255,255,0.02); }
.dark .tp-legacy-body .table-hover tbody tr:hover { background: rgba(59,130,246,0.08); }
