/* =========================================================================
   Brand theme bridge — maps Bootstrap component classes used across legacy
   admin/partner pages onto the new MactraOne brand palette (black + red).
   Loaded after Bootstrap and MactraOne/styles.css so it wins the cascade.
   ========================================================================= */

:root {
    /* Re-expose brand tokens with shorter names so admin pages can reference */
    --brand-red:        #e63946;
    --brand-red-dark:   #b30707;
    --brand-red-darker: #8f0606;
    --brand-red-light:  #fdecec;
    --brand-black:      #0a0a0a;
    --brand-grey-900:   #1a1a1a;
    --brand-grey-100:   #f8f9fa;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn-primary,
.btn.btn-primary {
    background-color: var(--brand-red);
    border-color: var(--brand-red);
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn.btn-primary:hover,
.btn.btn-primary:focus,
.btn.btn-primary:active {
    background-color: var(--brand-red-dark) !important;
    border-color: var(--brand-red-dark) !important;
}

.btn-outline-primary,
.btn.btn-outline-primary {
    color: var(--brand-red);
    border-color: var(--brand-red);
}
.btn-outline-primary:hover,
.btn.btn-outline-primary:hover {
    background-color: var(--brand-red);
    border-color: var(--brand-red);
    color: #fff;
}

/* Warning buttons (used for Rights / Edit-style actions) — neutralise the
   yellow/orange into a softer brand-aligned amber so they still read as a
   distinct action class but no longer clash with the red brand. */
.btn-outline-warning,
.btn.btn-outline-warning {
    color: #b58105;
    border-color: #b58105;
}
.btn-outline-warning:hover,
.btn.btn-outline-warning:hover {
    background-color: #b58105;
    border-color: #b58105;
    color: #fff;
}
.btn-warning,
.btn.btn-warning {
    background-color: #f0a020;
    border-color: #f0a020;
    color: #fff;
}
.btn-warning:hover {
    background-color: #d68b18;
    border-color: #d68b18;
    color: #fff;
}

/* ── Table headers (designer-grade polished grid) ──────────────────────
   Light, uppercase, muted column labels — replaces both the legacy
   .table-dark navy header and any thead.bg-primary header. */
.table > thead,
.table > thead.table-dark,
.table > thead.bg-primary {
    background-color: #f8f9fa !important;
}
.table > thead > tr > th,
.table > thead.table-dark > tr > th,
.table > thead.bg-primary > tr > th {
    background-color: #f8f9fa !important;
    color: #495057 !important;
    font-weight: 600 !important;
    font-size: 0.78rem !important;
    letter-spacing: 0.7px !important;
    text-transform: uppercase !important;
    border-color: var(--border-color) !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 14px 16px !important;
}
/* Row spacing + subtle dividers */
.table > tbody > tr > td {
    padding: 14px 16px !important;
    vertical-align: middle !important;
    color: var(--brand-black) !important;
    border-color: #f1f3f5 !important;
}
/* Hover state */
.table-hover > tbody > tr:hover > td {
    background-color: #fff5f6 !important;
}

/* ── Background utility classes used as accents across pages ──────────── */
.bg-primary {
    background-color: var(--brand-red) !important;
}
.bg-primary.text-white,
.bg-primary > .text-white {
    color: #fff !important;
}

/* Cards / card-header with bg-primary should use brand red */
.card-header.bg-primary {
    background-color: var(--brand-red) !important;
    color: #fff !important;
    border-bottom-color: var(--brand-red-dark);
}

/* ── Links ─────────────────────────────────────────────────────────────
   In legacy views, links to entities often use Bootstrap's default
   blue (#0d6efd). Re-tint the most common patterns to brand black with
   red hover so they no longer pop blue against the new theme. */
.table a:not(.btn),
.table-hover a:not(.btn) {
    color: var(--brand-black);
    text-decoration: none;
}
.table a:not(.btn):hover,
.table-hover a:not(.btn):hover {
    color: var(--brand-red);
    text-decoration: underline;
}

/* ── Badges (Status pills) ─────────────────────────────────────────────
   Leave bg-success / bg-info / bg-warning intact (Bootstrap defaults look
   fine on most pages). Only override bg-primary badges. */
.badge.bg-primary {
    background-color: var(--brand-red) !important;
}

/* ── Form focus state ──────────────────────────────────────────────────
   Match the brand accent for input focus so forms feel consistent with the
   logged-out (login) experience. */
.form-control:focus,
.form-select:focus {
    border-color: var(--brand-red);
    box-shadow: 0 0 0 0.25rem rgba(230, 57, 70, 0.15);
}

/* Search inputs in grid filters often have a pill shape — keep their bg
   white so they don't pick up the new body background tint. */
input.form-control[type="search"],
input.form-control[placeholder="Search..." i] {
    background-color: #fff;
}

/* ═════════════════════════════════════════════════════════════════════
   Light sidebar — switch admin/partner shell from dark navy/teal to a
   clean white-with-red-accent surface that matches the public portal.
   Overrides apply to every role (.theme-admin / .theme-partner / etc.)
   by re-declaring the same CSS variables site.css uses.
   ═════════════════════════════════════════════════════════════════════ */
/* Note the actual body classes are .role-admin / .role-partner (set in
   _Layout.cshtml from `roleClass`). Need higher specificity than the
   site.css partner block (`body.role-partner`), so we re-declare for both. */
:root,
body,
body.role-admin,
body.role-partner,
[data-theme="dark"] body.role-partner {
    --bg-app:              #f8f9fa;
    --bg-body:             #f8f9fa;
    --bg-card:             #ffffff;
    --bg-sidebar:          #ffffff !important;
    --bg-sidebar-hover:    var(--brand-red-light);
    --bg-sidebar-active:   var(--brand-red-light);
    --bg-topbar:           #ffffff;
    --text-primary:        var(--brand-black);
    --text-secondary:      #6c757d;
    --text-sidebar:        #495057;
    --text-topbar:         var(--brand-black);
    --border-color:        #e9ecef;
    --color-primary:       var(--brand-red);
    --color-primary-dark:  var(--brand-red-dark);
    --color-primary-light: var(--brand-red);
    --color-primary-rgb:   230,57,70;
    --color-accent:        var(--brand-red);
    --color-accent-light:  var(--brand-red);
    --color-accent-dark:   var(--brand-red-dark);
    --bg-table-header:     var(--brand-black);
}

/* Sidebar background + border (white with right edge divider) */
.sidebar {
    background: var(--bg-sidebar) !important;
    color: var(--text-sidebar) !important;
    border-right: 1px solid var(--border-color);
    box-shadow: 0 0 0 transparent;
}

/* Sidebar brand bar */
.sidebar-brand {
    color: var(--brand-black) !important;
    border-bottom: 1px solid var(--border-color) !important;
    background: #fff;
}
.sidebar-brand .brand-icon,
.sidebar-brand .brand-text {
    color: var(--brand-red) !important;
    filter: none !important;
}

/* Sidebar group titles (ADMINISTRATION, SERVICE, etc.) */
.sidebar-group-title {
    color: var(--text-secondary) !important;
    font-weight: 600;
    letter-spacing: 0.6px;
}

/* Sidebar items */
.sidebar-item,
.sidebar-item:visited {
    color: var(--text-sidebar) !important;
    border-radius: 8px;
}
.sidebar-item:hover {
    background: var(--bg-sidebar-hover) !important;
    color: var(--brand-red) !important;
}
.sidebar-item.active {
    background: var(--brand-red) !important;
    color: #fff !important;
    font-weight: 600;
}
.sidebar-item.active i {
    color: #fff !important;
}
.sidebar-item i {
    color: var(--text-secondary);
}

/* Sub-menu toggle chevrons */
.sidebar-toggle-sub::after {
    color: var(--text-secondary);
}

/* Scrollbar inside white sidebar — light track */
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.12) !important;
}

/* App body background — light, not pure white, so cards pop */
body,
body.theme-admin,
body.theme-partner {
    background: var(--bg-app) !important;
    color: var(--text-primary);
}

/* Top bar (above main content) */
.topbar,
.app-topbar,
.navbar-top {
    background: #fff !important;
    border-bottom: 1px solid var(--border-color);
}

/* ── Generic admin/partner page cards — white with soft shadow ──── */
.card {
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--brand-black);
}
/* Coloured card headers (bg-info / bg-warning / bg-success / bg-dark)
   used by Repair Details Step cards — soften so they don't fight the red. */
.card-header.bg-dark { background: var(--brand-black) !important; }
.card-header.bg-warning { background: #f0a020 !important; color: #fff !important; }
.card-header.bg-info { background: #0aa3b8 !important; color: #fff !important; }
.card-header.bg-success { background: #198754 !important; color: #fff !important; }

/* ── Page header utility (icon + title + subtitle + action button) ──── */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.page-head .ph-title {
    display: flex; align-items: center; gap: 14px;
}
.page-head .ph-title .ph-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: #fdecec;
    color: var(--brand-red);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.page-head .ph-title h3 {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--brand-black);
    line-height: 1.2;
}
.page-head .ph-title .ph-sub {
    color: #6c757d;
    font-size: 0.88rem;
    margin-top: 2px;
}

/* ── Grid card with search bar + record counter (toolbar pattern) ────── */
.grid-card {
    border-radius: 14px;
    border: 1px solid #f0f1f3;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    background: #fff;
}
.grid-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f3f5;
}
.grid-toolbar .search-pill {
    position: relative;
    flex: 0 1 320px;
    max-width: 360px;
}
.grid-toolbar .search-pill input {
    width: 100%;
    border: 1px solid #e9ecef;
    border-radius: 999px;
    padding: 9px 14px 9px 38px;
    font-size: 0.9rem;
    background: #fff;
    transition: all 0.2s;
}
.grid-toolbar .search-pill input:focus {
    outline: none;
    border-color: var(--brand-red);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.12);
}
.grid-toolbar .search-pill::before {
    content: '\F52A';
    font-family: 'bootstrap-icons';
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: #adb5bd;
    font-size: 0.95rem;
    pointer-events: none;
}
.grid-toolbar .grid-counter {
    color: #6c757d;
    font-size: 0.85rem;
    white-space: nowrap;
}
.grid-toolbar .grid-counter strong { color: var(--brand-black); font-weight: 600; }

/* ── Status pill — green dot + soft green bg ─────────────────────────── */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    border: 1px solid transparent;
}
.status-pill::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    display: inline-block;
}
.status-pill.active   { background: #d4f4dd; color: #0f5132; border-color: #b6e6c4; }
.status-pill.active::before   { background: #198754; }
.status-pill.inactive { background: #f8d7da; color: #842029; border-color: #f1aeb5; }
.status-pill.inactive::before { background: #dc3545; }
.status-pill.pending  { background: #fff3cd; color: #664d03; border-color: #ffe69c; }
.status-pill.pending::before  { background: #f0a020; }

/* ── Brand-outline action button (Rights / Edit / View etc.) ───────── */
.btn-brand-outline {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1.5px solid var(--brand-red);
    color: var(--brand-red);
    background: #fff;
    border-radius: 8px;
    padding: 6px 14px;
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.2s;
}
.btn-brand-outline:hover {
    background: var(--brand-red);
    color: #fff;
    border-color: var(--brand-red);
}
.btn-brand-outline i { font-size: 0.95rem; }

/* Card flush table — remove redundant card-body padding around tables */
.grid-card .table { margin-bottom: 0; }
.grid-card .table thead tr th:first-child,
.grid-card .table tbody tr td:first-child { padding-left: 20px !important; }
.grid-card .table thead tr th:last-child,
.grid-card .table tbody tr td:last-child  { padding-right: 20px !important; }

/* Sort icon for column headers — add a class .sortable on any th */
.table > thead > tr > th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 28px !important;
}
.table > thead > tr > th.sortable::after {
    content: '';
    position: absolute;
    right: 14px; top: 50%;
    width: 8px; height: 12px;
    background:
        linear-gradient(to bottom,
            transparent 0%, transparent 30%,
            #adb5bd 30%, #adb5bd 35%,
            transparent 35%, transparent 65%,
            #adb5bd 65%, #adb5bd 70%,
            transparent 70%);
    transform: translateY(-50%);
    opacity: 0.7;
}

/* ═══════════════════════════════════════════════════════════════════════
   AUTO-UPGRADE legacy page patterns so every existing Index page picks up
   the new look WITHOUT having to edit each .cshtml file individually.

   The legacy pattern across the app is:
     <div class="d-flex justify-content-between align-items-center mb-3">
         <h3><i class="bi bi-xxx me-2"></i>Page Title</h3>
         <a class="btn btn-primary">Action</a>
     </div>
     <div class="card">
         <div class="card-body">
             <table class="table ...">
   This block restyles those without touching the HTML.
   ═══════════════════════════════════════════════════════════════════════ */

/* H3 page titles inside main content — render as Poppins heading.
   The leading bootstrap-icon gets re-rendered as a red icon tile. */
.page-content > h3,
.page-content > .d-flex > h3,
main > h3,
main > .d-flex > h3,
main > section h3:first-of-type {
    font-family: 'Poppins', sans-serif !important;
    font-weight: 700 !important;
    font-size: 1.5rem !important;
    color: var(--brand-black) !important;
    display: flex !important;
    align-items: center !important;
    gap: 0 !important;
    line-height: 1.2;
    margin-bottom: 0;
}
/* Convert the leading icon into a tile (44x44 red badge) */
.page-content h3 > i.bi:first-child,
main h3 > i.bi:first-child {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    background: #fdecec;
    color: var(--brand-red);
    border-radius: 12px;
    font-size: 1.3rem !important;
    margin-right: 14px !important;
    flex-shrink: 0;
}

/* All cards in main content: rounded + soft border + subtle shadow */
.page-content .card,
main .card {
    border-radius: 14px;
    border: 1px solid #f0f1f3;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    overflow: hidden;
}
/* Only when card-body wraps a table directly, drop its padding so the table
   sits flush against the card edges (mock-pattern). Cards with other
   content (forms, lists, free text) keep their normal padding. */
.page-content .card > .card-body:has(> .table:only-child),
main .card > .card-body:has(> .table:only-child) {
    padding: 0;
}
.page-content .card > .card-body > .table:only-child,
main .card > .card-body > .table:only-child {
    margin-bottom: 0;
}
.page-content .card > .card-body > .table:only-child > thead > tr > th:first-child,
.page-content .card > .card-body > .table:only-child > tbody > tr > td:first-child,
main .card > .card-body > .table:only-child > thead > tr > th:first-child,
main .card > .card-body > .table:only-child > tbody > tr > td:first-child { padding-left: 20px !important; }
.page-content .card > .card-body > .table:only-child > thead > tr > th:last-child,
.page-content .card > .card-body > .table:only-child > tbody > tr > td:last-child,
main .card > .card-body > .table:only-child > thead > tr > th:last-child,
main .card > .card-body > .table:only-child > tbody > tr > td:last-child { padding-right: 20px !important; }

/* Coloured card-header bars (used on master pages, repair details, etc.)
   — the legacy palette uses bg-dark/bg-secondary which look ugly against
   the new brand red. Repaint them as soft brand-tinted headers. */
.card-header.bg-dark,
.card-header.bg-secondary {
    background-color: #f8f9fa !important;
    color: var(--brand-black) !important;
    border-bottom: 1px solid var(--border-color) !important;
    font-weight: 600 !important;
    padding: 14px 20px !important;
    font-size: 0.92rem !important;
}
.card-header.bg-dark .text-white,
.card-header.bg-secondary .text-white,
.card-header.bg-dark .btn-close-white,
.card-header.bg-secondary .btn-close-white {
    color: var(--brand-black) !important;
    filter: none !important;
}
/* Icons inside repainted headers get the brand red */
.card-header.bg-dark > i.bi,
.card-header.bg-dark span > i.bi,
.card-header.bg-secondary > i.bi,
.card-header.bg-secondary span > i.bi {
    color: var(--brand-red) !important;
}

/* btn-outline-secondary (pencil edit / view buttons in tables) — re-tint
   to brand red so it visually aligns with the rest of the action set. */
.btn-outline-secondary,
.btn.btn-outline-secondary {
    border-color: #e9ecef !important;
    color: #495057 !important;
    background: #fff !important;
    border-radius: 8px !important;
}
.btn-outline-secondary:hover,
.btn.btn-outline-secondary:hover {
    background: var(--brand-red-light) !important;
    border-color: var(--brand-red) !important;
    color: var(--brand-red) !important;
}
.btn-outline-secondary i { transition: color 0.2s; }
.btn-outline-secondary:hover i { color: var(--brand-red) !important; }

/* Auto-upgrade Bootstrap badges into status pills.
   Only applied when the badge is a status indicator next to text (i.e. only
   bg-success / bg-danger / bg-warning / bg-info / bg-secondary on .badge). */
.badge.bg-success,
.badge.bg-danger,
.badge.bg-warning,
.badge.bg-info,
.badge.bg-secondary {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 5px 14px !important;
    border-radius: 999px !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    border: 1px solid transparent !important;
}
.badge.bg-success::before,
.badge.bg-danger::before,
.badge.bg-warning::before,
.badge.bg-info::before,
.badge.bg-secondary::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.badge.bg-success { background: #d4f4dd !important; color: #0f5132 !important; border-color: #b6e6c4 !important; }
.badge.bg-success::before { background: #198754; }
.badge.bg-danger  { background: #f8d7da !important; color: #842029 !important; border-color: #f1aeb5 !important; }
.badge.bg-danger::before  { background: #dc3545; }
.badge.bg-warning { background: #fff3cd !important; color: #664d03 !important; border-color: #ffe69c !important; }
.badge.bg-warning::before { background: #f0a020; }
.badge.bg-info    { background: #cff4fc !important; color: #055160 !important; border-color: #9eeaf9 !important; }
.badge.bg-info::before    { background: #0aa3b8; }
.badge.bg-secondary { background: #e9ecef !important; color: #495057 !important; border-color: #dee2e6 !important; }
.badge.bg-secondary::before { background: #6c757d; }

/* Auto-restyle btn-outline-warning (used for "Rights" / "Edit" type
   actions) to the brand red outline button so it matches the mockup. */
.btn-outline-warning,
.btn.btn-outline-warning {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    border: 1.5px solid var(--brand-red) !important;
    color: var(--brand-red) !important;
    background: #fff !important;
    border-radius: 8px !important;
    padding: 6px 14px !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
}
.btn-outline-warning:hover,
.btn.btn-outline-warning:hover {
    background: var(--brand-red) !important;
    color: #fff !important;
    border-color: var(--brand-red) !important;
}

/* Page-level breadcrumb / route trail — already styled in site.css; tweak
   to match the new palette (red accent on the current segment). */
.breadcrumb-item.active,
.breadcrumb-item a { color: var(--brand-red) !important; }

/* Footer styling — make sure it sits on light bg with muted text */
.page-footer {
    text-align: center;
    padding: 16px 24px;
    color: #6c757d;
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    background: #fff;
}
