/* ==========================================================================
   BongaText UI enhancements

   Additive layer on top of the existing Bootstrap 3 admin template. It reuses
   the template's own tokens (brand #5fbeaa, Nunito, #f4f8fb page ground) rather
   than restyling the product, and covers the gaps the review found:
   accessible focus, keyboard skip link, empty / loading states, table and form
   legibility, action hierarchy, and small-screen behaviour.

   Loaded after site.min.css, so plain selectors win on equal specificity.
   ========================================================================== */

:root {
    --bt-brand: #5fbeaa;
    --bt-brand-dark: #4aa693;
    --bt-brand-soft: #eaf6f3;
    --bt-ink: #36404a;
    --bt-muted: #7a8794;
    --bt-line: #e4e9ee;
    --bt-ground: #f4f8fb;
    --bt-success: #81c868;
    --bt-info: #5d9cec;
    --bt-warning: #ffbd4a;
    --bt-danger: #f05050;
    --bt-radius: 5px;
    --bt-focus: 0 0 0 3px rgba(95, 190, 170, 0.45);
}

/* --------------------------------------------------------------------------
   1. Keyboard access
   The app had no visible focus indicator and no way to skip the sidebar.
   -------------------------------------------------------------------------- */

.bt-skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 1080;
    padding: 10px 18px;
    background: var(--bt-ink);
    color: #fff;
    border-radius: 0 0 var(--bt-radius) 0;
    font-weight: 600;
    text-decoration: none;
}

.bt-skip-link:focus {
    left: 0;
    color: #fff;
    text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
.btn:focus-visible {
    outline: 2px solid transparent;
    box-shadow: var(--bt-focus);
    border-radius: 3px;
}

/* Main region is focus-target only; never draw a ring around the whole page. */
#main-content:focus,
#main-content:focus-visible {
    outline: none;
    box-shadow: none;
}

/* --------------------------------------------------------------------------
   2. Action hierarchy
   Primary actions were rendered as grey btn-default and cancel links as red
   btn-danger, which inverted the meaning of the two most common buttons.
   -------------------------------------------------------------------------- */

.btn {
    border-radius: var(--bt-radius);
    font-weight: 600;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.btn-primary,
.btn-custom {
    background-color: var(--bt-brand);
    border-color: var(--bt-brand);
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-custom:hover,
.btn-custom:focus {
    background-color: var(--bt-brand-dark);
    border-color: var(--bt-brand-dark);
    color: #fff;
}

/* Neutral "get me out of here" action: readable, and clearly not destructive. */
.btn-cancel,
.btn-cancel:focus {
    background-color: #fff;
    border-color: var(--bt-line);
    color: var(--bt-muted);
}

.btn-cancel:hover {
    background-color: var(--bt-ground);
    border-color: #cfd8e0;
    color: var(--bt-ink);
}

.btn[disabled],
.btn.disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* Groups a form's submit/cancel pair with consistent spacing. */
.bt-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding-top: 6px;
    border-top: 1px solid var(--bt-line);
    margin-top: 18px;
}

.bt-form-actions .btn {
    margin: 0;
}

/* --------------------------------------------------------------------------
   3. Page headers and cards
   -------------------------------------------------------------------------- */

.header-title {
    color: var(--bt-ink);
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 22px;
    line-height: 1.3;
}

.bt-page-head {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.bt-page-head .header-title {
    margin-bottom: 4px;
}

.bt-page-head__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
}

.bt-page-head__lead {
    color: var(--bt-muted);
    margin: 0;
}

.card-box {
    box-shadow: 0 1px 2px rgba(54, 64, 74, .06);
}

/* --------------------------------------------------------------------------
   4. Tables
   -------------------------------------------------------------------------- */

.table > thead > tr > th {
    border-bottom: 2px solid var(--bt-line);
    color: var(--bt-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
    vertical-align: middle;
}

.table > tbody > tr > td {
    vertical-align: middle;
    color: var(--bt-ink);
}

.table-hover > tbody > tr:hover {
    background-color: var(--bt-brand-soft);
}

/* Numeric columns line up when right-aligned with tabular figures. */
.bt-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Row actions: give icon-only controls a real hit area. */
.bt-row-actions {
    white-space: nowrap;
    text-align: right;
}

.bt-row-actions > a,
.bt-row-actions > button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: 2px;
    border: 1px solid transparent;
    border-radius: var(--bt-radius);
    color: var(--bt-muted);
    background: none;
}

.bt-row-actions > a:hover,
.bt-row-actions > button:hover {
    background-color: var(--bt-brand-soft);
    border-color: var(--bt-line);
    color: var(--bt-brand-dark);
    text-decoration: none;
}

.bt-row-actions .text-danger:hover {
    background-color: rgba(240, 80, 80, .1);
    color: var(--bt-danger);
}

/* Horizontal scroll must stay inside the table wrapper, never the page. */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* --------------------------------------------------------------------------
   5. Empty, loading and error states
   None of the 149 views had an empty state; a list with no rows rendered as a
   bare table header with no explanation and no way forward.
   -------------------------------------------------------------------------- */

.bt-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--bt-muted);
}

.bt-empty__icon {
    font-size: 40px;
    line-height: 1;
    color: #c8d3dc;
    margin-bottom: 14px;
}

.bt-empty__title {
    color: var(--bt-ink);
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 6px;
}

.bt-empty__text {
    margin: 0 auto 16px;
    max-width: 44ch;
}

.bt-empty--error .bt-empty__icon {
    color: var(--bt-danger);
}

.bt-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 28px 16px;
    color: var(--bt-muted);
}

.bt-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--bt-line);
    border-top-color: var(--bt-brand);
    border-radius: 50%;
    animation: bt-spin .7s linear infinite;
    flex: none;
}

@keyframes bt-spin {
    to { transform: rotate(360deg); }
}

/* Anything mid-request reads as busy and stops accepting clicks. */
[aria-busy="true"] {
    opacity: .6;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .bt-spinner { animation-duration: 2s; }
    .btn { transition: none; }
}

/* --------------------------------------------------------------------------
   6. Forms
   -------------------------------------------------------------------------- */

.control-label,
.form-group > label {
    color: var(--bt-ink);
    font-weight: 600;
}

.form-control {
    border-color: var(--bt-line);
    border-radius: var(--bt-radius);
    box-shadow: none;
    color: var(--bt-ink);
}

.form-control:focus {
    border-color: var(--bt-brand);
    box-shadow: var(--bt-focus);
}

.form-control::placeholder {
    color: #a9b4be;
}

/* Marks a required field without relying on colour alone. */
.bt-required::after {
    content: " *";
    color: var(--bt-danger);
    font-weight: 700;
}

/* Short helper text under an input. */
.bt-hint {
    display: block;
    margin-top: 4px;
    color: var(--bt-muted);
    font-size: 12px;
}

/* Validation messages need to be noticed, not just coloured. */
.field-validation-error,
span.text-danger:not(:empty) {
    display: inline-block;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 600;
}

.input-validation-error {
    border-color: var(--bt-danger);
    background-color: #fff8f8;
}

.validation-summary-errors ul {
    margin: 0;
    padding-left: 18px;
}

.validation-summary-errors {
    border: 1px solid rgba(240, 80, 80, .35);
    background-color: #fff5f5;
    border-radius: var(--bt-radius);
    color: #a12d2d;
    padding: 10px 14px;
    margin-bottom: 14px;
}

.validation-summary-valid {
    display: none;
}

/* --------------------------------------------------------------------------
   7. Alerts
   -------------------------------------------------------------------------- */

.alert {
    border-radius: var(--bt-radius);
    border-width: 1px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert > .close {
    margin-left: auto;
    order: 3;
}

.alert .alert-text {
    flex: 1 1 auto;
}

/* --------------------------------------------------------------------------
   8. Filters toolbar
   -------------------------------------------------------------------------- */

.bt-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    padding: 14px 16px;
    background: var(--bt-ground);
    border: 1px solid var(--bt-line);
    border-radius: var(--bt-radius);
    margin-bottom: 16px;
}

.bt-filters .form-group {
    margin-bottom: 0;
}

.bt-filters label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bt-muted);
    margin-bottom: 4px;
}

/* --------------------------------------------------------------------------
   9. DataTables trim
   -------------------------------------------------------------------------- */

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--bt-line);
    border-radius: var(--bt-radius);
    padding: 5px 10px;
    color: var(--bt-ink);
}

.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
    border-color: var(--bt-brand);
    box-shadow: var(--bt-focus);
    outline: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--bt-brand) !important;
    border-color: var(--bt-brand) !important;
    color: #fff !important;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    color: var(--bt-muted);
}

.dataTables_empty {
    padding: 32px 16px !important;
    text-align: center;
    color: var(--bt-muted);
}

/* --------------------------------------------------------------------------
   10. Responsive
   The sidebar layout assumed a desktop viewport; these rules keep the content
   column, toolbars and tables usable down to a phone.
   -------------------------------------------------------------------------- */

/* Nothing should ever push the page itself sideways. */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

@media (max-width: 991px) {
    .bt-page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .bt-page-head__actions {
        margin-left: 0;
    }

    .card-box {
        padding: 16px;
    }
}

@media (max-width: 767px) {
    .header-title {
        font-size: 19px;
    }

    /* Horizontal form labels stack rather than eating half the width. */
    .form-horizontal .control-label {
        text-align: left;
        margin-bottom: 4px;
        padding-top: 0;
    }

    .bt-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .bt-filters .form-control,
    .bt-filters .btn {
        width: 100%;
    }

    .bt-form-actions .btn {
        flex: 1 1 auto;
    }

    /* Full-width tap targets read better than a 32px icon on touch. */
    .bt-row-actions > a,
    .bt-row-actions > button {
        width: 38px;
        height: 38px;
    }

    .footer {
        text-align: center;
    }
}

/* --------------------------------------------------------------------------
   11. Print
   -------------------------------------------------------------------------- */

@media print {
    .topbar,
    .left.side-menu,
    .bt-page-head__actions,
    .bt-filters,
    .bt-row-actions,
    .footer,
    .dataTables_length,
    .dataTables_filter,
    .dataTables_paginate {
        display: none !important;
    }

    .content-page {
        margin-left: 0 !important;
    }

    .card-box {
        border: none;
        box-shadow: none;
        padding: 0;
    }
}
