/* Menu */
.nav> .nav-item > a{
    color: white;
}

/* Headings */
h1, h2, h3, h4, h5, h6 { color: #506281; }

/* Global font size */
body, table, .form-control, .form-select, .btn, input, select, textarea, label, th, td {
    font-size: 14px !important;
}

/* Modal form spacing */
.modal-body .form-group { margin-bottom: 0.75rem; }
.modal-body .row.g-2 > [class*="col-"] { padding-top: 0.25rem; padding-bottom: 0.25rem; }

/* Validation feedback */
.was-validated .form-control:invalid,
.was-validated .form-select:invalid { border-color: #dc3545; }
.was-validated .form-control:valid,
.was-validated .form-select:valid   { border-color: #28a745; }

/* DataTable cell and header — condensed */
table.dataTable th, table.dataTable td {
    line-height: 20px !important;
    padding: 10px 4px !important;
}

/* Grid header — bold, no wrap, aligned with body */
table.dataTable thead th {
    font-weight: 600 !important;
    color: #3f4d67 !important;
    font-size: 12px !important;
    white-space: nowrap !important;
    padding: 10px 4px !important;
}

/* Grid body */
table.dataTable tbody td {
    color: #212529 !important;
    font-size: 12px !important;
    font-weight: 400 !important;
    padding: 4px !important;
}

/* DataTables sizing elements — leave in DOM for column alignment */

/* Grid status pills */
table.dataTable .badge {
    display: inline-block;
    padding: 3px 12px !important;
    border-radius: 10px;
    font-size: 13px !important;
    font-weight: 600;
}

/* Search button — match Add button exactly */
button#searchWithTerms {
    border-radius: 0.25rem !important;
}

/* Store nav label */
a#store-nav-label {
    color: #ffffff !important;
    font-weight: 400 !important;
}

/* Dropdown menu — white background, #495057 text, blue hover. */
.dropdown-menu li {
    font-size: 14px;
    padding: 0px;
}
.dropdown-menu {
    padding: 0;
    background-color: #fff;
}
.dropdown-menu .dropdown-item {
    color: #495057;
    padding: 0.5em 0.5em;
}
.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus {
    background-color: #34a6e7;
    color: #fff;
}

/* Desktop navbar — top-level link padding (lg breakpoint and up) */
@media (min-width: 992px) {
    .navbar-expand-lg .navbar-nav .nav-link {
        padding: 1em;
    }
}

/* Page headings */
h4 {
    font-size: 30px !important;
    font-weight: 600 !important;
}

/* DataTables sorting_disabled sizing rows — kept for column alignment */

/* Filter bar — size, alignment, font */
.tableFilter .form-control-sm,
.tableFilter .form-select-sm {
    font-size: 12px !important;
    height: 30px !important;
    vertical-align: middle !important;
    display: inline-flex !important;
    align-items: center !important;
}
.tableFilter .btn {
    font-size: 12px !important;
    height: 30px !important;
    vertical-align: middle !important;
    display: inline-flex !important;
    align-items: center !important;
}
.tableFilter label {
    font-size: 12px !important;
}

/* Reduce gap between filter row and action buttons */
.dataTables_wrapper .row:first-child {
    align-items: center !important;
    gap: 0 !important;
    margin-bottom: 4px !important;
}
.dataTables_wrapper .row:first-child > [class*="col-"] {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
/* Shrink filter column, give more space to buttons */
.dataTables_wrapper .row:first-child .tableFilter {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
}
.dataTables_wrapper .row:first-child .float-right,
.dataTables_wrapper .row:first-child .dt-buttons {
    margin-left: auto !important;
}

/* Options column — keep buttons on one row */
table.dataTable td.text-nowrap,
table.dataTable td .btn-group-nowrap {
    white-space: nowrap;
}

/* Searchable customer dropdown — now uses .entity-search-wrap / .entity-dropdown / .entity-item */

/* Pagination hidden — show all rows */
.dataTables_paginate { display: none !important; }
.dataTables_info { display: none !important; }

/* Empty-state row ("No matching records found") — left-align.
   Beats the `tbody tr > td:last-child { text-align: right }` rule in
   custom-datatables.css by being more specific (class + tbody + td). */
table.dataTable tbody td.dataTables_empty,
table.dataTable tbody tr > td.dataTables_empty:last-child {
    text-align: left !important;
}

/* ── Status badges ── */
.badge-active {
    display: inline-block; padding: 3px 12px !important; border-radius: 10px;
    font-size: 13px !important; font-weight: 600;
    background: linear-gradient(135deg, #1dc4e9, #1de9b6); color: #fff;
}
.badge-inactive {
    display: inline-block; padding: 3px 12px !important; border-radius: 10px;
    font-size: 13px !important; font-weight: 600;
    background: linear-gradient(135deg, #f6665d, #f89b95); color: #fff;
}
.badge-info-alt {
    display: inline-block; padding: 3px 12px !important; border-radius: 10px;
    font-size: 13px !important; font-weight: 600;
    background: linear-gradient(135deg, #8569ba, #d198e3); color: #fff;
}

/* ── Entity search dropdown (customers, creditors) ── */
.entity-search-wrap { position: relative; display: inline-block; width: 100%; }
.entity-search-wrap input { width: 100%; }
.entity-search-wrap .search-icon {
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: #aab2bd;
}
.entity-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 1050;
    max-height: 250px; overflow-y: auto;
    background: #fff; border: 1px solid #ddd; border-top: none; border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); display: none;
}
.entity-dropdown .entity-item {
    padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f5f5f5;
}
.entity-dropdown .entity-item:hover { background: #e9f5ff; }
.entity-dropdown .entity-item .entity-acno { font-weight: 600; color: #3f4d67; margin-right: 8px; }
.entity-dropdown .entity-item .entity-name { color: #506281; }

/* ── GRV modal wide ── */
.modal-wide .modal-dialog { max-width: 900px; }

/* ── SweetAlert buttons — match form Save/Cancel (.btn-primary / .btn-danger).
   The bundled sweetalert.css ships with a pale-blue confirm (#8CD4F5) and
   grey cancel (#C1C1C1) that don't match the Cerulean theme used everywhere
   else. Re-skin them with the Bootstrap primary/danger palette so confirm
   dialogs read as "save vs cancel" the same way modal forms do. ── */
.sweet-alert button.confirm {
    background-color: #2fa4e7 !important; /* btn-primary (Cerulean) */
    border: 1px solid #2fa4e7 !important;
    color: #fff !important;
}
.sweet-alert button.confirm:hover  { background-color: #1990d5 !important; border-color: #1888ca !important; }
.sweet-alert button.confirm:active { background-color: #1888ca !important; border-color: #167ebd !important; }
.sweet-alert button.confirm:focus  { box-shadow: 0 0 0 0.2rem rgba(47, 164, 231, 0.5) !important; }

.sweet-alert button.cancel {
    background-color: #c71c22 !important; /* btn-danger (Cerulean) */
    border: 1px solid #c71c22 !important;
    color: #fff !important;
}
.sweet-alert button.cancel:hover  { background-color: #a5171c !important; border-color: #98151a !important; }
.sweet-alert button.cancel:active { background-color: #98151a !important; border-color: #8a1317 !important; }
.sweet-alert button.cancel:focus  { box-shadow: 0 0 0 0.2rem rgba(199, 28, 34, 0.5) !important; }

/* ── Legacy user grid overrides ── */
.user-grid-wrap .dataTables_wrapper { margin-right: 20px; padding-top: 0; }
.user-grid-wrap .dt-buttons { float: none; text-align: center; margin-bottom: 0; padding-top: 0; }
.user-grid-wrap .dt-buttons .dt-button {
    background: #1976d2; border-radius: 4px; color: #fff; margin-right: 3px; padding: 5px 15px;
}

/* ── Mobile + tablet overrides ─────────────────────────────────────────────
   Activates at <992px (Bootstrap's `lg` breakpoint, matches navbar-expand-lg
   in menu.twig). Above this width the desktop layout is untouched.
   --------------------------------------------------------------------- */
@media (max-width: 991.98px) {

    /* Touch targets + readable fonts. iOS auto-zooms when an input's
       computed font-size is < 16px on focus — bumping prevents that. */
    body, table, .form-control, .form-select, .btn, input, select, textarea, label, th, td {
        font-size: 14px !important;
    }
    .form-control, .form-select, input, select, textarea {
        font-size: 16px !important;
        min-height: 40px;
    }
    .btn {
        min-height: 40px;
        padding: 0.5rem 0.85rem;
    }

    /* Modals: hard-cap to viewport. Desktop .modal-wide is 900px which
       overflows phones; even default modals can clip with the theme's
       custom margins. */
    .modal-dialog,
    .modal-wide .modal-dialog {
        max-width: calc(100% - 1rem) !important;
        margin: 0.5rem auto !important;
    }
    .modal-body { padding: 0.75rem; }
    .modal-body .row.g-2 > [class*="col-"] { padding-top: 0.5rem; padding-bottom: 0.5rem; }

    /* DataTables: relax the desktop 4px / 12px crunch so cells are tappable. */
    table.dataTable th, table.dataTable td {
        line-height: 18px !important;
        padding: 8px 6px !important;
    }
    table.dataTable thead th { font-size: 13px !important; padding: 10px 6px !important; }
    table.dataTable tbody td { font-size: 13px !important; padding: 8px 6px !important; }
    table.dataTable .btn,
    table.dataTable td .btn { min-height: 36px; padding: 0.35rem 0.5rem; }

    /* Neutralize fixed scrollY:500px set per-grid. The grids still get
       scrollX:true for horizontal overflow on narrow viewports, but the
       inner 500px vertical scroll-within-scroll is unusable on phones
       (creates double-scrollbars). Letting it grow lets the page scroll
       carry the table naturally. */
    .dataTables_scrollBody {
        max-height: none !important;
        overflow-y: visible !important;
    }
    .dataTables_scroll { overflow-x: auto; }

    /* Filter bar + export buttons: stack vertically instead of fighting
       for one row. */
    .dataTables_wrapper .row:first-child { flex-wrap: wrap !important; }
    .dataTables_wrapper .row:first-child .tableFilter,
    .dataTables_wrapper .row:first-child .float-right,
    .dataTables_wrapper .row:first-child .dt-buttons {
        flex: 0 0 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
    }
    .tableFilter { display: flex; flex-wrap: wrap; gap: 6px; }
    .tableFilter .form-control-sm,
    .tableFilter .form-select-sm,
    .tableFilter .btn {
        height: auto !important;
        min-height: 36px;
        font-size: 14px !important;
    }
    .tableFilter label { font-size: 13px !important; width: 100%; }
    .dt-buttons { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
    .dt-buttons .dt-button { font-size: 13px !important; }

    /* Page headings shrink so they don't dominate phone viewports. */
    h4 { font-size: 22px !important; }

    /* Dropdowns inside a collapsed navbar render full-width without the
       absolute-positioned popup chrome. */
    .navbar-nav .dropdown-menu {
        border: none;
        padding-left: 0.75rem;
        background-color: transparent;
        box-shadow: none;
    }
    .navbar-nav .dropdown-menu .dropdown-item { color: #fff; padding: 0.5rem 0.5rem; }
    .navbar-nav .dropdown-menu .dropdown-item:hover { background-color: rgba(255,255,255,0.08); }
}

/* Toggle switch styling */
.form-check.form-switch {
    padding-left: 3em;
    min-height: 2em;
    display: flex;
    align-items: center;
}
.form-check.form-switch .form-check-input {
    width: 2.5em;
    height: 1.3em;
    margin-left: -3em;
    margin-top: 0;
    cursor: pointer;
    background-color: #cfd5de;
    border: none;
    transition: background-color 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}
.form-check.form-switch .form-check-input:checked {
    background-color: #1de9b6;
    border-color: #1de9b6;
}
.form-check.form-switch .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(29, 233, 182, 0.25);
    border-color: #1de9b6;
}
.form-check.form-switch .form-check-label {
    cursor: pointer;
    margin-left: 0.5em;
}

/* ─── Admin User → Permissions section ────────────────────────────────────
   Scoped styling for the role-based permission grids on the back-office
   admin-user form. Replaces the inline styles that used to live in
   src/templates/admin-user/form.twig. */

.permissions-section { margin-top: 1.5rem; }

.permissions-section .perm-heading {
    color: #506281;
    font-weight: 600;
}
.permissions-section .perm-divider {
    border-color: #506281;
    opacity: 0.3;
    margin-top: 0.25rem;
    margin-bottom: 0.75rem;
}

.permissions-section .perm-group-header {
    background-color: #eef1f6;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}
.permissions-section .perm-group-header strong { color: #364257; }

.permissions-section .perm-switch { padding-left: 2.5em; }

.permissions-section .perm-item-list { margin-bottom: 1rem; }

.permissions-section .perm-item-row { border-bottom: 1px solid #f0f2f5; }
.permissions-section .perm-item-label {
    color: #364257;
    font-weight: 600;
    font-size: 0.95rem;
}

/* Toggle cells — three width variants used across groups */
.permissions-section .perm-cell {
    padding-left: 2.5em;
    margin: 0;
    min-width: 170px;
}
.permissions-section .perm-cell--narrow { min-width: 140px; }
.permissions-section .perm-cell--wide   { min-width: 200px; }
.permissions-section .perm-cell-label   { font-size: 0.85rem; }

/* Setup grid (the table-based block) */
.permissions-section .perm-setup-wrap   { margin-bottom: 1rem; }
.permissions-section .perm-setup-table  { margin-bottom: 0; }
.permissions-section .perm-setup-table thead { background-color: #f4f6fa; }
.permissions-section .perm-setup-table thead th { background-color: #eef1f6; }
.permissions-section .perm-setup-table thead .perm-action-col { width: 90px; }
.permissions-section .perm-setup-table .perm-action-col-label { width: 90px; }
table[id].table-condensed:not(.dataTable){visibility:hidden !important}table[id].table-condensed:not(.dataTable)~* .tableFilter:empty,.dataTables_wrapper .tableFilter:empty{display:none}.dataTables_wrapper .dataTables_filter{float:left !important}.dt-buttons{float:right !important}.dt-buttons>a{margin-left:8px}#start-date,#end-date{border:1px solid #dee2e6 !important;border-radius:0.375rem !important;color:#495072 !important}#searchCol,#expression{color:#495072}table.dataTable thead th,table.dataTable tfoot th{font-weight:bold}table.dataTable thead th{font-weight:700 !important;color:#3f4d67 !important;font-size:12px !important;padding:10px 4px !important}table.dataTable thead tr>th:last-child,table.dataTable tbody tr>td:last-child,table.dataTable tfoot tr>th:last-child,table.dataTable tfoot tr>td:last-child{text-align:right !important}.btn-delete-role,.btn-outline-danger.st-delete,.btn-outline-danger.au-delete,.btn-outline-danger.cu-delete,.btn-outline-danger.cr-delete,.btn-outline-danger.tl-delete,.btn-outline-danger.trf-delete,button[title="Delete"]{display:none !important}.form-select{height:42px !important}table.dataTable tfoot th,table.dataTable tfoot td{border-top:1px solid #111;font-weight:700 !important;color:#3f4d67 !important;padding:10px 4px !important;font-size:12px !important}.dataTables_scrollHead table.dataTable thead th,.dataTables_scrollHead table.dataTable thead td{border-top:1px solid #dee2e6 !important}.dataTables_scrollFoot table.dataTable tfoot th,.dataTables_scrollFoot table.dataTable tfoot td{border-bottom:1px solid #dee2e6 !important}.dataTables_scrollBody table.dataTable>thead>tr>th,.dataTables_scrollBody table.dataTable>thead>tr>td,.dataTables_scrollBody table.dataTable>tfoot>tr>th,.dataTables_scrollBody table.dataTable>tfoot>tr>td{padding:0 !important;height:0 !important;line-height:0 !important;border:0 !important}
/* Opt-in column-content classes — set as columnDef.className on a column
   to override a cell's default white-space behavior. Add `.dt-wrap-2` on
   a column whose body cells would otherwise wrap onto 3+ lines and blow
   out the row height (e.g. long description / notes columns) — it
   clamps content to 2 lines with an ellipsis after. `.dt-wrap` forces
   full natural wrap as an override for inherited nowrap. */
table.dataTable tbody td.dt-wrap-2{white-space:normal;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}
table.dataTable tbody td.dt-wrap{white-space:normal;word-break:break-word;overflow:visible;text-overflow:clip}
/* dt-nowrap-wrapper: opt-in wrapper around a DataTables table that wants
   the column-width pattern — every header + body + footer cell stays on
   one line. The companion JS helper applyDtNowrap(grid) (in tableFilter.js)
   stamps min-width from declared column widths and syncs header column
   widths to the body's actual rendered widths so they stay aligned and
   scroll together. */
.dt-nowrap-wrapper .dataTables_scrollHead th,
.dt-nowrap-wrapper .dataTables_scrollHead td,
.dt-nowrap-wrapper .dataTables_scrollBody th,
.dt-nowrap-wrapper .dataTables_scrollBody td,
.dt-nowrap-wrapper .dataTables_scrollFoot th,
.dt-nowrap-wrapper .dataTables_scrollFoot td{white-space:nowrap}
/* +5px right padding (on top of the global 4px) so column text — header,
   body, and footer — has breathing room from the next column's left edge.
   Helper stamps box-sizing:border-box on cells so column widths stay exact. */
.dt-nowrap-wrapper .dataTables_scrollHead th,
.dt-nowrap-wrapper .dataTables_scrollHead td,
.dt-nowrap-wrapper .dataTables_scrollBody th,
.dt-nowrap-wrapper .dataTables_scrollBody td,
.dt-nowrap-wrapper .dataTables_scrollFoot th,
.dt-nowrap-wrapper .dataTables_scrollFoot td{padding-right:9px !important}
/* Nav-tabs sit flush against the grid header below. */
ul.nav.nav-tabs.mb-3 { margin-bottom: 0 !important; }
