/* =====================================================================
   Agarha dashboard theme
   ---------------------------------------------------------------------
   One visual language shared with the mobile app: the palette is taken
   from Agarha_App_Flutter/lib/theme/app_colors.dart and the typeface is
   the app's Tajawal. Loaded after AdminLTE (RTL build) on every layout
   page, and after login.css on the sign-in and registration pages.

   This file only styles. It never hides, adds or reorders behaviour, so
   every page keeps working exactly as before when it is removed.
   ===================================================================== */

/* ------------------------------------------------------------- fonts */
@font-face { font-family: 'Tajawal'; src: url('../fonts/Tajawal-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('../fonts/Tajawal-Medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('../fonts/Tajawal-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Tajawal'; src: url('../fonts/Tajawal-ExtraBold.ttf') format('truetype'); font-weight: 800; font-display: swap; }

/* ------------------------------------------------------------ tokens */
:root {
  /* Brand (mirrors the Flutter app) */
  --ag-primary: #0F7A71;        /* colorPrimary: CTAs, active states   */
  --ag-primary-600: #0C665E;    /* hover / pressed                     */
  --ag-primary-700: #0A524C;
  --ag-primary-50: #E6F4F2;     /* colorPrimaryWhite: tinted surfaces  */
  --ag-primary-rgb: 15, 122, 113;
  --ag-ink: #1E293B;            /* colorSecondPrimary: headings        */
  --ag-muted: #64748B;          /* colorIconProfile: labels            */
  --ag-bg: #F4F7F6;             /* colorScaffoldBackground             */
  --ag-surface: #FFFFFF;        /* colorCardCanvas                     */
  --ag-gold: #D97706;           /* colorAccentGold: pending            */
  --ag-emerald: #16A34A;        /* colorAccentEmerald: success         */
  --ag-danger: #DC2626;

  /* Neutrals */
  --ag-border: #E2E8F0;
  --ag-border-strong: #CBD5E1;
  --ag-head-bg: #F1F5F4;
  --ag-sidebar: #1E293B;
  --ag-sidebar-2: #172033;

  /* Shape */
  --ag-radius-sm: 8px;
  --ag-radius: 12px;
  --ag-radius-lg: 16px;
  --ag-shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --ag-shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .05);
  --ag-shadow-lg: 0 20px 45px rgba(15, 23, 42, .18);
  --ag-ring: 0 0 0 .2rem rgba(var(--ag-primary-rgb), .18);

  /* Bootstrap hand-off: every component that reads these follows the brand */
  --bs-primary: var(--ag-primary);
  --bs-primary-rgb: 15, 122, 113;
  --bs-success: var(--ag-emerald);
  --bs-success-rgb: 22, 163, 74;
  --bs-warning: var(--ag-gold);
  --bs-warning-rgb: 217, 119, 6;
  --bs-danger: var(--ag-danger);
  --bs-danger-rgb: 220, 38, 38;
  --bs-secondary-color: var(--ag-muted);
  --bs-body-font-family: 'Tajawal', 'Cairo', system-ui, sans-serif;
  --bs-body-bg: var(--ag-bg);
  --bs-body-color: var(--ag-ink);
  --bs-border-color: var(--ag-border);
  --bs-border-radius: var(--ag-radius-sm);
  --bs-link-color: var(--ag-primary);
  --bs-link-color-rgb: 15, 122, 113;
  --bs-link-hover-color: var(--ag-primary-700);
  --bs-link-hover-color-rgb: 10, 82, 76;
  --bs-focus-ring-color: rgba(var(--ag-primary-rgb), .25);
  --bs-primary-bg-subtle: var(--ag-primary-50);
  --bs-primary-text-emphasis: var(--ag-primary-700);
}

/* ------------------------------------------------------------- base */
html, body { font-family: var(--bs-body-font-family); }
/* The old layout forced one Cairo weight onto every element with `*`;
   inheriting instead lets headings and labels carry real weights.
   Icon fonts keep their own family. */
body, button, input, select, textarea, .tooltip, .popover, .dropdown-menu {
  font-family: var(--bs-body-font-family);
}
body {
  background: var(--ag-bg) !important;
  color: var(--ag-ink);
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(var(--ag-primary-rgb), .2); }

/* --------------------------------------------------------- header bar */
.app-header {
  background: rgba(255, 255, 255, .92) !important;
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--ag-border);
  box-shadow: none;
  min-height: 60px;
}
.app-header .nav-link { color: var(--ag-ink); }
.app-header .nav-link:hover { color: var(--ag-primary); }

.ag-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0 !important;
  border-radius: 10px;
  font-size: 1.2rem;
  transition: background-color .15s ease;
}
.ag-icon-btn:hover { background: var(--ag-primary-50); }

.ag-crumbs {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin: 0;
  padding: 0 .5rem;
  list-style: none;
  font-size: .9rem;
  color: var(--ag-muted);
  white-space: nowrap;
  overflow: hidden;
}
.ag-crumbs a { color: var(--ag-muted); text-decoration: none; }
.ag-crumbs a:hover { color: var(--ag-primary); }
.ag-crumbs .bi-chevron-left { font-size: .7rem; opacity: .7; }
.ag-crumbs .ag-crumb-current { color: var(--ag-ink); font-weight: 700; overflow: hidden; text-overflow: ellipsis; }

/* User chip */
.ag-user-chip {
  display: inline-flex !important;
  align-items: center;
  gap: .55rem;
  padding: .25rem .6rem !important;
  border-radius: 999px;
}
.ag-user-chip:hover { background: var(--ag-primary-50); }
.ag-user-chip::after { display: none !important; }
.ag-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ag-primary);
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
  flex: 0 0 auto;
}
.ag-user-menu {
  min-width: 240px;
  padding: .5rem;
  border-radius: var(--ag-radius);
}
.ag-user-menu .ag-user-head {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .6rem .8rem;
  margin-bottom: .35rem;
  border-bottom: 1px solid var(--ag-border);
}
.ag-user-menu .ag-user-head .ag-avatar { width: 42px; height: 42px; font-size: 1.1rem; }
.ag-user-menu .ag-user-name { font-weight: 700; color: var(--ag-ink); }
.ag-user-menu .ag-user-role { font-size: .8rem; color: var(--ag-muted); }
.ag-user-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  border-radius: var(--ag-radius-sm);
  padding: .55rem .6rem;
}
.ag-user-menu .dropdown-item.text-danger:hover { background: #FEF2F2; }

/* Notifications bell: the badge sits on the bell's outer corner. */
.notif-bell .notif-badge {
  background: var(--ag-danger) !important;
  color: #fff !important;
  transform: translate(-35%, -20%) !important;
  border: 2px solid #fff;
}
.notifications-menu { border-radius: var(--ag-radius); padding: .35rem; }
.notifications-menu .notif-icon { color: var(--ag-primary) !important; }
.notifications-menu .notif-item { border-radius: var(--ag-radius-sm); }

/* ------------------------------------------------------------ sidebar */
.app-sidebar,
.app-sidebar[data-bs-theme=dark],
[data-bs-theme=dark] .app-sidebar {
  background: linear-gradient(180deg, var(--ag-sidebar) 0%, var(--ag-sidebar-2) 100%) !important;
  border: 0;
  --lte-sidebar-color: #CBD5E1;
  --lte-sidebar-hover-bg: rgba(255, 255, 255, .06);
  --lte-sidebar-hover-color: #fff;
  --lte-sidebar-active-color: #fff;
  --lte-sidebar-menu-active-bg: rgba(255, 255, 255, .06);
  --lte-sidebar-menu-active-color: #fff;
  --lte-sidebar-submenu-bg: transparent;
  --lte-sidebar-submenu-color: #A3B1C6;
  --lte-sidebar-submenu-hover-bg: rgba(255, 255, 255, .06);
  --lte-sidebar-submenu-hover-color: #fff;
  --lte-sidebar-submenu-active-bg: var(--ag-primary);
  --lte-sidebar-submenu-active-color: #fff;
}
.app-sidebar .sidebar-brand {
  height: 64px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.app-sidebar .brand-link { display: flex; align-items: center; justify-content: center; }
.app-sidebar .brand-link .brand-image {
  float: none;
  height: 44px;
  max-height: 44px;
  width: auto;
  margin: 0;
  opacity: 1;
  box-shadow: none;
}
.app-sidebar .sidebar-wrapper { padding: .5rem .6rem 1rem; }

.sidebar-menu .nav-header {
  color: #64748B;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 1rem .75rem .35rem;
}
.sidebar-menu .nav-link {
  border-radius: 10px;
  padding: .55rem .75rem;
  font-size: .93rem;
}
.sidebar-menu > .nav-item > .nav-link { font-weight: 700; }
.sidebar-menu .nav-link .nav-icon { font-size: 1.05rem; opacity: .9; }
.sidebar-menu .nav-treeview {
  margin: .15rem 0 .35rem;
  padding-inline-start: .65rem !important;
  border-inline-start: 1px solid rgba(255, 255, 255, .08);
  margin-inline-start: 1.15rem;
}
.sidebar-menu .nav-treeview .nav-link { font-size: .9rem; padding: .45rem .7rem; }
/* A top-level page link (no submenu) gets the same solid highlight as a
   page inside a section; an open section's own header stays subtle. */
.sidebar-menu > .nav-item:not(:has(> .nav-treeview)) > .nav-link.active {
  background: var(--ag-primary);
  color: #fff;
}
.sidebar-menu > .nav-item:not(:has(> .nav-treeview)) > .nav-link.active,
.sidebar-menu .nav-treeview .nav-link.active {
  box-shadow: 0 4px 12px rgba(var(--ag-primary-rgb), .35);
  font-weight: 700;
}
.sidebar-menu .nav-link .nav-arrow { font-size: .75rem; opacity: .7; }

/* ------------------------------------------------------- main content */
.app-main .app-content-header { padding: 1.25rem .75rem 2rem; }
/* Data-heavy screens (bookings has 20+ optional columns) need the room;
   the old 1320px cap left half a wide monitor empty. */
.app-main .container { max-width: 100%; }

/* Page title: every screen uses <h1 class="title text-secondary">. */
.app-main h1.title {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--ag-ink) !important;
  text-align: start !important;
  justify-content: flex-start;
  margin-bottom: 1rem !important;
  line-height: 1.4;
}
.app-main h1.title::before {
  content: "";
  width: 5px;
  height: 1.35em;
  border-radius: 4px;
  background: var(--ag-primary);
  flex: 0 0 auto;
}
/* Pages that center everything under .row.text-center keep centered
   cells but not a centered page heading. */
.app-main .row.text-center > h1.title { padding-inline: calc(var(--bs-gutter-x) * .5); }

/* Toolbars built from inline flex rows: let them wrap on small screens. */
.app-main [style*="justify-content: space-between"] { flex-wrap: wrap; row-gap: .6rem; }
.app-main .row.text-center > div[style*="display: flex"] { margin-bottom: .25rem; }

/* -------------------------------------------------------------- cards */
.card {
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-lg);
  box-shadow: var(--ag-shadow);
  --bs-card-inner-border-radius: calc(var(--ag-radius-lg) - 1px);
}
.card > .card-header {
  background: transparent;
  border-bottom: 1px solid var(--ag-border);
  padding: .9rem 1.15rem;
  font-weight: 700;
}
.card > .card-header .card-title { font-weight: 700; font-size: 1.05rem; }
/* Coloured card headers: one brand colour for "primary/dark", and a
   quieter tint for the secondary side panel. */
.card > .card-header.bg-primary,
.card > .card-header.bg-dark { background: var(--ag-primary) !important; border-bottom-color: transparent; }
.card > .card-header.bg-secondary {
  background: var(--ag-primary-50) !important;
  color: var(--ag-primary-700) !important;
  border-bottom-color: rgba(var(--ag-primary-rgb), .15);
}
/* AdminLTE hard-codes its outline colours instead of reading Bootstrap's. */
.card-outline.card-primary { border-top: 3px solid var(--ag-primary); }
.card-outline.card-warning { border-top: 3px solid var(--ag-gold); }
.card-outline.card-success { border-top: 3px solid var(--ag-emerald); }
.card-outline.card-danger { border-top: 3px solid var(--ag-danger); }

/* ------------------------------------------------------------ buttons */
.btn {
  --bs-btn-font-weight: 600;
  --bs-btn-border-radius: 10px;
  --bs-btn-padding-y: .48rem;
  --bs-btn-padding-x: 1rem;
  --bs-btn-focus-box-shadow: var(--ag-ring);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-sm { --bs-btn-border-radius: 8px; --bs-btn-padding-y: .28rem; --bs-btn-padding-x: .65rem; }
.btn-lg { --bs-btn-border-radius: 12px; }
.btn:disabled, .btn.disabled { opacity: .45; }
/* `.btn` is inline-flex now; block buttons keep the full width. */
.btn.w-100, .d-grid > .btn { display: flex; }

.btn-primary {
  --bs-btn-bg: var(--ag-primary);
  --bs-btn-border-color: var(--ag-primary);
  --bs-btn-hover-bg: var(--ag-primary-600);
  --bs-btn-hover-border-color: var(--ag-primary-600);
  --bs-btn-active-bg: var(--ag-primary-700);
  --bs-btn-active-border-color: var(--ag-primary-700);
  --bs-btn-disabled-bg: var(--ag-primary);
  --bs-btn-disabled-border-color: var(--ag-primary);
}
.btn-success {
  --bs-btn-bg: var(--ag-emerald);
  --bs-btn-border-color: var(--ag-emerald);
  --bs-btn-hover-bg: #15803D;
  --bs-btn-hover-border-color: #15803D;
  --bs-btn-active-bg: #166534;
  --bs-btn-active-border-color: #166534;
  --bs-btn-disabled-bg: var(--ag-emerald);
  --bs-btn-disabled-border-color: var(--ag-emerald);
}
.btn-warning {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--ag-gold);
  --bs-btn-border-color: var(--ag-gold);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #B45309;
  --bs-btn-hover-border-color: #B45309;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #92400E;
  --bs-btn-active-border-color: #92400E;
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: var(--ag-gold);
  --bs-btn-disabled-border-color: var(--ag-gold);
}
.btn-danger {
  --bs-btn-bg: var(--ag-danger);
  --bs-btn-border-color: var(--ag-danger);
  --bs-btn-hover-bg: #B91C1C;
  --bs-btn-hover-border-color: #B91C1C;
  --bs-btn-active-bg: #991B1B;
  --bs-btn-active-border-color: #991B1B;
  --bs-btn-disabled-bg: var(--ag-danger);
  --bs-btn-disabled-border-color: var(--ag-danger);
}
.btn-info {
  --bs-btn-color: #fff;
  --bs-btn-bg: #0E7490;
  --bs-btn-border-color: #0E7490;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #155E75;
  --bs-btn-hover-border-color: #155E75;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #164E63;
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: #0E7490;
  --bs-btn-disabled-border-color: #0E7490;
}
.btn-secondary {
  --bs-btn-bg: #64748B;
  --bs-btn-border-color: #64748B;
  --bs-btn-hover-bg: #475569;
  --bs-btn-hover-border-color: #475569;
}
.btn-outline-primary {
  --bs-btn-color: var(--ag-primary);
  --bs-btn-border-color: var(--ag-primary);
  --bs-btn-hover-bg: var(--ag-primary);
  --bs-btn-hover-border-color: var(--ag-primary);
  --bs-btn-active-bg: var(--ag-primary-600);
  --bs-btn-active-border-color: var(--ag-primary-600);
}
.btn-outline-success {
  --bs-btn-color: var(--ag-emerald);
  --bs-btn-border-color: var(--ag-emerald);
  --bs-btn-hover-bg: var(--ag-emerald);
  --bs-btn-hover-border-color: var(--ag-emerald);
}
.btn-outline-secondary {
  --bs-btn-color: var(--ag-ink);
  --bs-btn-border-color: var(--ag-border-strong);
  --bs-btn-hover-color: var(--ag-ink);
  --bs-btn-hover-bg: #F1F5F9;
  --bs-btn-hover-border-color: var(--ag-border-strong);
  --bs-btn-active-color: var(--ag-ink);
  --bs-btn-active-bg: #E2E8F0;
  background: #fff;
}
/* Plain bordered "close" buttons in modals (`btn border`, `btn-default`). */
.btn.border, .btn-default {
  background: #fff;
  color: var(--ag-ink);
  border-color: var(--ag-border-strong) !important;
}
.btn.border:hover, .btn-default:hover { background: #F1F5F9; }

/* -------------------------------------------------------------- forms */
.form-label { font-weight: 600; color: var(--ag-ink); font-size: .9rem; margin-bottom: .35rem; }
.form-control, .form-select {
  border-color: var(--ag-border-strong);
  border-radius: 10px;
  padding: .5rem .8rem;
  color: var(--ag-ink);
  background-color: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-select { padding-inline-start: .8rem; }
.form-control::placeholder { color: #94A3B8; }
.form-control:focus, .form-select:focus {
  border-color: var(--ag-primary);
  box-shadow: var(--ag-ring);
}
.form-control:disabled, .form-select:disabled, .form-control[readonly] { background-color: #F8FAFC; }
.form-control-sm, .form-select-sm { border-radius: 8px; padding: .3rem .6rem; }
.form-check-input:checked { background-color: var(--ag-primary); border-color: var(--ag-primary); }
.form-switch .form-check-input { width: 2.6em; height: 1.4em; margin-top: .1em; cursor: pointer; }
.form-switch .form-check-label { cursor: pointer; font-weight: 600; padding-inline-start: .35rem; }
.form-check-input:focus { border-color: var(--ag-primary); box-shadow: var(--ag-ring); }
.form-switch .form-check-input:focus { --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%2364d2c6'/%3e%3c/svg%3e"); }
.input-group-text { background: #F8FAFC; border-color: var(--ag-border-strong); color: var(--ag-muted); }
.input-group > .form-control, .input-group > .form-select, .input-group > .input-group-text, .input-group > .btn { border-radius: 10px; }

/* ------------------------------------------------------------- tables */
/* Tables that are not already inside a card are wrapped by the layout in
   .ag-table-wrap: a white rounded panel that also scrolls sideways on a
   narrow screen instead of pushing the whole page wider. */
.ag-table-wrap {
  background: var(--ag-surface);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-lg);
  box-shadow: var(--ag-shadow);
  overflow-x: auto;
  margin-top: 1rem;
  margin-bottom: 1rem;
  padding: 0 !important;
}
.ag-table-wrap > .table { margin: 0 !important; }
/* Inside a .row the wrapper keeps the gutter the table used to have. */
.row > .ag-table-wrap {
  width: calc(100% - var(--bs-gutter-x));
  flex: 0 0 auto;
  margin-inline: calc(var(--bs-gutter-x) * .5);
}
/* Bordered tables inside the panel drop their outer frame - the panel is it. */
.ag-table-wrap > .table-bordered { border-style: hidden; }

.app-main .table {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--ag-border);
  --bs-table-striped-bg: #F8FAFC;
  --bs-table-hover-bg: var(--ag-primary-50);
  color: var(--ag-ink);
  vertical-align: middle;
  font-size: .92rem;
}
.app-main .table > :not(caption) > * > * { padding: .7rem .8rem; }
.app-main .table-sm > :not(caption) > * > * { padding: .45rem .6rem; }

/* Header row: `.table-dark` everywhere becomes the light brand header. */
.app-main .table > thead > tr > th,
.app-main .table > thead.table-dark > tr > th,
.app-main .table > thead > tr.table-dark > th,
.app-main .table .table-dark,
.app-main .table thead.table-light th {
  --bs-table-bg: var(--ag-head-bg);
  --bs-table-color: var(--ag-ink);
  --bs-table-border-color: var(--ag-border);
  background-color: var(--ag-head-bg);
  color: #334155;
  font-weight: 700;
  font-size: .82rem;
  white-space: nowrap;
  border-bottom: 1px solid var(--ag-border-strong);
}
.app-main .table-dark { --bs-table-bg: var(--ag-head-bg); --bs-table-color: var(--ag-ink); --bs-table-border-color: var(--ag-border); color: var(--ag-ink); }

/* Every body row reacts to the pointer, so the eye can follow it across. */
.app-main .table > tbody > tr:hover > * { --bs-table-bg-state: var(--ag-primary-50); }

/* Row selection: many screens select a record with a radio in the last
   column before Edit/Delete. The layout makes the whole row clickable;
   this shows which one is picked. */
.app-main .table > tbody > tr:has(> td input[type=radio]) { cursor: pointer; }
.app-main .table > tbody > tr:has(> td input[type=radio]:checked) > * {
  --bs-table-bg-state: rgba(var(--ag-primary-rgb), .12);
  box-shadow: inset 0 0 0 9999px rgba(var(--ag-primary-rgb), .12);
}
.app-main .table > tbody > tr:has(> td input[type=radio]:checked) > td:first-child {
  box-shadow: inset -3px 0 0 var(--ag-primary), inset 0 0 0 9999px rgba(var(--ag-primary-rgb), .12);
}
.app-main .table input[type=radio] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--ag-primary);
  cursor: pointer;
  vertical-align: middle;
}
.app-main .table img { border-radius: 8px; }

/* Empty-state rows ("لا توجد بيانات", "جارٍ التحميل...") */
.app-main .table td.text-muted[colspan] { padding: 2rem 1rem; text-align: center; }

/* Long tables scroll inside their panel so the header row stays visible. */
.ag-table-wrap { max-height: max(360px, calc(100vh - 250px)); overflow: auto; }
.ag-table-wrap > .table > thead > tr > th { position: sticky; top: 0; z-index: 2; }
.ag-table-wrap > .table > thead > tr > th::after {
  /* Collapsed borders scroll away with the body; this line stays. */
  content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 1px; background: var(--ag-border-strong);
}

/* Search + count above a table */
.ag-table-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  margin-bottom: -.35rem;
}
.row > .ag-table-tools { width: calc(100% - var(--bs-gutter-x)); margin-inline: calc(var(--bs-gutter-x) * .5); padding: 0; }
.ag-search { position: relative; flex: 0 1 320px; margin: 0; }
.ag-search .bi { position: absolute; inset-inline-start: .8rem; top: 50%; transform: translateY(-50%); color: #94A3B8; pointer-events: none; }
.ag-search .form-control { padding-inline-start: 2.3rem; background: #fff; height: 40px; }
.ag-count { color: var(--ag-muted); font-size: .85rem; font-weight: 600; }
tr.ag-filtered-out { display: none; }

/* Empty / loading state under a table */
.ag-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: 2.25rem 1rem;
  color: var(--ag-muted);
  font-size: .95rem;
}
.ag-empty[hidden] { display: none; }
.ag-empty .bi { font-size: 1.35rem; opacity: .7; }

/* Booking status badges */
.ag-status {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .65rem; border-radius: 999px;
  font-size: .8rem; font-weight: 700; white-space: nowrap;
}
.ag-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ag-status-new { background: #FEF3C7; color: #B45309; }
.ag-status-accepted { background: #DCFCE7; color: #15803D; }
.ag-status-finished { background: #E2E8F0; color: #334155; }
.ag-status-closed { background: #FEE2E2; color: #B91C1C; }

/* "View" action in the bookings table */
.ag-view-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  color: var(--ag-primary); background: var(--ag-primary-50);
  cursor: pointer; transition: background-color .15s ease;
}
.ag-view-btn:hover { background: rgba(var(--ag-primary-rgb), .18); }

/* ------------------------------------------------------------ toasts */
.ag-toasts {
  position: fixed;
  top: 76px;
  inset-inline-start: 50%;
  transform: translateX(50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  width: min(440px, calc(100vw - 2rem));
  pointer-events: none;
}
.ag-toast {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  padding: .85rem .9rem;
  background: #fff;
  border: 1px solid var(--ag-border);
  border-inline-start: 4px solid var(--ag-tone, var(--ag-primary));
  border-radius: 12px;
  box-shadow: var(--ag-shadow-lg);
  color: var(--ag-ink);
  font-weight: 600;
  line-height: 1.6;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .2s ease, transform .2s ease;
}
.ag-toast.show { opacity: 1; transform: none; }
.ag-toast-icon { color: var(--ag-tone); font-size: 1.2rem; line-height: 1.4; }
.ag-toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ag-toast-close {
  border: 0; background: transparent; color: #94A3B8;
  width: 28px; height: 28px; border-radius: 7px; flex: 0 0 auto;
}
.ag-toast-close:hover { background: #F1F5F9; color: var(--ag-ink); }
.ag-toast-success { --ag-tone: var(--ag-emerald); }
.ag-toast-error { --ag-tone: var(--ag-danger); }
.ag-toast-warning { --ag-tone: var(--ag-gold); }
.ag-toast-info { --ag-tone: var(--ag-primary); }

/* ----------------------------------------------------- confirm dialog */
.ag-confirm {
  position: fixed; inset: 0; z-index: 2500;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, .45);
  opacity: 0; transition: opacity .18s ease;
}
.ag-confirm.show { opacity: 1; }
.ag-confirm-box {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--ag-shadow-lg);
  padding: 1.75rem 1.5rem 1.4rem;
  text-align: center;
  transform: scale(.96); transition: transform .18s ease;
}
.ag-confirm.show .ag-confirm-box { transform: none; }
.ag-confirm-icon {
  width: 56px; height: 56px; margin: 0 auto 1rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 1.5rem;
  background: var(--ag-primary-50); color: var(--ag-primary);
}
.ag-confirm-icon.danger { background: #FEE2E2; color: var(--ag-danger); }
.ag-confirm-box h5 { font-weight: 800; color: var(--ag-ink); margin-bottom: .5rem; }
.ag-confirm-box p { color: var(--ag-muted); margin-bottom: 1.4rem; line-height: 1.7; overflow-wrap: anywhere; }
.ag-confirm-actions { display: flex; gap: .6rem; justify-content: center; }
.ag-confirm-actions .btn { min-width: 120px; }

/* ------------------------------------------------- busy (saving) state */
.btn.ag-busy, button.ag-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.ag-busy > *, button.ag-busy > * { visibility: hidden; }
.btn.ag-busy::after, button.ag-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 1.1rem; height: 1.1rem; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .55); border-top-color: #fff;
  animation: ag-spin .7s linear infinite;
}
.btn-outline-secondary.ag-busy::after, .btn.border.ag-busy::after, .btn-default.ag-busy::after,
.btn-outline-primary.ag-busy::after, .btn-outline-success.ag-busy::after {
  border-color: rgba(15, 23, 42, .2); border-top-color: var(--ag-primary);
}
@keyframes ag-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------ image upload preview */
.ag-file-preview {
  display: flex; align-items: center; gap: .75rem;
  margin: .4rem 0 .6rem;
  padding: .45rem;
  border: 1px dashed var(--ag-border-strong);
  border-radius: 10px;
  background: #F8FAFC;
  color: var(--ag-muted);
  font-size: .82rem;
}
.ag-file-preview img {
  width: 64px; height: 64px; object-fit: contain;
  border-radius: 8px; background: #fff; border: 1px solid var(--ag-border);
}

/* ---------------------------------------------------------- nav tabs */
.app-main .nav-tabs {
  border: 0;
  gap: .35rem;
  padding: .3rem;
  background: #fff;
  border: 1px solid var(--ag-border);
  border-radius: 12px;
  box-shadow: var(--ag-shadow-sm);
  flex-wrap: wrap;
}
.app-main .nav-tabs .nav-link {
  border: 0;
  border-radius: 9px;
  color: var(--ag-muted);
  font-weight: 600;
  padding: .45rem .9rem;
  margin: 0;
}
.app-main .nav-tabs .nav-link:hover { color: var(--ag-ink); background: #F1F5F9; }
.app-main .nav-tabs .nav-link.active {
  color: #fff;
  background: var(--ag-primary);
  box-shadow: 0 2px 8px rgba(var(--ag-primary-rgb), .3);
}
.app-main .nav-pills .nav-link.active { background: var(--ag-primary); }

/* ------------------------------------------------------------- modals */
.modal-content {
  border: 0;
  border-radius: var(--ag-radius-lg);
  box-shadow: var(--ag-shadow-lg);
  overflow: hidden;
}
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--ag-border);
  background: #fff;
}
.modal-header .modal-title { font-weight: 800; font-size: 1.1rem; color: var(--ag-ink); }
/* Coloured headers (bg-success, bg-primary) become one brand header. */
.modal-header.bg-success, .modal-header.bg-primary, .modal-header.bg-info, .modal-header.bg-dark {
  background: var(--ag-primary) !important;
  border-bottom-color: transparent;
}
.modal-header.bg-success .modal-title, .modal-header.bg-primary .modal-title,
.modal-header.bg-info .modal-title, .modal-header.bg-dark .modal-title,
.modal-header.text-white .modal-title { color: #fff; }
.modal-header .btn-close { margin: 0; margin-inline-start: auto; }
.modal-body { padding: 1.25rem; }
.modal-footer { border-top: 1px solid var(--ag-border); background: #F8FAFC; padding: .8rem 1.25rem; gap: .5rem; }
.modal-backdrop.show { opacity: .45; }
/* Bootstrap 4 style close button still used by one modal. */
.modal-header .close {
  background: none;
  border: 0;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ag-muted);
  margin-inline-start: auto;
}

/* Side-label rows (admins, branches) write the input before its label. In
   the old LTR layout that put the label on the right; reversing the row
   keeps it there now that the page reads right-to-left. */
.d-flex.align-items-center:has(> label.form-label:last-child):has(> .form-control, > .form-select) {
  flex-direction: row-reverse;
  gap: .25rem;
}
.d-flex.align-items-center:has(> label.form-label:last-child) > label.form-label {
  margin: 0 !important;
  flex: 0 0 auto;
  color: var(--ag-muted);
}

/* Forms inside modals: the submit / close pair at the end of the body. */
.modal-body form > .btn:last-of-type { margin-top: .5rem; }
.modal-body form > .btn + .btn { margin-inline-start: .35rem; }

/* ------------------------------------------------- alerts and badges */
.alert { border-radius: var(--ag-radius); border-width: 0; border-inline-start: 4px solid currentColor; }
.alert-info { background: var(--ag-primary-50); color: var(--ag-primary-700); }
.badge { font-weight: 600; border-radius: 6px; padding: .35em .6em; }
.badge.rounded-pill { border-radius: 999px; }

/* ------------------------------------------------------- dropdowns */
.dropdown-menu {
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius);
  box-shadow: var(--ag-shadow-lg);
}
.dropdown-item:active, .dropdown-item.active { background: var(--ag-primary); }

/* --------------------------------------------------- pagination etc */
.pagination { --bs-pagination-active-bg: var(--ag-primary); --bs-pagination-active-border-color: var(--ag-primary); --bs-pagination-color: var(--ag-primary); --bs-pagination-border-radius: 8px; }
.progress-bar { background-color: var(--ag-primary); }
.accordion { --bs-accordion-active-bg: var(--ag-primary-50); --bs-accordion-active-color: var(--ag-primary-700); --bs-accordion-btn-focus-box-shadow: var(--ag-ring); }

/* Report money column totals keep their own emphasis, in the brand tint. */
.report-table tfoot td {
  background-color: var(--ag-primary-50) !important;
  color: var(--ag-primary-700) !important;
  border-top: 2px solid rgba(var(--ag-primary-rgb), .35) !important;
}

/* ------------------------------------------------------------- footer */
.app-footer {
  background: transparent;
  border-top: 1px solid var(--ag-border);
  color: var(--ag-muted);
  font-size: .82rem;
  padding: .9rem 1.25rem;
}
.app-footer a { color: var(--ag-muted); }

/* ---------------------------------------------------------- scrollbars */
.app-main ::-webkit-scrollbar { height: 10px; width: 10px; }
.app-main ::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; border: 2px solid #fff; }
.app-main ::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------- small screens */
@media (max-width: 767.98px) {
  .app-main .app-content-header { padding: 1rem .25rem 1.5rem; }
  .app-main h1.title { font-size: 1.2rem; }
  .app-main .container { padding-inline: .5rem; }
  .modal-body { padding: 1rem; }
}

/* ===================================================================
   Sign-in and registration pages (login.ejs, register.ejs)
   =================================================================== */
.ag-auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  background: var(--ag-bg);
  font-family: var(--bs-body-font-family);
}
.ag-auth-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem;
  color: #fff;
  background:
    radial-gradient(circle at 15% 15%, rgba(255, 255, 255, .14) 0, transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(255, 255, 255, .10) 0, transparent 45%),
    linear-gradient(150deg, #11968B 0%, var(--ag-primary) 45%, #0A4F49 100%);
}
.ag-auth-brand img { width: 180px; max-width: 60%; }
.ag-auth-brand h2 { font-weight: 800; font-size: 2rem; line-height: 1.4; margin: 0 0 .75rem; color: #fff; }
.ag-auth-brand p { color: rgba(255, 255, 255, .82); font-size: 1.05rem; max-width: 30rem; margin: 0; }
.ag-auth-points { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: .8rem; }
.ag-auth-points li { display: flex; align-items: center; gap: .65rem; color: rgba(255, 255, 255, .92); }
.ag-auth-points i {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(255, 255, 255, .14);
}
.ag-auth-foot { color: rgba(255, 255, 255, .6); font-size: .85rem; }

.ag-auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.25rem;
}
.ag-auth-card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border: 1px solid var(--ag-border);
  border-radius: 20px;
  box-shadow: var(--ag-shadow);
  padding: 2.25rem 2rem;
}
.ag-auth-card.wide { max-width: 640px; }
.ag-auth-card .ag-auth-logo { display: none; text-align: center; margin-bottom: 1.25rem; }
.ag-auth-card .ag-auth-logo img { width: 140px; }
.ag-auth-card h1 { font-size: 1.55rem; font-weight: 800; color: var(--ag-ink); margin: 0 0 .35rem; }
.ag-auth-card .ag-auth-sub { color: var(--ag-muted); margin: 0 0 1.75rem; }
.ag-auth-card .form-label { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; display: block; }
.ag-auth-card .form-control {
  height: auto;
  padding: .7rem .95rem;
  border-radius: 12px;
  border: 1px solid var(--ag-border-strong);
  background: #fff;
  font-size: 1rem;
  box-shadow: none;
}
.ag-auth-card .form-control:focus { border-color: var(--ag-primary); box-shadow: var(--ag-ring); }
.ag-field { position: relative; margin-bottom: 1rem; }
.ag-field .ag-field-icon {
  position: absolute;
  inset-inline-start: .9rem;
  bottom: .78rem;
  color: #94A3B8;
  pointer-events: none;
  font-size: 1.05rem;
}
.ag-field .form-control.has-icon { padding-inline-start: 2.6rem; }
.ag-field .ag-eye {
  position: absolute;
  inset-inline-end: .55rem;
  bottom: .42rem;
  border: 0;
  background: transparent;
  color: var(--ag-muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
}
.ag-field .ag-eye:hover { background: #F1F5F9; color: var(--ag-ink); }
.ag-auth-btn {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: .8rem 1rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  background: var(--ag-primary);
  box-shadow: 0 6px 16px rgba(var(--ag-primary-rgb), .3);
  transition: background-color .15s ease, transform .05s ease;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  cursor: pointer;
}
.ag-auth-btn:hover { background: var(--ag-primary-600); color: #fff; }
.ag-auth-btn:active { transform: translateY(1px); }
.ag-auth-btn:disabled { opacity: .7; cursor: progress; }
.ag-auth-btn.ghost {
  background: #fff;
  color: var(--ag-primary);
  border: 1px solid rgba(var(--ag-primary-rgb), .35);
  box-shadow: none;
  text-decoration: none;
}
.ag-auth-btn.ghost:hover { background: var(--ag-primary-50); color: var(--ag-primary-700); }
.ag-auth-link { color: var(--ag-primary); font-weight: 600; text-decoration: none; font-size: .9rem; }
.ag-auth-link:hover { text-decoration: underline; color: var(--ag-primary-700); }
.ag-divider {
  display: flex; align-items: center; gap: .75rem;
  color: #94A3B8; font-size: .85rem; margin: 1.5rem 0;
}
.ag-divider::before, .ag-divider::after { content: ""; flex: 1; height: 1px; background: var(--ag-border); }
.ag-section-title {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 700; color: var(--ag-primary-700);
  background: var(--ag-primary-50);
  border-radius: 10px;
  padding: .55rem .85rem;
  margin: .5rem 0 1rem;
  font-size: .95rem;
}

@media (max-width: 991.98px) {
  .ag-auth { grid-template-columns: 1fr; }
  .ag-auth-brand { display: none; }
  .ag-auth-card .ag-auth-logo { display: block; }
}
@media (max-width: 575.98px) {
  .ag-auth-card { padding: 1.75rem 1.25rem; border-radius: 16px; }
}
