/* ============================================================
   SSC "calm professional" design system.
   Tokens from ssc.shj.ae (.ssc theme) + component styles.
   Loaded AFTER Bootstrap; overrides use Bootstrap CSS variables
   wherever possible so RTL/LTR bundles both inherit them.
   ============================================================ */

:root {
  --ssc-navy: #183254;
  --ssc-blue: #114C99;
  --ssc-blue-hover: #0E3F80;
  --ssc-blue-active: #0C376F;
  --ssc-gold: #DFC07F;
  --ssc-ink: #1C2B3A;
  --ssc-muted: #667180;
  --ssc-ground: #F6F7F9;
  --ssc-border: #E6E9EE;
  --ssc-row-border: #F0F2F5;
  --ssc-success: #147F40;
  --ssc-error: #DB3B21;

  --ssc-side-text: #C8D3E0;
  --ssc-side-link: #B9C6D8;
  --ssc-side-muted: #8FA3BD;
  --ssc-side-user: #E6ECF3;
  --ssc-side-danger: #FF9C8B;

  --bs-body-bg: var(--ssc-ground);
  --bs-body-color: var(--ssc-ink);
  --bs-border-color: var(--ssc-border);
  --bs-border-radius: .625rem;
  --bs-border-radius-lg: .75rem;
  --bs-link-color: var(--ssc-blue);
  --bs-link-hover-color: var(--ssc-blue-hover);
  --bs-link-color-rgb: 17, 76, 153;
  --bs-link-hover-color-rgb: 14, 63, 128;
  --bs-body-color-rgb: 28, 43, 58;
  --bs-body-bg-rgb: 246, 247, 249;
  --bs-btn-focus-shadow-rgb: 17, 76, 153;
}

body {
  font-family: 'Alexandria', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--ssc-ground);
  color: var(--ssc-ink);
}

/* ---------- app shell ---------- */

.app-body { display: flex; min-height: 100vh; }
.app-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-main { flex: 1; width: 100%; max-width: 1400px; margin-inline: auto; padding: 1.5rem clamp(1rem, 3vw, 2.25rem); }

.app-sidebar {
  --bs-offcanvas-width: 270px;
  flex-shrink: 0;
  background: var(--ssc-navy);
  color: var(--ssc-side-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
@media (min-width: 992px) {
  .app-sidebar { width: 250px; position: sticky; top: 0; height: 100vh; background-color: var(--ssc-navy) !important; }
}

.side-brand { padding: 1.5rem 1.25rem 1.1rem; }
/* Logo art is dark on transparent, so it sits on a white chip to stay legible on navy. */
.side-brand-logo { display: block; background: #fff; border-radius: .6rem; padding: .6rem .75rem; margin-bottom: .95rem; }
.side-brand-logo img { display: block; width: 100%; height: auto; }
.side-brand-name { display: block; color: #fff; font-weight: 600; font-size: 1.02rem; text-decoration: none; }
.side-brand-name:hover, .side-brand-name:focus { color: #fff; }
.side-brand-rule { width: 26px; height: 2px; background: var(--ssc-gold); border-radius: 1px; margin-top: .8rem; }

.side-nav { padding: .75rem .5rem; display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .8rem;
  border-radius: .5rem;
  border-inline-start: 3px solid transparent;
  color: var(--ssc-side-link); text-decoration: none; font-size: .92rem;
}
.side-link .bi { font-size: 1rem; }
.side-link:hover, .side-link:focus { color: #fff; background: rgba(255, 255, 255, .05); }
.side-link.active {
  color: #fff; font-weight: 500;
  background: rgba(255, 255, 255, .08);
  border-inline-start-color: var(--ssc-gold);
}
.side-nav-section {
  margin-top: .55rem;
  padding: .75rem .85rem .1rem;
  border-top: 1px solid rgba(255, 255, 255, .09);
  color: var(--ssc-side-muted);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.side-footer {
  margin-top: auto;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, .1);
  display: flex; flex-direction: column; gap: .35rem;
}
.side-user { color: var(--ssc-side-user); font-size: .9rem; font-weight: 500; display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; overflow-wrap: anywhere; }
.side-link-sm { color: var(--ssc-side-muted); font-size: .8rem; text-decoration: none; display: flex; align-items: center; gap: .45rem; padding: .15rem 0; }
.side-link-sm:hover, .side-link-sm:focus { color: #fff; }
.side-logout:hover, .side-logout:focus { color: var(--ssc-side-danger); }

.app-topbar {
  position: sticky; top: 0; z-index: 1030;
  background: var(--ssc-navy); color: #fff;
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem;
}
.topbar-toggle { background: none; border: 0; color: #fff; font-size: 1.4rem; line-height: 1; padding: .1rem .3rem; }
.topbar-brand { font-weight: 600; font-size: .95rem; }

/* ---------- auth (chrome-less) pages ---------- */

.auth-body { background: var(--ssc-navy); }
.auth-main {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.auth-main .alert { width: 100%; max-width: 400px; }
.auth-card { background: #fff; border-radius: .9rem; padding: 2.25rem 2rem; width: 100%; max-width: 400px; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand-logo { display: block; width: min(230px, 85%); height: auto; margin: 0 auto 1rem; }
.auth-brand-name { font-weight: 600; font-size: 1.15rem; color: var(--ssc-navy); margin: 0; }
.auth-brand-rule { width: 28px; height: 2px; background: var(--ssc-gold); border-radius: 1px; margin: .9rem auto 0; }
.auth-gov { text-align: center; margin-top: 1.4rem; padding-top: 1.1rem; border-top: 1px solid var(--ssc-border); }
.auth-gov-logo { width: 118px; height: auto; }
.auth-lang { text-align: center; margin-top: 1rem; font-size: .85rem; }

/* ---------- page scaffolding ---------- */

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-title { font-size: 1.45rem; font-weight: 600; margin: 0; color: var(--ssc-ink); }
.page-sub { color: var(--ssc-muted); font-size: .85rem; margin-top: .15rem; }
.page-actions { display: flex; gap: .5rem; align-items: center; }

/* ---------- cards / panels ---------- */

.card { border: 1px solid var(--ssc-border); box-shadow: none; background: #fff; }
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--ssc-border);
  color: var(--ssc-ink); font-weight: 600; font-size: .92rem;
  padding: .85rem 1.1rem;
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
}
.card-header .card-link { font-size: .82rem; font-weight: 400; text-decoration: none; }

/* ---------- KPI tiles ---------- */

.kpi-card { background: #fff; border: 1px solid var(--ssc-border); border-radius: var(--bs-border-radius-lg); padding: .9rem 1.1rem; height: 100%; }
.kpi-card.kpi-accent { border-top: 2px solid var(--ssc-gold); }
.kpi-value { font-size: 1.6rem; font-weight: 600; color: var(--ssc-ink); line-height: 1.25; }
.kpi-label { font-size: .78rem; color: var(--ssc-muted); }
.kpi-sub { font-size: .74rem; color: var(--ssc-muted); margin-top: .2rem; display: flex; gap: .6rem; flex-wrap: wrap; }

/* ---------- report summary band ---------- */

.report-summary { background: var(--ssc-navy); border-radius: .9rem; padding: 1.25rem 1.35rem; }
.report-summary-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.summary-title { color: #fff; font-weight: 600; font-size: .95rem; }
.summary-rule { width: 26px; height: 2px; background: var(--ssc-gold); border-radius: 1px; }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; }
/* Base size applies at every width (2-col phone, 3-col tablet/print, and the
   narrow band just under 1200px) so the money tile always has a wrap
   opportunity; overflow-wrap guarantees no horizontal spill even for an
   unusually long total. The >=1200px rule below is a narrower override for
   the 6-column desktop layout only — keep both, they protect different
   widths. */
.summary-tile-money .summary-value { font-size: clamp(1rem, 3.2vw, 1.75rem); overflow-wrap: anywhere; }
@media (min-width: 1200px) {
  .summary-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .summary-grid-6 .summary-tile-money .summary-value { font-size: clamp(.9rem, 1.25vw, 1.35rem); }
}
@media (max-width: 1199.98px) { .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 767.98px) { .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.summary-tile { background: rgba(255, 255, 255, .07); border: 1px solid transparent; border-radius: .75rem; padding: .9rem 1rem; }
.summary-tile-accent { border-color: rgba(223, 192, 127, .55); }
.summary-icon { color: var(--ssc-gold); font-size: 1.25rem; display: block; line-height: 1; }
.summary-icon-silver { color: #C3CAD3; }
.summary-icon-bronze { color: #C89B6A; }
.summary-value { color: #fff; font-size: 1.75rem; font-weight: 700; line-height: 1.2; margin-top: .35rem; }
.summary-tile-accent .summary-value { color: var(--ssc-gold); }
.summary-label { color: var(--ssc-side-text); font-size: .74rem; }

/* ---------- year-grouped report results ---------- */

.year-head { display: flex; align-items: center; gap: .65rem; padding: .95rem 1.1rem .45rem; }
.year-label { font-weight: 700; color: var(--ssc-navy); font-size: .95rem; }
.year-tick { width: 22px; height: 2px; background: var(--ssc-gold); border-radius: 1px; flex-shrink: 0; }
.year-line { flex: 1; height: 1px; background: var(--ssc-border); }
.year-meta { color: var(--ssc-muted); font-size: .74rem; white-space: nowrap; }

.report-row {
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
  padding: .8rem 1.1rem;
  border-bottom: 1px solid var(--ssc-row-border);
}
.report-row-main { flex: 1 1 260px; min-width: 0; }
.report-row-club { flex: 0 0 170px; font-size: .85rem; }
.report-row-total { text-align: center; min-width: 3.2rem; }
.report-row-reward { flex: 0 0 auto; min-width: 5.5rem; text-align: center; font-size: .85rem; font-weight: 700; color: var(--ssc-navy); white-space: nowrap; }
.total-num { display: block; font-size: 1.15rem; font-weight: 700; color: var(--ssc-navy); line-height: 1.15; }
.total-unit { display: block; font-size: .64rem; color: var(--ssc-muted); }

.report-totals {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .85rem 1.1rem; margin-top: -1px;
  background: #F8FAFC; border-top: 2px solid var(--ssc-border);
}
.totals-label { font-weight: 600; font-size: .85rem; flex: 1; }
.total-chip { border-radius: 2rem; padding: .3rem .8rem; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.total-chip-gold { background: #F7F0DD; color: #7A6118; }
.total-chip-silver { background: #F0F2F5; color: #5E6873; }
.total-chip-bronze { background: #F4E9DC; color: #8A5A2B; }
.total-chip-navy { background: var(--ssc-navy); color: #fff; }

/* ---------- filter toolbar ---------- */

.filter-toolbar {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  background: #fff; border: 1px solid var(--ssc-border);
  border-radius: var(--bs-border-radius-lg);
  padding: .6rem .75rem; margin-bottom: 1rem;
}
.filter-toolbar .toolbar-search { flex: 1 1 220px; min-width: 180px; }
.filter-toolbar .toolbar-search .form-control { border-radius: 2rem; font-size: .88rem; }
.filter-toolbar .btn { border-radius: 2rem; }
/* Date inputs in a toolbar share the same chip look as selects, but with
   symmetric padding — they have no dropdown arrow to fill a wide
   inline-end gutter. */
.toolbar-select, .toolbar-date {
  width: auto; font-size: .85rem; border-radius: 2rem;
  padding-block: .35rem; padding-inline: .9rem 2rem;
  border-color: var(--ssc-border); color: var(--ssc-ink); background-color: #fff;
}
.toolbar-date { max-width: 11rem; padding-inline: .9rem; }
.toolbar-select.has-value, .toolbar-date.has-value { border-color: var(--ssc-blue); color: var(--ssc-blue); background-color: #EEF3FB; font-weight: 500; }

/* ---------- badges & medal pills ---------- */

.badge-type { display: inline-block; padding: .25em .6em; border-radius: .35rem; font-size: .75rem; font-weight: 500; }
.badge-type-local { background: #EEF3FB; color: #114C99; }
.badge-type-gulf  { background: #F7F0DD; color: #7A6435; }
.badge-type-arab  { background: #F7ECE7; color: #9A4E2E; }
.badge-type-asia  { background: #E8F4EE; color: #1A6E42; }
.badge-type-world { background: #E9EEF7; color: #183254; }
.badge-type-unknown { background: #EEF0F2; color: #5E6873; }

.medal-pills { display: inline-flex; gap: .25rem; }
.medal-pill { min-width: 1.7em; text-align: center; padding: .15em .45em; border-radius: .35rem; font-size: .78rem; font-weight: 500; }
.medal-gold   { background: #F7F0DD; color: #7A6118; }
.medal-silver { background: #F0F2F5; color: #5E6873; }
.medal-bronze { background: #F4E9DC; color: #8A5A2B; }
.medal-pill.medal-zero { background: #FAFBFC; color: #A9B2BC; }

/* ---------- tables ---------- */

.table { --bs-table-hover-bg: #F8FAFC; }

/* DataTables 2's stylesheet is LTR-only: it hardcodes text-align:left on
   thead/tfoot cells and pins the sort icon with right/padding-right, which
   flips the header row to LTR on the Arabic pages. Re-state those rules
   with logical properties — theme.css loads after the CDN css, and these
   selectors match or beat the vendor specificity, so they win either way. */
table.dataTable thead > tr > th,
table.dataTable thead > tr > td,
table.dataTable tfoot > tr > th,
table.dataTable tfoot > tr > td { text-align: start; }
table.dataTable thead > tr > th.dt-orderable-asc,
table.dataTable thead > tr > th.dt-orderable-desc,
table.dataTable thead > tr > th.dt-ordering-asc,
table.dataTable thead > tr > th.dt-ordering-desc,
table.dataTable thead > tr > td.dt-orderable-asc,
table.dataTable thead > tr > td.dt-orderable-desc,
table.dataTable thead > tr > td.dt-ordering-asc,
table.dataTable thead > tr > td.dt-ordering-desc {
  padding-right: .5rem;     /* undo the vendor's physical 30px gutter... */
  padding-inline-end: 30px; /* ...and re-add it on the sort-icon side */
}
table.dataTable thead > tr > th.dt-orderable-asc span.dt-column-order,
table.dataTable thead > tr > th.dt-orderable-desc span.dt-column-order,
table.dataTable thead > tr > th.dt-ordering-asc span.dt-column-order,
table.dataTable thead > tr > th.dt-ordering-desc span.dt-column-order,
table.dataTable thead > tr > td.dt-orderable-asc span.dt-column-order,
table.dataTable thead > tr > td.dt-orderable-desc span.dt-column-order,
table.dataTable thead > tr > td.dt-ordering-asc span.dt-column-order,
table.dataTable thead > tr > td.dt-ordering-desc span.dt-column-order {
  right: auto;
  inset-inline-end: 12px;
}
.table > :not(caption) > * > * { vertical-align: middle; }
.table thead th {
  background: #F4F6F9; color: #5E6873;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
  border-bottom: 1px solid var(--ssc-border);
}
.table td { border-color: var(--ssc-row-border); }
.cell-title { display: block; font-weight: 500; color: var(--ssc-ink); }
.cell-sub { display: block; font-size: .75rem; color: var(--ssc-muted); margin-top: .1rem; }
.cell-date { color: var(--ssc-muted); }
.actions-cell { white-space: nowrap; }

/* ---------- empty states ---------- */

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ssc-muted); }
.empty-state .bi { font-size: 2rem; color: #C3CAD3; display: block; margin-bottom: .5rem; }
.empty-state p { margin-bottom: .9rem; }

/* ---------- buttons ---------- */

.btn-primary {
  --bs-btn-bg: var(--ssc-blue); --bs-btn-border-color: var(--ssc-blue);
  --bs-btn-hover-bg: var(--ssc-blue-hover); --bs-btn-hover-border-color: var(--ssc-blue-hover);
  --bs-btn-active-bg: var(--ssc-blue-active); --bs-btn-active-border-color: var(--ssc-blue-active);
  --bs-btn-disabled-bg: #7EA0C9; --bs-btn-disabled-border-color: #7EA0C9;
  --bs-btn-focus-shadow-rgb: 17, 76, 153;
}
.btn-outline-primary {
  --bs-btn-color: var(--ssc-blue); --bs-btn-border-color: #BFD0E5;
  --bs-btn-hover-bg: var(--ssc-blue); --bs-btn-hover-border-color: var(--ssc-blue);
  --bs-btn-active-bg: var(--ssc-blue-active); --bs-btn-active-border-color: var(--ssc-blue-active);
  --bs-btn-focus-shadow-rgb: 17, 76, 153;
}
.btn-success { --bs-btn-bg: var(--ssc-success); --bs-btn-border-color: var(--ssc-success); --bs-btn-hover-bg: #116A36; --bs-btn-hover-border-color: #116A36; --bs-btn-active-bg: #0E5A2E; --bs-btn-active-border-color: #0E5A2E; --bs-btn-focus-shadow-rgb: 20, 127, 64; }
.btn-icon { --bs-btn-padding-y: .25rem; --bs-btn-padding-x: .5rem; }

/* ---------- forms ---------- */

.form-label { font-size: .85rem; font-weight: 500; color: var(--ssc-ink); }
.form-control:focus, .form-select:focus {
  border-color: var(--ssc-blue);
  box-shadow: 0 0 0 .2rem rgba(17, 76, 153, .15);
}
.form-section { border: 0; padding: 0; margin: 0 0 1.5rem; }
.form-section > legend {
  float: none; width: 100%;
  font-size: .8rem; font-weight: 600; color: var(--ssc-muted); letter-spacing: .3px;
  border-bottom: 1px solid var(--ssc-border);
  padding-bottom: .4rem; margin-bottom: 1rem;
}
.medal-field .form-label { font-weight: 600; }
.medal-field-gold .form-label { color: #8A6D1D; }
.medal-field-silver .form-label { color: #5E6873; }
.medal-field-bronze .form-label { color: #8A5A2B; }

/* ---------- pagination ---------- */

.pagination {
  --bs-pagination-color: var(--ssc-blue);
  --bs-pagination-hover-color: var(--ssc-blue-hover);
  --bs-pagination-focus-color: var(--ssc-blue-hover);
  --bs-pagination-active-bg: var(--ssc-blue);
  --bs-pagination-active-border-color: var(--ssc-blue);
}

/* ---------- charts ---------- */

.chart-body { position: relative; height: 280px; }

/* ---------- accessibility ---------- */

:focus-visible { outline: 2px solid var(--ssc-blue); outline-offset: 2px; }
.app-sidebar :focus-visible, .app-topbar :focus-visible { outline-color: var(--ssc-gold); }

/* ---------- print ---------- */

.print-header { display: none; }
@media print {
  .no-print, .app-sidebar, .app-topbar, .pagination,
  .dt-search, .dt-paging, .dt-info, .dt-length {
    display: none !important;
  }
  body, .app-body { background: #fff !important; display: block; }
  .app-main { padding: 0 !important; max-width: none; }
  .print-header { display: block !important; text-align: center; margin-bottom: 1rem; }
  .print-header-logos { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
  .print-header-logos img { height: 42px; width: auto; }
  .print-header h2 { font-size: 1.45rem; font-weight: 600; margin: 0; }
  .print-header h3 { font-size: 1.1rem; font-weight: 500; margin: .25rem 0 0; }
  .card, .kpi-card { border-color: #bbb; box-shadow: none; }
  /* Browsers skip background paint by default, so the navy band flips to a
     bordered white card with dark text instead of white-on-white. */
  .report-summary { background: #fff !important; border: 1px solid #bbb; }
  .summary-title, .summary-value { color: var(--ssc-ink); }
  .summary-tile { background: #fff; border: 1px solid #ddd; }
  .summary-tile-accent { border-color: #C7A659; }
  .summary-icon, .summary-tile-accent .summary-value { color: #8A6D1D; }
  .summary-icon-silver { color: #5E6873; }
  .summary-icon-bronze { color: #8A5A2B; }
  .summary-label { color: var(--ssc-muted); }
  .total-chip { border: 1px solid #ddd; }
  .total-chip-navy { color: var(--ssc-ink); }
}
