/**
 * AI Legal System - Admin Dashboard Styles
 */

:root {
    /* Premium Legal palette */
    --primary-color: #121212;          /* brand dark */
    --primary-dark: #000000;
    --primary-light: rgba(18, 18, 18, 0.10);
    --primary-lighter: rgba(18, 18, 18, 0.05);
    --secondary-color: #e6bf46;         /* brand gold */
    --secondary-dark: #c9a02f;
    --secondary-light: rgba(230, 191, 70, 0.12);
    --accent-color: #e6bf46;            /* gold accent line */
    --success-color: #168058;
    --danger-color: #c03548;
    --warning-color: #d99528;
    --info-color: #0e7490;
    --light-color: #f6f4ef;             /* warm off-white */
    --dark-color: #1f2937;
    --sidebar-width: 250px;
    --navbar-height: 60px;
    --gradient-primary: linear-gradient(135deg, #121212 0%, #2a2a2a 100%);
    --gradient-secondary: linear-gradient(135deg, #e6bf46 0%, #d4a933 100%);
    --gradient-sidebar: linear-gradient(180deg, #121212 0%, #121212 100%);

    /* Premium design tokens */
    --radius: 8px;
    --radius-sm: 5px;
    --radius-lg: 12px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.03);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 0 0 1px rgba(15, 23, 42, 0.02);
    --shadow-md: 0 6px 16px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.03);
    --shadow-lg: 0 18px 38px rgba(15, 23, 42, 0.10), 0 4px 8px rgba(15, 23, 42, 0.04);
    --shadow-gold: 0 4px 14px rgba(230, 191, 70, 0.25);
    --border-color: #e8e3d8;            /* warm hairline */
    --border-color-strong: #d4cdb9;
    --surface: #ffffff;
    --surface-muted: #faf8f4;           /* parchment-like */
    --surface-canvas: #f4f1ea;          /* page background */
    --text-primary: #1a1f2e;
    --text-secondary: #4a5163;
    --text-tertiary: #7a8194;

    /* Premium serif for headings (LTR). Arabic stays Cairo. */
    --font-serif: 'Iowan Old Style', 'Apple Garamond', Baskerville, 'Libre Caslon Text', 'Times New Roman', Georgia, serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--surface-canvas);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
    letter-spacing: -0.005em;
}

/* Subtle parchment texture (very faint) via gradient overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 15% 20%, rgba(230, 191, 70, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 85% 80%, rgba(18, 18, 18, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}
body > * { position: relative; z-index: 1; }

/* Preloader */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Navbar */
.navbar {
    height: var(--navbar-height);
    background: var(--gradient-sidebar) !important;
    padding: 0 1.5rem;
    z-index: 1030;
    box-shadow: 0 1px 0 rgba(230, 191, 70, 0.25), 0 4px 14px rgba(0, 0, 0, 0.20);
    border-bottom: 1px solid rgba(230, 191, 70, 0.20);
}

.navbar-brand {
    color: #fff !important;
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.3px;
}
.navbar-brand i {
    color: var(--accent-color) !important;
    font-style: normal;
    margin-inline-end: 0.5rem;
}

.navbar-brand i {
    color: var(--accent-color);
}

/* Brand logo (emblem) in the navbar */
.navbar-brand {
    display: inline-flex;
    align-items: center;
}
.navbar-logo {
    height: 38px;
    width: auto;
    margin-inline-end: 0.6rem;
    /* Emblem is gold-on-transparent — sits well on the dark navbar */
}

/* Brand logo at the top of the sidebar */
.sidebar-brand {
    display: block;
    text-align: center;
    padding: 6px 0 12px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(230, 191, 70, 0.20);
}
.sidebar-brand-logo {
    height: 64px;
    width: auto;
    max-width: 90%;
}

.sidebar-toggle {
    font-size: 1.25rem;
    padding: 0.5rem;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--navbar-height));
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    box-shadow: 1px 0 0 rgba(15, 23, 42, 0.03);
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 1020;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 24px 20px 22px;
    background: var(--gradient-primary);
    color: #fff;
    text-align: center;
    position: relative;
}

.sidebar-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 12%;
    right: 12%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
}

.admin-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid rgba(230, 191, 70, 0.4);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08);
    margin-bottom: 10px;
    object-fit: cover;
}

.admin-name {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: 0.2px;
}

.admin-role {
    font-size: 0.7rem;
    opacity: 0.85;
    background: rgba(230, 191, 70, 0.18);
    color: var(--accent-color);
    display: inline-block;
    padding: 3px 12px;
    border-radius: 12px;
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.sidebar-nav {
    padding: 12px 0 24px;
}

.sidebar-nav .nav-section {

    padding: 9px 20px;
    margin-top: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    /* background: rgb(125 121 111); */
    color: #121212;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(230, 191, 70, 0.35);


}
.sidebar-nav .nav-section:first-child { margin-top: 0; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    margin: 1px 0px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s, padding-left 0.15s;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
}

.sidebar-nav .nav-link:hover {
    background: var(--primary-lighter);
    color: var(--primary-color);
}

.sidebar-nav .nav-link.active {
    background: var(--primary-color);
    color: #fff;
    font-weight: 600;
    box-shadow: var(--shadow-sm), inset 3px 0 0 var(--accent-color);
}

.sidebar-nav .nav-link.active i { color: var(--accent-color); }

/* Logout — always red */
.sidebar-nav .nav-link.logout-link,
.sidebar-nav .nav-link.logout-link i { color: var(--danger-color); }
.sidebar-nav .nav-link.logout-link:hover {
    background: rgba(220, 53, 69, 0.10);
    color: var(--danger-color);
}

/* Phone numbers are always LTR, regardless of page language (RTL or LTR). */
input[type="tel"],
input[name="phone"], input[name="whatsapp"], input[name="mobile"],
input[name="phone_ar"], .phone-ltr {
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: embed;
}

.sidebar-nav .nav-link i {
    width: 20px;
    margin-right: 12px;
    font-size: 0.88rem;
    text-align: center;
    opacity: 0.85;
}

/* Sidebar count badge — small pill on the trailing edge */
.sidebar-nav .nav-link {
    justify-content: flex-start;
}
.sidebar-nav .nav-link .sidebar-badge {
    margin-inline-start: auto;       /* push to trailing edge */
    background: var(--secondary-color);
    color: #fff;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1;
    padding: 3px 7px;
    border-radius: 999px;
    min-width: 20px;
    text-align: center;
    letter-spacing: 0.2px;
    box-shadow: 0 1px 2px rgba(230, 191, 70, 0.30);
}
.sidebar-nav .nav-link.active .sidebar-badge {
    background: var(--accent-color);
    color: var(--primary-dark);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.sidebar-nav .nav-link:hover .sidebar-badge {
    transform: scale(1.05);
    transition: transform 0.15s ease;
}

[dir="rtl"] .sidebar-nav .nav-link i {
    margin-right: 0;
    margin-left: 12px;
}

.sidebar-nav .nav-link i {
    width: 22px;
    margin-right: 10px;
    font-size: 0.9rem;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--navbar-height);
    padding: 25px;
    min-height: calc(100vh - var(--navbar-height));
    transition: margin-left 0.3s ease;
}

.main-content.expanded {
    margin-left: 0;
}

/* Page Header */
.page-header {
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.page-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 48px;
    height: 2px;
    background: var(--secondary-color);
}

.page-title {
    font-family: var(--font-serif);
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 6px;
    letter-spacing: -0.015em;
    line-height: 1.2;
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 0.82rem;
}

.breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.15s;
}

.breadcrumb-item a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--text-tertiary);
}

/* Cards */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    margin-bottom: 24px;
    background: var(--surface);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 22px;
    font-weight: 600;
    color: var(--primary-dark);
    border-radius: var(--radius) var(--radius) 0 0 !important;
    font-size: 0.92rem;
    letter-spacing: 0.1px;
}

.card-header i {
    color: var(--secondary-color);
    margin-inline-end: 0.5rem;
}

.card-body {
    padding: 22px;
}

/* Stat Cards — flat with gold accent line, premium feel */
.stat-card {
    border-radius: var(--radius);
    padding: 22px 24px 20px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    /* Fill the column so all cards in a row share the tallest card's height */
    height: 100%;
}

/* Dashboard stat grid — every card identical height, even across rows */
.stats-grid .stat-card {
    min-height: 130px;
    height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--secondary-color);
}

/* Notes history timeline (client view) */
.timeline-notes { position: relative; margin: 0; padding: 0; }
.timeline-notes .tn-item {
    position: relative;
    padding-inline-start: 22px;
    padding-bottom: 16px;
}
.timeline-notes .tn-item::before {
    content: '';
    position: absolute;
    inset-inline-start: 5px;
    top: 4px;
    bottom: -4px;
    width: 2px;
    background: var(--border-color);
}
.timeline-notes .tn-item:last-child::before { display: none; }
.timeline-notes .tn-dot {
    position: absolute;
    inset-inline-start: 0;
    top: 3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--secondary-color);
    border: 2px solid var(--surface);
}
.timeline-notes .tn-body { line-height: 1.45; }

/* Gold accent line at the top */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--secondary-color);
    opacity: 0.35;
    transition: opacity 0.2s ease;
}
.stat-card:hover::before {
    opacity: 1;
}

/* Color variants — now control the accent line + icon color, not whole bg */
.stat-card.primary::before    { background: var(--primary-color); }
.stat-card.secondary::before  { background: var(--secondary-color); }
.stat-card.success::before    { background: var(--success-color); }
.stat-card.info::before       { background: var(--info-color); }
.stat-card.warning::before    { background: var(--warning-color); }
.stat-card.danger::before     { background: var(--danger-color); }
.stat-card.dark::before       { background: var(--primary-dark); }

.stat-card.primary   .stat-icon { color: var(--primary-color); }
.stat-card.secondary .stat-icon { color: var(--secondary-color); }
.stat-card.success   .stat-icon { color: var(--success-color); }
.stat-card.info      .stat-icon { color: var(--info-color); }
.stat-card.warning   .stat-icon { color: var(--warning-color); }
.stat-card.danger    .stat-icon { color: var(--danger-color); }
.stat-card.dark      .stat-icon { color: var(--primary-dark); }

.stat-icon {
    font-size: 1.6rem;
    opacity: 0.18;
    position: absolute;
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.stat-card:hover .stat-icon {
    opacity: 0.35;
    transform: translateY(-50%) scale(1.1);
}

.stat-value {
    font-family: var(--font-serif);
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 2px;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

/* RTL: gold accent on left instead of right for stat icon */
[dir="rtl"] .stat-icon { right: auto; left: 22px; }

/* Tables */
.table {
    margin-bottom: 0;
    color: var(--text-primary);
}

.table thead th {
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border-color);
    border-top: none;
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-tertiary);
    padding: 12px 16px;
    text-align: start;          /* follows LTR/RTL direction */
    vertical-align: middle;
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-color: var(--border-color);
    text-align: start;          /* match the header alignment */
    font-size: 0.88rem;
}

/* Actions column always sits at the trailing edge */
.table thead th:last-child,
.table tbody td:last-child {
    text-align: end;
}

/* RTL: mirror directional arrow/chevron icons (back, next, prev) so they point
   the correct way. FontAwesome glyphs are LTR by design; flip them under RTL. */
[dir="rtl"] i.fa-arrow-left,
[dir="rtl"] i.fa-arrow-right,
[dir="rtl"] i.fa-long-arrow-alt-left,
[dir="rtl"] i.fa-long-arrow-alt-right,
[dir="rtl"] i.fa-chevron-left,
[dir="rtl"] i.fa-chevron-right,
[dir="rtl"] i.fa-angle-left,
[dir="rtl"] i.fa-angle-right,
[dir="rtl"] i.fa-arrow-circle-left,
[dir="rtl"] i.fa-arrow-circle-right,
[dir="rtl"] i.fa-paper-plane {
    transform: scaleX(-1);
}

/* RTL: align all table cells to the start (right). Includes tfoot (totals row)
   so footer cells line up with the body — DataTables forces thead/tfoot to left. */
[dir="rtl"] .table thead th,
[dir="rtl"] .table tfoot th,
[dir="rtl"] .table tbody td {
    text-align: right;
}
/* Only the LAST column of LIST tables (DataTables — holds the actions/buttons)
   flips to the opposite side. This must NOT apply to plain detail/form tables
   (e.g. .table-form on view pages), whose last cell is a data value. */
[dir="rtl"] table.dataTable thead th:last-child,
[dir="rtl"] table.dataTable tbody td:last-child {
    text-align: left;
}

/* LTR mirror of the same. */
[dir="ltr"] .table thead th,
[dir="ltr"] .table tfoot th,
[dir="ltr"] .table tbody td {
    text-align: left;
}
[dir="ltr"] table.dataTable thead th:last-child,
[dir="ltr"] table.dataTable tbody td:last-child {
    text-align: right;
}

/* Inline content inside cells (badges, buttons, links) should align with the cell */
.table tbody td .badge,
.table tbody td .btn-group,
.table tbody td > .btn {
    vertical-align: middle;
}

.table-hover tbody tr {
    transition: background-color 0.15s ease;
}
.table-hover tbody tr:hover {
    background-color: var(--surface-muted);
}

.table tbody tr {
    border-bottom: 1px solid var(--border-color);
}


/* Refined links inside tables */
.table tbody td a:not(.btn) {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}
/* <a>-based action buttons keep their Bootstrap button colors — without this the
   rule above painted a dark icon on the dark btn-primary (invisible edit icon). */
.table tbody td a.btn-primary,
.table tbody td a.btn-danger,
.table tbody td a.btn-info,
.table tbody td a.btn-success { color: #fff; }
.table tbody td a:not(.btn):hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* DataTables sort icons should appear right after the header text, not float */
table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:after {
    margin-inline-start: 6px;
}

/* Force action buttons in single row (listing tables only — form-table cells
   must wrap their hint text, see .table-form override below) */
.table tbody td:last-child {
    white-space: nowrap;
    min-width: fit-content;
}
.table tbody td .btn-group {
    flex-wrap: nowrap;
    display: inline-flex;
    box-shadow: var(--shadow-xs);
    border-radius: 0;
    overflow: hidden;
}
.table tbody td .btn-group .btn {
    border-radius: 0;
    box-shadow: none;
    padding: 5px 9px;
    font-size: 0.78rem;
}
.table tbody td .btn-group .btn:first-child { border-radius: 0; }
.table tbody td .btn-group .btn:last-child  { border-radius: 0; }
.table tbody td > .btn {
    padding: 5px 9px;
    font-size: 0.78rem;
    border-radius: 0;
}
.table tbody td > a.btn,
.table tbody td > button.btn {
    margin-right: 2px;
    margin-bottom: 0;
    vertical-align: middle;
    display: inline-block;
}

/* Buttons */
.btn {
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    font-weight: 600;
    font-size: 0.86rem;
    letter-spacing: 0.1px;
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s, color 0.15s;
    box-shadow: var(--shadow-xs);
    border-width: 1px;
}

/* Icon-only buttons (.btn-icon class is added by function.js to any button
   whose only content is an <i> element). Square aspect, icon centered. */
.btn-icon,
.table tbody td > .btn.btn-icon,
.table tbody td > a.btn.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    aspect-ratio: 1 / 1;
    line-height: 1;
}
.btn-icon.btn-sm,
.table tbody td > .btn-icon.btn-sm {
    padding: 0 8px;
}
.btn-icon.btn-lg {
    padding: 0 14px;
}
.btn-icon > i {
    margin: 0;
}

.btn:focus, .btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(18, 18, 18, 0.18);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(18, 18, 18, 0.25);
}

.btn-secondary {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: #fff;
}

.btn-secondary:hover {
    background: var(--secondary-dark);
    border-color: var(--secondary-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-gold);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--border-color-strong);
    background: var(--surface);
}

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

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-color-strong);
    background: var(--surface);
}

.btn-outline-secondary:hover {
    background: var(--surface-muted);
    color: var(--primary-color);
    border-color: var(--secondary-color);
}

.btn-group-sm .btn,
.btn-sm {
    padding: 5px 12px;
    font-size: 0.78rem;
}

/* =============================================
   FORMS — Professional Legal Style
   ============================================= */

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color-strong);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
    background-color: var(--surface);
    color: var(--text-primary);
    line-height: 1.5;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(18, 18, 18, 0.10);
    background-color: var(--surface);
}

/* Reserve room for the dropdown arrow so it never overlaps the text.
   inline-end = right in LTR / left in RTL, matching Bootstrap's arrow side. */
.form-select { padding-inline-end: 2.5rem; }
.form-select-sm { padding-inline-end: 2rem; }

.form-control:hover, .form-select:hover {
    border-color: var(--text-tertiary);
}

.form-control::placeholder {
    color: #b8b8b8;
    font-size: 0.88rem;
    font-style: italic;
}

.form-label {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 7px;
    font-size: 0.83rem;
    letter-spacing: 0;
}

.form-label .text-danger {
    font-size: 0.9em;
}

/* Form section dividers */
.form-section {
    background: linear-gradient(135deg, #f8f9fa, #eef1f5);
    border: 1px solid #e2e6ea;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.form-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary-color);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section-title i {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Compact row spacing */
.modal-body .row {
    margin-bottom: 2px;
}

.modal-body .mb-3 {
    margin-bottom: 14px !important;
}

/* RTL form fields */
.form-control[dir="rtl"], input[dir="rtl"] {
    text-align: right;
    font-family: "Noto Naskh Arabic", "Tahoma", sans-serif;
}

/* Form footer with actions */
.modal-body hr {
    margin: 20px 0 16px 0;
    border-color: #e2e6ea;
}

.modal-body .text-end .btn {
    min-width: 100px;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 8px 20px;
}

/* Textarea */
textarea.form-control {
    line-height: 1.6;
}

/* Input group */
.input-group-text {
    background: #f8f9fa;
    border-color: #ccd0d5;
    color: #666;
    font-size: 0.85rem;
}

/* Checkbox & switch */
.form-check-label {
    font-size: 0.88rem;
    color: #555;
    cursor: pointer;
}

/* Select2 inside modals */
.modal .select2-container .select2-selection {
    min-height: 36px;
    border-color: var(--border-color-strong);
    border-radius: var(--radius-sm);
}

.modal .select2-container--focus .select2-selection {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(26, 82, 118, 0.1);
}

.select2-container .select2-selection {
    border-radius: var(--radius-sm) !important;
}

/* Match select2 single-select height to the project's taller form controls (10px
   vertical padding → ~44px), so select2 lines up with form-select/form-control in
   filter bars and forms instead of rendering shorter. */
.select2-container--bootstrap-5 .select2-selection--single {
    min-height: 44px !important;
    display: flex;
    align-items: center;
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 1.5;
    padding-top: 0;
    padding-bottom: 0;
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: 100%;
}

.select2-container--bootstrap-5 .select2-dropdown {
    border-radius: var(--radius-sm) !important;
    border-color: var(--border-color-strong) !important;
    box-shadow: var(--shadow-md);
}

/* Form info/help text */
.form-text, small.text-muted {
    font-size: 0.78rem;
}

/* Alert in forms */
.modal-body .alert {
    font-size: 0.85rem;
    padding: 10px 14px;
    border-radius: 6px;
}

/* Disabled/readonly */
.form-control:disabled, .form-control[readonly] {
    background: #f5f6f8;
    color: #888;
}

/* =============================================
   TABLE-BASED FORMS
   ============================================= */
.table-form {
    margin-bottom: 16px;
    font-size: 0.88rem;
    border-color: var(--border-color);
    table-layout: fixed;
    width: 100%;
    word-wrap: break-word;
}
.table-form td {
    padding: 8px 12px;
    vertical-align: middle;
    border-color: var(--border-color);
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
    white-space: normal;   /* listing tables set td nowrap globally — form hints must wrap, not clip */
}
/* Must out-specify `.table tbody td:last-child { nowrap }` — a form row's value
   cell is usually the last child and its hint text has to wrap, not clip. */
.table-form tbody td:last-child {
    white-space: normal;
}
.table-form .form-lbl {
    background: var(--surface-muted);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.82rem;
    letter-spacing: 0;
    white-space: normal;
    word-break: break-word;
    width: 18%;
    min-width: 110px;
}
.table-form .form-lbl .text-danger {
    font-size: 0.85em;
}
.table-form .form-control-sm,
.table-form .form-select-sm {
    font-size: 0.88rem;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    width: 100%;
    max-width: 100%;
}
/* Keep arrow clearance on modal-form selects (higher specificity than the base rule) */
.table-form .form-select-sm { padding-inline-end: 2rem; }
.table-form .form-control-sm:focus,
.table-form .form-select-sm:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(26, 82, 118, 0.1);
}
.table-form textarea.form-control-sm {
    line-height: 1.5;
    resize: vertical;     /* never let drag-resize push past the cell/modal width */
    max-height: 45vh;     /* cap height so a long textarea can't outgrow the popup */
    overflow-y: auto;
}
.table-form .form-check-input {
    cursor: pointer;
}

/* Inline risk-level selector (Compliance → KYC table) — compact color-coded pill */
.risk-select {
    width: auto;
    min-width: 92px;
    display: inline-block;
    font-weight: 600;
    font-size: 0.76rem;
    line-height: 1.4;
    padding: 3px 28px 3px 12px;
    border-radius: 999px;
    cursor: pointer;
}
.risk-select.risk-low {
    color: #0f7d4d;
    background-color: #e8f7ef;
    border-color: #a7e0c4;
}
.risk-select.risk-medium {
    color: #9a6700;
    background-color: #fdf6e3;
    border-color: #f0d68a;
}
.risk-select.risk-high {
    color: #c0392b;
    background-color: #fdecea;
    border-color: #f1a9a0;
}
.risk-select:focus {
    box-shadow: 0 0 0 2px rgba(26, 82, 118, 0.12);
    border-color: currentColor;
}
[dir="rtl"] .risk-select {
    padding: 3px 12px 3px 28px;
}

/* Section title for table forms */
.form-section-title {
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--primary-color);
    margin: 22px 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}
.form-section-title:first-child {
    margin-top: 0;
}
.form-section-title i {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Modal */
.modal-header {
    background: var(--surface);
    color: var(--text-primary);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 18px 24px 16px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header .modal-title {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: 0.1px;
}

.modal-header .btn-close {
    opacity: 0.6;
    transition: opacity 0.15s;
}
.modal-header .btn-close:hover { opacity: 1; }

.modal-content {
    border: none;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.modal-body {
    padding: 22px;
    overflow-x: hidden;
}

.modal-footer {
    padding: 14px 22px;
    background: var(--surface-muted);
    border-top: 1px solid var(--border-color);
}

/* Constrain modal dialog so very long forms don't push beyond viewport */
.modal-dialog.modal-dialog-scrollable {
    max-height: calc(100vh - 3rem);
}
.modal-dialog.modal-dialog-scrollable .modal-content {
    max-height: calc(100vh - 3rem);
}

/* In-form action bar (Save/Cancel inside <form>.text-end) — sticks to the bottom of
   the scrollable modal and bleeds symmetrically to the body padding edges (the modal's
   rounded corners + overflow:hidden clip it cleanly in both LTR and RTL). */
.modal-body > form > .text-end:last-child,
.modal-body > .text-end:last-child {
    position: sticky;
    bottom: -22px;
    margin: 18px -22px -22px -22px;
    padding: 14px 22px;
    background: var(--surface-muted);
    border-top: 1px solid var(--border-color);
    z-index: 5;
}
.modal-body > form > .text-end:last-child .btn,
.modal-body > .text-end:last-child .btn {
    min-width: 100px;
}

/* Badges — pill shape with subtle border */
.badge {
    padding: 4px 11px;
    font-weight: 600;
    border-radius: 999px;
    font-size: 0.7rem;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    border: 1px solid transparent;
    /* Fallback so a badge without a recognised bg-* class stays readable
       (Bootstrap defaults badge text to white → invisible on light cards). */
    color: var(--text-secondary);
}

/* Soft pastel backgrounds with the dominant color on text + border */
.badge.bg-primary    { background: #e8eef3 !important; color: var(--primary-color); border-color: rgba(18, 18, 18, 0.20); }
.badge.bg-secondary  { background: #f5efde !important; color: var(--secondary-dark); border-color: rgba(230, 191, 70, 0.30); }
.badge.bg-success    { background: #e3f3eb !important; color: var(--success-color); border-color: rgba(22, 128, 88, 0.25); }
.badge.bg-danger     { background: #fceaed !important; color: var(--danger-color); border-color: rgba(192, 53, 72, 0.25); }
.badge.bg-warning    { background: #fcefd8 !important; color: #8a5a0a !important; border-color: rgba(217, 149, 40, 0.30); }
.badge.bg-info       { background: #d5eef3 !important; color: var(--info-color); border-color: rgba(14, 116, 144, 0.25); }
.badge.bg-light      { background: var(--surface-muted) !important; color: var(--text-secondary); border-color: var(--border-color); }
.badge.bg-dark       { background: #e2e5ec !important; color: var(--primary-dark); border-color: var(--border-color-strong); }

/* Outline badges — transparent fill, coloured text + border */
.badge.bg-outline-secondary { background: transparent !important; color: var(--text-secondary); border-color: var(--border-color-strong); }
.badge.bg-outline-primary   { background: transparent !important; color: var(--primary-color); border-color: rgba(18, 18, 18, 0.35); }

/* Switch Toggle */
.form-switch .form-check-input {
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.form-switch .form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Dropify */
.dropify-wrapper {
    border-radius: var(--radius);
    border: 2px dashed var(--border-color-strong);
    background: var(--surface-muted);
    transition: border-color 0.15s, background-color 0.15s;
}

.dropify-wrapper:hover {
    border-color: var(--primary-color);
    background: var(--primary-lighter);
}

/* DataTables */
.dataTables_wrapper .dataTables_filter input {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color-strong);
    padding: 6px 12px;
    margin-left: 8px;
    font-size: 0.88rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 82, 118, 0.12);
    outline: none;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color-strong);
    padding: 5px 28px 5px 10px;
    font-size: 0.88rem;
}

/* Empty-table state — friendly "no data" placeholder */
.dt-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 34px 16px;
    color: var(--text-tertiary);
}
.dt-empty-state i {
    font-size: 2rem;
    opacity: 0.45;
}
.dt-empty-state span {
    font-size: 0.9rem;
    font-weight: 500;
}

.dataTables_wrapper .dataTables_info {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    padding-top: 12px;
}

/* DataTables pagination (Bootstrap 5 theme) — keep the buttons connected,
   no stray gaps between page numbers. */
.dataTables_wrapper .dataTables_paginate { padding-top: 12px; }
.dataTables_wrapper .pagination { margin-bottom: 0; }

.dataTables_wrapper .pagination .page-link {
    margin: 0 !important;
    padding: 5px 12px !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
    font-size: 0.85rem;
}

.dataTables_wrapper .pagination .page-link:hover {
    background: var(--primary-lighter) !important;
    border-color: var(--border-color) !important;
    color: var(--primary-color) !important;
    z-index: 2;
}

.dataTables_wrapper .pagination .page-item.active .page-link {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #fff !important;
}

.dataTables_wrapper .pagination .page-item.disabled .page-link {
    color: var(--text-tertiary) !important;
    opacity: 0.6;
}

/* Toastr customization */
.toast-success { background-color: var(--success-color) !important; }
.toast-error { background-color: var(--danger-color) !important; }

/* Login Page — Premium Legal */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-sidebar);
    position: relative;
    overflow: hidden;
    padding: 20px;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 800px;
    height: 800px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(230, 191, 70, 0.10) 0%, transparent 60%);
    top: -200px;
    right: -200px;
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(18, 18, 18, 0.3) 0%, transparent 60%);
    bottom: -200px;
    left: -200px;
    pointer-events: none;
}

.login-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 44px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(230, 191, 70, 0.15);
    position: relative;
    overflow: hidden;
}

.login-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 50%, var(--primary-color) 100%);
}

.login-logo {
    text-align: center;
    margin-bottom: 18px;
    font-size: 2.6rem;
    color: var(--secondary-color);
    line-height: 1;
}
.login-logo-img {
    max-width: 300px;
    width: 100%;
    height: auto;
}

.login-title {
    font-family: var(--font-serif);
    text-align: center;
    margin-bottom: 6px;
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 1.55rem;
    letter-spacing: -0.01em;
}

.login-subtitle {
    text-align: center;
    margin-bottom: 28px;
    color: var(--text-tertiary);
    font-size: 0.84rem;
    letter-spacing: 0.2px;
}

.login-box .form-control {
    padding: 11px 14px;
    font-size: 0.92rem;
}

.login-box .btn-primary {
    padding: 11px 16px;
    font-size: 0.92rem;
    background: var(--gradient-primary);
    border: none;
}
.login-box .btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 8px 22px rgba(18, 18, 18, 0.40);
}

/* =============================================
   LAW REFERENCE LINKS & POPUP
   ============================================= */

/* Article reference — clickable with tooltip */
.law-ref-article {
    color: #b8860b;                       /* brand amber/gold (readable on white) */
    cursor: pointer;
    border-bottom: 1px dashed #d4a933;
    transition: all 0.2s;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 500;
}
.law-ref-article:hover {
    background: #faf3dd;
    color: #96690a;
    border-bottom-color: #96690a;
}
.law-ref-loading {
    opacity: 0.6;
    cursor: wait;
}
.law-ref-loading::after {
    content: ' ⏳';
    animation: lawRefBlink 1s infinite;
}
@keyframes lawRefBlink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Full law name — blue highlight only, NOT clickable */
.law-ref-name {
    color: #2a2a2a;
    font-weight: 600;
}

/* Law Popup */
.law-popup {
    position: absolute;
    z-index: 10000;
    width: 500px;
    max-width: 90vw;
    max-height: 70vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.05);
    overflow: hidden;
    animation: lawPopupIn 0.2s ease;
}
.law-popup-rtl {
    direction: rtl;
    text-align: right;
}
@keyframes lawPopupIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.law-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: linear-gradient(135deg, #0d2137, #1a3a5c);
    color: #fff;
}
.law-popup-title {
    font-size: 0.85rem;
    font-weight: 600;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.law-popup-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 0 0 12px;
    line-height: 1;
    opacity: 0.7;
}
.law-popup-close:hover { opacity: 1; }
.law-popup-body {
    padding: 16px 18px;
    overflow-y: auto;
    max-height: 55vh;
    font-size: 0.88rem;
    line-height: 1.8;
}
.law-popup-body .ai-heading {
    margin-top: 10px;
    font-size: 0.95rem;
}

/* Recent items widget */
.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.recent-item:last-child {
    border-bottom: none;
}

.recent-item h6 {
    margin: 0;
    font-size: 0.9rem;
}

.recent-item small {
    color: #888;
}

/* Activity Timeline */
.activity-timeline {
    position: relative;
    padding-left: 30px;
}

.activity-timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #eee;
}

.activity-item {
    position: relative;
    padding-bottom: 20px;
}

.activity-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--secondary-color);
}

.activity-item h6 {
    margin: 0;
    font-size: 0.9rem;
}

.activity-item small {
    color: #888;
}

/* Sortable */
.drag-handle {
    cursor: move;
    color: #999;
    padding: 5px 10px;
}

.drag-handle:hover {
    color: var(--primary-color);
}

.sortable-placeholder {
    background: #f0f8ff !important;
    border: 2px dashed var(--primary-color) !important;
    height: 50px;
}

/* Case status colors */
.case-intake { border-left: 4px solid #ffc107; }
.case-open { border-left: 4px solid #17a2b8; }
.case-active { border-left: 4px solid #007bff; }
.case-hearing { border-left: 4px solid #28a745; }
.case-closed { border-left: 4px solid #6c757d; }

/* =============================================
   RESPONSIVE — Mobile & Tablet
   ============================================= */

/* Sidebar backdrop overlay for mobile */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1015;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}
body.sidebar-open {
    overflow: hidden;
}

/* AI co-pilot chat header: case selector caps at a reasonable desktop width
   so a long case-title option doesn't stretch the header element. */
.chat-header .chat-case-select {
    max-width: 280px;
    text-overflow: ellipsis;
}

@media (max-width: 991.98px) {
    /* Sidebar slides in/out, gets boxed shadow when open */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        z-index: 1025;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0 !important;
        padding: 20px 18px;
    }

    /* Navbar — fit everything on one row */
    .navbar {
        padding: 0 0.6rem;
        flex-wrap: nowrap;
    }
    .navbar .container-fluid {
        flex-wrap: nowrap;
        gap: 0.25rem;
        padding: 0;
    }
    .navbar-brand {
        font-size: 0.92rem;
        margin-inline-end: 0;
        padding: 0;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex-shrink: 1;
    }
    .navbar-brand .fa-balance-scale { font-size: 1.05rem; }
    .sidebar-toggle {
        padding: 6px 10px;
        font-size: 1.1rem;
        flex-shrink: 0;
    }
    .navbar-nav.ms-auto {
        gap: 0.15rem !important;
        flex-shrink: 0;
        flex-wrap: nowrap;
    }
    .navbar-nav .nav-link {
        padding: 6px 8px;
    }
    /* Hide the username text and role badge in user dropdown */
    .navbar .nav-item.dropdown > .nav-link {
        padding: 6px 6px;
    }
    .navbar .nav-item.dropdown > .nav-link .badge {
        display: none !important;
    }
    .navbar .nav-item.dropdown > .nav-link {
        font-size: 0;            /* hide the username text */
    }
    .navbar .nav-item.dropdown > .nav-link i {
        font-size: 1.1rem;       /* keep the user icon visible */
    }
    .navbar .nav-item.dropdown > .nav-link::after {
        display: none;           /* drop the small dropdown caret arrow */
    }
    /* Make the language toggle compact pill */
    .navbar-nav.ms-auto > a.nav-link[href*="admin_lang"] {
        font-size: 0.72rem !important;
        padding: 3px 8px !important;
        line-height: 1.4 !important;
    }

    /* Page header smaller */
    .page-header {
        margin-bottom: 18px;
        padding-bottom: 12px;
    }
    .page-title {
        font-size: 1.4rem;
    }

    /* Cards tighter */
    .card {
        margin-bottom: 16px;
    }
    .card-body {
        padding: 16px;
    }
    .card-header {
        padding: 13px 16px;
        font-size: 0.88rem;
    }

    /* Stat cards smaller numbers */
    .stat-value {
        font-size: 1.6rem;
    }
    .stat-card {
        padding: 18px 18px 16px;
    }
    .stat-icon {
        font-size: 1.3rem;
    }

    /* Tables get horizontal scroll fallback inside cards */
    .card-body > table.table,
    .card-body > .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Modal: full-width with small margins */
    .modal-dialog {
        margin: 8px;
    }
    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl,
    .modal-dialog.modal-dialog-scrollable {
        max-width: calc(100% - 16px);
        max-height: calc(100vh - 16px);
    }
    .modal-dialog.modal-dialog-scrollable .modal-content {
        max-height: calc(100vh - 16px);
    }
    .modal-body {
        padding: 16px;
    }
    .modal-header {
        padding: 14px 16px 12px;
    }

    /* Sticky form action bar adjusts for new padding */
    .modal-body > form > .text-end:last-child,
    .modal-body > .text-end:last-child {
        bottom: -16px;
        margin: 16px -16px -16px -16px;
        padding: 12px 16px;
    }
    .modal-body > form > .text-end:last-child .btn,
    .modal-body > .text-end:last-child .btn {
        min-width: 0;
        padding: 7px 14px;
        font-size: 0.82rem;
    }

    /* Form section title compact */
    .form-section-title {
        font-size: 0.92rem;
        margin: 16px 0 10px;
        padding-bottom: 8px;
    }
}

@media (max-width: 767.98px) {
    body { font-size: 13.5px; }

    .stat-card {
        margin-bottom: 12px;
    }
    .stat-value {
        font-size: 1.45rem;
    }
    .stat-label {
        font-size: 0.7rem;
        letter-spacing: 0.5px;
    }
    .stat-icon {
        font-size: 1.1rem;
        right: 14px;
    }
    [dir="rtl"] .stat-icon { left: 14px; right: auto; }

    .page-title {
        font-size: 1.2rem;
    }
    .page-header {
        margin-bottom: 14px;
    }
    .breadcrumb {
        font-size: 0.74rem;
    }

    /* Login adapts */
    .login-box {
        padding: 28px 22px;
        border-radius: var(--radius);
    }
    .login-logo {
        font-size: 2rem;
        margin-bottom: 12px;
    }
    .login-title {
        font-size: 1.25rem;
    }
    .login-subtitle {
        font-size: 0.78rem;
        margin-bottom: 20px;
    }

    /* Buttons: keep tap targets ≥ 36px high */
    .btn {
        padding: 8px 14px;
        font-size: 0.83rem;
    }
    .btn-sm, .btn-group-sm .btn {
        padding: 6px 10px;
        font-size: 0.76rem;
    }

    /* Quick action grid — 2 cols on small phones */
    .col-md-4.col-6.mb-3 .btn-outline-primary.w-100.py-3 {
        padding: 14px 8px !important;
        font-size: 0.78rem;
    }

    /* DataTables controls stack vertically */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: start !important;
        margin-bottom: 8px;
    }
    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        margin: 4px 0 0 0;
    }
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 4px 9px !important;
        font-size: 0.78rem;
    }

    /* Tables: tighter cells */
    .table thead th { padding: 10px 10px; font-size: 0.68rem; }
    .table tbody td { padding: 10px 10px; font-size: 0.83rem; }

    /* Action button column doesn't wrap */
    .table tbody td:last-child .btn-group { flex-wrap: nowrap; }

    /* AI chat bubbles on phones */
    .chat-bubble {
        max-width: 92% !important;
        font-size: 0.85rem;
    }

    /* AI co-pilot: case selector + header on mobile.
       The header has the chat title (which can wrap with ellipsis) and the
       case-switcher dropdown. On mobile let the select drop onto its own row
       and span full width — long case titles no longer push it off-screen. */
    .chat-header .chat-case-select {
        width: 100% !important;
        max-width: 100%;
    }
    .chat-header > .text-truncate {
        max-width: 100%;
        flex: 1 1 100%;
    }

    /* ----- Filter cards (list pages) ----- */
    /* When filter columns stack, give them vertical spacing.
       Targets the typical .card-body.py-2 > .row pattern; pages
       that already use .row.g-2 still benefit (rule is idempotent). */
    .card-body.py-2 > .row > [class*="col-"] {
        margin-bottom: 8px;
    }
    .card-body.py-2 > .row > [class*="col-"]:last-child {
        margin-bottom: 0;
    }
    /* Right-aligned action buttons in a filter bar: left-align on mobile,
       wrap nicely with gaps between buttons. */
    .card-body.py-2 .text-end {
        text-align: start !important;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    .card-body.py-2 .text-end .btn {
        margin: 0;
    }

    /* Free-form filter strips (e.g. KB search) that use inline width:auto:
       force selects to flex-grow so they fill the row, not sit crammed. */
    .card-body .d-flex.flex-wrap > .form-select,
    .card-body .d-flex.flex-wrap > .form-control {
        flex: 1 1 140px;
        width: auto !important;   /* override inline style="width:auto" */
        min-width: 0;
    }
}

@media (max-width: 575.98px) {
    .main-content {
        padding: 14px 12px;
    }

    /* table-form already stacks at this breakpoint via earlier rule — reinforce */
    .table-form .form-lbl {
        padding: 8px 4px 2px;
        font-size: 0.78rem;
    }

    /* Hide non-essential nav labels in navbar */
    .navbar-brand {
        font-size: 0.88rem;
        letter-spacing: 0;
    }
    .navbar-nav.ms-auto {
        gap: 0.25rem !important;
    }

    /* Stack form action buttons full-width */
    .modal-body > form > .text-end:last-child,
    .modal-body > .text-end:last-child {
        display: flex;
        flex-direction: column-reverse;
        gap: 6px;
    }
    .modal-body > form > .text-end:last-child .btn,
    .modal-body > .text-end:last-child .btn {
        width: 100%;
        margin: 0;
    }

    /* Page title smaller */
    .page-title {
        font-size: 1.1rem;
    }

    /* Card-header with right-side button: stack */
    .card-header.d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 8px;
    }
    .card-header.d-flex.justify-content-between > .btn,
    .card-header.d-flex.justify-content-between > div {
        margin-inline-start: auto;
    }

    /* Hide RTL secondary text in quick-draft buttons */
    .text-start small.float-end,
    .text-start small.float-start {
        display: none;
    }
}

/* Touch target boost on coarse pointers */
@media (pointer: coarse) {
    .sidebar-nav .nav-link {
        padding-top: 10px;
        padding-bottom: 10px;
    }
    .dropdown-item {
        padding: 10px 12px;
    }
    .table tbody td .btn-group .btn {
        padding: 6px 11px;
    }
}

/* =============================================
   AI RESPONSE FORMATTING
   ============================================= */

/* Container */
.ai-response {
    font-size: 0.92rem;
    line-height: 1.85;
    color: #2c2c2c;
    word-wrap: break-word;
}

/* While the AI is still generating, the (empty) result container must not paint
   its border/padding as a bare box under the loading spinner (KB / Research /
   Precedents streams create the container up-front and fill it on first chunk). */
.ai-response:empty { display: none; }

.ai-response.ai-rtl {
    direction: rtl;
    text-align: right;
    font-family: 'Segoe UI', 'Noto Naskh Arabic', Tahoma, sans-serif;
}

/* Headings */
.ai-response .ai-heading {
    color: var(--primary-color);
    margin: 18px 0 8px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid #e8e8e8;
    font-weight: 600;
    line-height: 1.4;
}

.ai-response h3.ai-heading { font-size: 1.15rem; }
.ai-response h4.ai-heading { font-size: 1.05rem; }
.ai-response h5.ai-heading { font-size: 0.95rem; border-bottom: none; }
.ai-response h6.ai-heading { font-size: 0.9rem; border-bottom: none; color: #555; }

/* Paragraphs */
.ai-response .ai-paragraph {
    margin: 0 0 8px 0;
}

.ai-response .ai-spacer {
    height: 8px;
}

/* Lists */
.ai-response .ai-list {
    margin: 6px 0 12px 0;
    padding-left: 24px;
}

.ai-rtl .ai-list {
    padding-left: 0;
    padding-right: 24px;
}

.ai-response .ai-list li {
    margin-bottom: 5px;
    line-height: 1.7;
}

.ai-response .ai-list li .ai-sub-item {
    margin-left: 16px;
}

.ai-rtl .ai-list li .ai-sub-item {
    margin-left: 0;
    margin-right: 16px;
}

/* Nested lists */
.ai-response .ai-list .ai-list {
    margin-top: 4px;
    margin-bottom: 4px;
}

/* Bold & Italic */
.ai-response strong {
    font-weight: 600;
    color: #1a1a1a;
}

.ai-response em {
    font-style: italic;
}

/* Code */
/* NO dark "code" styling in AI answers — these are legal answers, not code.
   Inline `…` and ```fenced``` content render as light panels in the normal font
   (the model sometimes wraps plans/lists in fences; keep them readable + RTL). */
.ai-response .ai-inline-code {
    background: #f0f2f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.95em;
    color: inherit;
}

.ai-response .ai-code-block {
    background: #f6f8fa;
    color: #1a1a1a;
    border: 1px solid #e2e6ea;
    padding: 12px 16px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    overflow-x: auto;
    margin: 10px 0;
    line-height: 1.8;
    white-space: pre-wrap;      /* wrap long Arabic lines instead of side-scrolling */
    direction: inherit;         /* respect RTL inside the panel */
    text-align: inherit;
}

.ai-response .ai-code-block code {
    color: inherit;
    background: none;
    padding: 0;
    font-family: inherit;
    white-space: inherit;
}

/* Blockquote ('>' lines) — quoted article text / notes. border-inline-start flips in RTL. */
.ai-response .ai-quote {
    border-inline-start: 3px solid #d4a933;
    background: #faf8f2;
    padding: 8px 14px;
    margin: 10px 0;
    border-radius: 4px;
    color: #444;
}

/* Horizontal Rule */
.ai-response .ai-hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 16px 0;
}

/* Markdown tables */
.ai-response .ai-table-wrap {
    overflow-x: auto;
    margin: 12px 0;
}

.ai-response .ai-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: #fff;
}

.ai-response .ai-table th,
.ai-response .ai-table td {
    border: 1px solid #e2e6ea;
    padding: 8px 12px;
    text-align: inherit;
    vertical-align: top;
    line-height: 1.6;
}

.ai-response .ai-table th {
    background: #f4f6f9;
    color: #1a1a1a;
    font-weight: 600;
    white-space: nowrap;
}

.ai-response .ai-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.ai-response.ai-rtl .ai-table th,
.ai-response.ai-rtl .ai-table td {
    text-align: right;
}

/* Source-transparency flags — compact color-coded dots (see markdown.js tokens).
   amber = unverified (general knowledge) · green = verified vs official web sources.
   Full explanation lives in the title tooltip; the label stays tiny. */
.ai-response .ai-flag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 2px 2px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.6;
    vertical-align: middle;
    cursor: help;
    white-space: nowrap;
}
.ai-response .ai-flag-unv {
    background: #fff8e6;
    border: 1px solid #f3d98a;
    color: #b58900;
}
.ai-response .ai-flag-web {
    background: #eaf7ef;
    border: 1px solid #a9dcbd;
    color: #1c6b3c;
}
.ai-response .ai-flag-label { font-weight: 600; }
.ai-response .ai-link {
    color: #b8860b;                       /* brand amber/gold, matches law-ref links */
    text-decoration: none;
    word-break: break-word;
}
.ai-response .ai-link:hover { color: #96690a; text-decoration: underline; }

/* Chat bubble overrides */
.chat-ai .ai-response {
    color: #333;
}

.chat-ai .ai-response .ai-heading {
    color: var(--primary-color);
    font-size: 0.95rem;
    margin: 12px 0 6px 0;
}

.chat-ai .ai-response .ai-paragraph {
    margin-bottom: 6px;
}

.chat-ai .ai-response .ai-list {
    margin: 4px 0 8px 0;
    padding-left: 20px;
}

.chat-ai .ai-rtl .ai-list {
    padding-left: 0;
    padding-right: 20px;
}

/* Research/Analysis panel overrides */
.border .ai-response {
    padding: 4px 0;
}

.border .ai-response .ai-heading:first-child {
    margin-top: 0;
}

/* Print Styles */
/* =============================================
   RTL OVERRIDES (Arabic)
   ============================================= */
[dir="rtl"] body,
[dir="rtl"] .sidebar,
[dir="rtl"] .navbar,
[dir="rtl"] .main-content,
[dir="rtl"] .card,
[dir="rtl"] .modal,
[dir="rtl"] .table,
[dir="rtl"] .form-control,
[dir="rtl"] .form-select,
[dir="rtl"] .btn,
[dir="rtl"] .dropdown-menu,
[dir="rtl"] .alert,
[dir="rtl"] .badge,
[dir="rtl"] .breadcrumb,
[dir="rtl"] .nav-link,
[dir="rtl"] .form-label,
[dir="rtl"] .form-lbl,
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] h4, [dir="rtl"] h5, [dir="rtl"] h6 {
    font-family: "Cairo", "Tahoma", "Segoe UI", sans-serif;
}

[dir="rtl"] .page-title {
    font-family: "Cairo", sans-serif;
    font-weight: 700;
}

[dir="rtl"] .stat-value {
    font-family: "Cairo", sans-serif;
    font-weight: 800;
}

[dir="rtl"] .sidebar-nav .nav-link span {
    font-family: "Cairo", sans-serif;
    font-weight: 500;
}

[dir="rtl"] .sidebar-nav .nav-section {
    font-family: "Cairo", sans-serif;
    font-weight: 700;
}

[dir="rtl"] .card-header {
    font-family: "Cairo", sans-serif;
    font-weight: 600;
}

[dir="rtl"] .form-section-title {
    font-family: "Cairo", sans-serif;
    font-weight: 700;
}

[dir="rtl"] .navbar-brand {
    font-family: "Cairo", sans-serif;
    font-weight: 700;
}

[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.08);
}

[dir="rtl"] .sidebar.collapsed {
    transform: translateX(100%);
}

[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

[dir="rtl"] .main-content.expanded {
    margin-right: 0;
}

[dir="rtl"] .sidebar-nav .nav-link {
    border-left: none;
    border-right: 3px solid transparent;
}

[dir="rtl"] .sidebar-nav .nav-link:hover,
[dir="rtl"] .sidebar-nav .nav-link.active {
    border-left-color: transparent;
    border-right-color: var(--primary-color);
}

[dir="rtl"] .sidebar-nav .nav-link i {
    margin-right: 0;
    margin-left: 10px;
}

[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    content: "\\";
    float: right;
    padding-left: 0.5rem;
    padding-right: 0;
}

[dir="rtl"] .table-form .form-lbl {
    text-align: right;
}

/* RTL form fields: text inputs / selects / textareas align to the start (right);
   keep email, phone, URL, number and date fields LTR-left for legibility. */
[dir="rtl"] .table-form .form-control,
[dir="rtl"] .table-form .form-select,
[dir="rtl"] .table-form textarea.form-control,
[dir="rtl"] .modal-body .form-control,
[dir="rtl"] .modal-body .form-select,
[dir="rtl"] .modal-body textarea {
    text-align: right;
}
[dir="rtl"] .table-form input[type="email"],
[dir="rtl"] .table-form input[type="tel"],
[dir="rtl"] .table-form input[type="url"],
[dir="rtl"] .table-form input[type="number"],
[dir="rtl"] .table-form input[type="date"],
[dir="rtl"] .modal-body input[type="email"],
[dir="rtl"] .modal-body input[type="tel"],
[dir="rtl"] .modal-body input[type="url"],
[dir="rtl"] .modal-body input[type="number"],
[dir="rtl"] .modal-body input[type="date"] {
    text-align: left;
    direction: ltr;
}

[dir="rtl"] .form-section-title {
    direction: rtl;
}

[dir="rtl"] .stat-icon {
    right: auto;
    left: 20px;
}

[dir="rtl"] .activity-timeline {
    padding-left: 0;
    padding-right: 30px;
}

[dir="rtl"] .activity-timeline::before {
    left: auto;
    right: 10px;
}

[dir="rtl"] .activity-item::before {
    left: auto;
    right: -24px;
}

@media (max-width: 991px) {
    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }
    [dir="rtl"] .sidebar.show {
        transform: translateX(0);
    }
    [dir="rtl"] .main-content {
        margin-right: 0;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .dataTables_filter,
    .dataTables_length,
    .dataTables_paginate {
        display: none !important;
    }

    .main-content {
        margin: 0;
        padding: 0;
    }
}

/* =============================================
   MODAL OVERFLOW SAFETY (fixes form expansion)
   ============================================= */

/* Prevent any child from forcing modal-body to expand horizontally */
.modal-body * {
    max-width: 100%;
}
.modal-body img,
.modal-body video,
.modal-body iframe,
.modal-body table {
    max-width: 100%;
}

/* Long unbroken strings (URLs, IDs, file names) should wrap */
.modal-body p,
.modal-body div,
.modal-body td,
.modal-body span,
.modal-body label {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Inputs and selects never exceed their cell */
.modal-body .form-control,
.modal-body .form-select,
.modal-body .select2-container {
    max-width: 100% !important;
    min-width: 0 !important;
}

/* Textareas in modals: only resize vertically and stay within the popup */
.modal-body textarea,
.modal-body textarea.form-control {
    resize: vertical;
    max-height: 45vh;
    overflow-y: auto;
}

/* Bootstrap input-group inside narrow cells */
.modal-body .input-group {
    flex-wrap: nowrap;
}

/* Code blocks inside modals */
.modal-body pre,
.modal-body code {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Alerts inside modals stay compact */
.modal-body .alert {
    margin-bottom: 14px;
}

/* On narrow viewports, stack table-form labels above inputs */
@media (max-width: 575.98px) {
    .table-form,
    .table-form tbody,
    .table-form tr,
    .table-form td {
        display: block;
        width: 100% !important;
    }
    .table-form .form-lbl {
        background: transparent;
        padding: 8px 4px 4px;
        border-bottom: none;
        min-width: 0;
    }
    .table-form td {
        padding: 4px 4px 10px;
        border: none;
    }
    .table-form tr {
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 8px;
        margin-bottom: 8px;
    }
}

/* =============================================
   ALERTS, DROPDOWNS, MODERN TOUCHES
   ============================================= */
.alert {
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    padding: 12px 16px;
    font-size: 0.88rem;
}
.alert-light {
    background: var(--surface-muted);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.dropdown-menu {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    padding: 6px;
}
.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.88rem;
}
.dropdown-item:hover, .dropdown-item:focus {
    background: var(--primary-lighter);
    color: var(--primary-color);
}

/* Modal animation polish */
.modal.fade .modal-dialog {
    transform: scale(0.97) translateY(-10px);
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
}

/* Form check (checkbox / switch) labels */
.form-check-input {
    border-color: var(--border-color-strong);
}
.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}
.form-check-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 82, 118, 0.15);
}

/* =============================================
   ICON PICKER
   ============================================= */
.icon-picker-wrap {
    flex-wrap: nowrap;
}
.icon-picker-btn {
    min-width: 200px;
    text-align: start;
    font-weight: 500;
}
.icon-picker-popover {
    z-index: 10000;
    background: #fff;
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 360px;
    max-height: 380px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.icon-picker-search {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}
.icon-picker-grid {
    padding: 6px 10px 10px;
    overflow-y: auto;
    flex: 1;
}
.icon-picker-group {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 4px 4px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 6px;
    grid-column: 1 / -1;
}
.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}
.icon-picker-item {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 8px 0;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    font-size: 1rem;
}
.icon-picker-item:hover {
    background: var(--primary-lighter);
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.icon-picker-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.85rem;
    padding: 24px 8px;
}

/* Subtle scrollbar styling */
.modal-body::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.modal-body::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}
.modal-body::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

/* =============================================
   PREMIUM LEGAL — FINAL POLISH LAYER
   ============================================= */

/* Headings — serif accents in LTR mode only */
h1, h2, h3, h4 {
    color: var(--primary-dark);
    font-weight: 700;
    letter-spacing: -0.01em;
}
[dir="ltr"] .page-title,
[dir="ltr"] .modal-title,
[dir="ltr"] .login-title,
[dir="ltr"] .card-header h5,
[dir="ltr"] .card-header h6 {
    font-family: var(--font-serif);
}

/* Form section title — refined */
.form-section-title {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0;
    color: var(--primary-dark);
    margin: 22px 0 12px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}
.form-section-title::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 32px;
    height: 2px;
    background: var(--secondary-color);
}
[dir="rtl"] .form-section-title::after {
    left: auto;
    right: 0;
}
.form-section-title i {
    color: var(--secondary-color);
    font-size: 0.95rem;
}

/* Quick action buttons (dashboard grid) — premium hover */
.btn-outline-primary.w-100.py-3,
.btn-outline-primary.w-100.py-2 {
    border: 1px solid var(--border-color);
    background: var(--surface);
    color: var(--text-secondary);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-xs);
}
.btn-outline-primary.w-100.py-3:hover,
.btn-outline-primary.w-100.py-2:hover {
    background: var(--surface);
    color: var(--primary-color);
    border-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.btn-outline-primary.w-100 i.fa-2x {
    color: var(--secondary-color);
    transition: transform 0.2s ease;
}
.btn-outline-primary.w-100:hover i.fa-2x {
    transform: scale(1.1);
}

/* Recent item polish */
.recent-item {
    transition: background-color 0.15s ease;
    margin: 0 -8px;
    padding: 12px 8px;
    border-radius: var(--radius-sm);
}
.recent-item:hover {
    background-color: var(--surface-muted);
}

/* Activity timeline — premium dots */
.activity-timeline {
    position: relative;
    padding-left: 28px;
}
.activity-timeline::before {
    background: var(--border-color);
}
.activity-item {
    padding-bottom: 18px;
}
.activity-item::before {
    background: var(--secondary-color);
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--border-color-strong);
    width: 12px;
    height: 12px;
    left: -26px;
    top: 3px;
}
.activity-item h6 {
    font-weight: 600;
    color: var(--primary-dark);
    font-size: 0.88rem;
}
.activity-item small {
    color: var(--text-tertiary);
    font-size: 0.78rem;
}

[dir="rtl"] .activity-item::before {
    left: auto;
    right: -26px;
}

/* Breadcrumb refinement */
.breadcrumb-item {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}
.breadcrumb-item a {
    color: var(--secondary-color);
    font-weight: 500;
}
.breadcrumb-item a:hover {
    color: var(--secondary-dark);
}
.breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-tertiary);
    content: "›";
    font-weight: 600;
}

/* Nav tabs — premium */
.nav-tabs {
    border-bottom: 1px solid var(--border-color);
}
.nav-tabs .nav-link {
    border: none;
    color: var(--text-tertiary);
    font-weight: 600;
    font-size: 0.86rem;
    padding: 10px 18px;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    transition: color 0.15s, border-color 0.15s;
    letter-spacing: 0.2px;
}
.nav-tabs .nav-link:hover {
    color: var(--primary-color);
    border-color: transparent;
    background: transparent;
}
.nav-tabs .nav-link.active {
    color: var(--primary-color);
    background: transparent;
    border-bottom-color: var(--secondary-color);
}

/* Alerts — premium */
.alert {
    border-radius: var(--radius-sm);
    border: 1px solid;
    padding: 12px 16px;
    font-size: 0.88rem;
    border-left-width: 3px;
}
[dir="rtl"] .alert {
    border-left-width: 1px;
    border-right-width: 3px;
}
.alert-success    { background: #f0f9f4; border-color: var(--success-color); color: #0d5639; }
.alert-danger     { background: #fdf2f4; border-color: var(--danger-color); color: #8a263a; }
.alert-warning    { background: #fef8e7; border-color: var(--warning-color); color: #6b4309; }
.alert-info       { background: #ebf6f9; border-color: var(--info-color); color: #0a5b6f; }
.alert-light      { background: var(--surface-muted); border-color: var(--border-color); color: var(--text-secondary); }

/* Form switch — premium */
.form-switch .form-check-input {
    width: 38px;
    height: 22px;
    background-color: #d1d6df;
    border-color: transparent;
    cursor: pointer;
}
.form-switch .form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* Card hover — slightly lift */
.card.h-100 {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card.h-100:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(230, 191, 70, 0.4);
}

/* Section spacing — more generous */
.main-content {
    padding: 30px 32px;
}

/* Hide that ugly DataTables wrapper top */
.dataTables_wrapper .row {
    margin-bottom: 12px;
}
.dataTables_wrapper .row:last-child {
    margin-bottom: 0;
    margin-top: 12px;
}

/* Pill button (icon-only) hover */
.btn-link.text-white:hover {
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    color: var(--accent-color) !important;
}

/* Selection color */
::selection {
    background: rgba(230, 191, 70, 0.25);
    color: var(--primary-dark);
}

/* Refined card-header buttons (right-side actions) */
.card-header .btn {
    padding: 5px 12px;
    font-size: 0.78rem;
}

/* AR mode keeps Cairo as primary on headings — override the serif */
[dir="rtl"] .page-title,
[dir="rtl"] .modal-title,
[dir="rtl"] .login-title,
[dir="rtl"] .form-section-title,
[dir="rtl"] .stat-value,
[dir="rtl"] .navbar-brand,
[dir="rtl"] .admin-name,
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] h5,
[dir="rtl"] h6 {
    font-family: "Cairo", "Tahoma", sans-serif;
    font-style: normal;
}

/* Subtle entrance for main content */
.main-content {
    animation: fadeInUp 0.3s ease-out;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Streaming AI message — plain whitespace-preserving while text arrives */
.msg-content.streaming {
    white-space: pre-wrap;
    word-break: break-word;
}
.msg-content.streaming::after {
    content: '▍';
    display: inline-block;
    margin-inline-start: 1px;
    color: var(--secondary-color);
    animation: aiCursorBlink 1s steps(1) infinite;
    vertical-align: baseline;
}
@keyframes aiCursorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ---------------------------------------------------------------------------
   Pending tasks / deadlines: a red pulsing badge, because these are the two
   counts a user must not walk past. Animates opacity + box-shadow only (both
   compositor-friendly), and holds still for anyone who asked for reduced motion
   — where it stays solid red so the warning is never lost, only the movement.
   Specificity matches the base .sidebar-badge rules so it wins on colour.
--------------------------------------------------------------------------- */
.sidebar-nav .nav-link .sidebar-badge.sidebar-badge-alert,
.sidebar-nav .nav-link.active .sidebar-badge.sidebar-badge-alert {
    background: #ef4444;
    color: #fff;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: sidebarBadgePulse 1.4s ease-in-out infinite;
}

@keyframes sidebarBadgePulse {
    0%   { opacity: 1;    box-shadow: 0 0 0 0    rgba(239, 68, 68, 0.7); }
    70%  { opacity: 0.55; box-shadow: 0 0 0 6px  rgba(239, 68, 68, 0); }
    100% { opacity: 1;    box-shadow: 0 0 0 0    rgba(239, 68, 68, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar-nav .nav-link .sidebar-badge.sidebar-badge-alert,
    .sidebar-nav .nav-link.active .sidebar-badge.sidebar-badge-alert {
        animation: none;
        opacity: 1;
    }
}
