/* ==========================================================================
   AKSP Enterprise UI — local design system (Stage 1)
   Layers on top of locally-served Bootstrap RTL. No CDN, no external fonts.
   Visual language adapted from the approved Stitch "Dignity & Service Enterprise" theme.
   ========================================================================== */
:root {
  /* Brand + surfaces — matched to the original Stitch dashboards (navy/indigo primary, light sidebar) */
  --aksp-primary: #2E6FA8;          /* Stitch navy primary (buttons/active) — white text 6.8:1 */
  --aksp-primary-600: #1F4C78;      /* hover */
  --aksp-primary-050: #E3EEF8;      /* light-blue tint (active pill / icon chip) */
  --aksp-primary-navy: #0E2A47;     /* deep brand navy (logo/brand/active text) */
  --aksp-on-primary: #ffffff;
  --aksp-bg: #F7FAFD;               /* app background */
  --aksp-surface: #ffffff;
  --aksp-text: #0f172a;            /* slate-900 */
  --aksp-text-muted: #64748b;      /* slate-500 */
  --aksp-border: #DFE9F2;          /* slate-200 */
  --aksp-sidebar: #ffffff;         /* light sidebar (Stitch) */
  --aksp-sidebar-2: #F2F7FC;
  --aksp-sidebar-text: #334155;    /* slate-700 — 10.4:1 on white */
  --aksp-sidebar-muted: #64748b;   /* slate-500 */
  --aksp-sidebar-active: #E3EEF8;  /* light-blue active pill */
  /* Status */
  --aksp-success: #1B7A4C;
  --aksp-warning: #B8860B;
  --aksp-error: #B3261E;
  --aksp-info: #2E6FA8;
  /* Metrics */
  --aksp-sidebar-w: 280px;
  --aksp-sidebar-collapsed: 72px;
  --aksp-topbar-h: 64px;
  --aksp-content-max: 1440px;
  --aksp-radius: 8px;
  --aksp-card-radius: 14px;         /* Stitch cards ~16px */
  --aksp-card-shadow: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
  --aksp-card-shadow-hover: 0 10px 30px rgba(15,23,42,.10);
  --aksp-space: 8px;
  --aksp-row-h: 48px;
  --aksp-gold: #C9A227;          /* subtle gold accent (Anba Karas identity) */
  --aksp-font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", "Cairo", system-ui, sans-serif;
}

html, body { background: var(--aksp-bg); color: var(--aksp-text); font-family: var(--aksp-font); }
body { margin: 0; }

/* ---- App shell (RTL: sidebar on the right) ---- */
.aksp-shell { display: flex; min-height: 100vh; }
.aksp-sidebar {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--aksp-sidebar-w);
  background: var(--aksp-sidebar); color: var(--aksp-sidebar-text);
  display: flex; flex-direction: column; z-index: 1040;
  transition: width .18s ease; overflow: hidden;
  border-left: 1px solid var(--aksp-border);   /* divider facing content (RTL) */
}
.aksp-sidebar__brand {
  height: var(--aksp-topbar-h); display: flex; align-items: center; gap: 10px;
  padding: 0 16px; color: var(--aksp-primary-navy); font-weight: 700;
  border-bottom: 1px solid var(--aksp-border); white-space: nowrap;
}
.aksp-sidebar__logo {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 8px;
  background: var(--aksp-primary-navy); color: #fff; display: grid; place-items: center; font-size: 18px;
}
.aksp-sidebar__nav { flex: 1; overflow-y: auto; padding: 8px; }
.aksp-nav-group { margin-bottom: 4px; }
.aksp-nav-group__label { color: var(--aksp-sidebar-muted); font-size: 11px; font-weight: 600; padding: 12px 12px 6px; letter-spacing: .02em; }
.aksp-nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: 2px 0;
  color: var(--aksp-sidebar-text); text-decoration: none; border-radius: 8px; font-size: 14px; white-space: nowrap;
}
.aksp-nav-link:hover { background: #f1f5f9; color: var(--aksp-primary-navy); }
.aksp-nav-link.is-active { background: var(--aksp-sidebar-active); color: var(--aksp-primary-navy); font-weight: 600; position: relative; }
.aksp-nav-link.is-active::before { content: ""; position: absolute; inset-inline-start: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--aksp-primary); }
.aksp-nav-link .aksp-ico { flex: 0 0 20px; width: 20px; height: 20px; display: grid; place-items: center; }
.aksp-nav-sub { padding-inline-start: 30px; }
.aksp-nav-sub .aksp-nav-link { padding: 7px 12px; font-size: 13px; color: var(--aksp-sidebar-muted); }
.aksp-nav-sub .aksp-nav-link:hover, .aksp-nav-sub .aksp-nav-link.is-active { color: var(--aksp-primary-navy); }

/* Collapsed rail */
.aksp-shell.is-collapsed .aksp-sidebar { width: var(--aksp-sidebar-collapsed); }
.aksp-shell.is-collapsed .aksp-nav-group__label,
.aksp-shell.is-collapsed .aksp-nav-link__text,
.aksp-shell.is-collapsed .aksp-brand__text,
.aksp-shell.is-collapsed .aksp-nav-sub { display: none; }
.aksp-shell.is-collapsed .aksp-nav-link { justify-content: center; }

/* Main column */
.aksp-main { flex: 1; margin-right: var(--aksp-sidebar-w); transition: margin .18s ease; min-width: 0; display: flex; flex-direction: column; }
.aksp-shell.is-collapsed .aksp-main { margin-right: var(--aksp-sidebar-collapsed); }

/* Top bar */
.aksp-topbar {
  height: var(--aksp-topbar-h); background: var(--aksp-surface); border-bottom: 1px solid var(--aksp-border);
  display: flex; align-items: center; gap: 12px; padding: 0 16px; position: sticky; top: 0; z-index: 1030;
}
.aksp-topbar__title { font-weight: 700; font-size: 16px; margin: 0; }
.aksp-iconbtn { width: 40px; height: 40px; border: 1px solid var(--aksp-border); background: #fff; border-radius: 8px; display: grid; place-items: center; cursor: pointer; color: var(--aksp-text); }
.aksp-iconbtn:hover { background: var(--aksp-bg); }
.aksp-topbar__spacer { flex: 1; }

.aksp-content { padding: 24px; width: 100%; max-width: var(--aksp-content-max); margin: 0 auto; }
.aksp-footer { padding: 14px 24px; color: var(--aksp-text-muted); font-size: 12px; border-top: 1px solid var(--aksp-border); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Breadcrumb + page header */
.aksp-breadcrumb { font-size: 12px; color: var(--aksp-text-muted); margin-bottom: 6px; }
.aksp-breadcrumb a { color: var(--aksp-text-muted); text-decoration: none; }
.aksp-breadcrumb a:hover { color: var(--aksp-primary); }
.aksp-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.aksp-page-header__title { font-size: 22px; font-weight: 700; margin: 0; }
.aksp-page-header__sub { color: var(--aksp-text-muted); font-size: 13px; margin: 4px 0 0; }

/* Stat cards */
.aksp-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.aksp-stat { background: var(--aksp-surface); border: 1px solid var(--aksp-border); border-radius: var(--aksp-card-radius); box-shadow: var(--aksp-card-shadow); padding: 16px; text-decoration: none; color: inherit; display: block; transition: box-shadow .15s, transform .15s, border-color .15s; }
a.aksp-stat:hover { box-shadow: var(--aksp-card-shadow-hover); transform: translateY(-1px); border-color: #c7d7f5; }
.aksp-stat__label { color: var(--aksp-text-muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.aksp-stat__value { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--aksp-text); }
.aksp-stat__sub { font-size: 12px; color: var(--aksp-text-muted); margin-top: 2px; }
.aksp-stat__ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: 0 0 40px; }
.aksp-stat__ico--primary { background: var(--aksp-primary-050); color: var(--aksp-primary-navy); }
.aksp-stat__ico--success { background: #ecfdf5; color: #047857; }
.aksp-stat__ico--warning { background: #fffbeb; color: #b45309; }
.aksp-stat__ico--error   { background: #fff1f2; color: #be123c; }
.aksp-stat__ico--info    { background: #eef2ff; color: #4338ca; }
.aksp-stat__ico--neutral { background: #f1f5f9; color: #475569; }

/* Urgent-action items */
.aksp-urgent { border-inline-start: 3px solid; padding: 10px 12px; border-radius: 8px; margin-bottom: 10px; background: #f8fafc; }
.aksp-urgent:last-child { margin-bottom: 0; }
.aksp-urgent--warning { border-color: var(--aksp-warning); background: #fffbeb; }
.aksp-urgent--error   { border-color: var(--aksp-error);   background: #fff1f2; }
.aksp-urgent--info    { border-color: var(--aksp-info);    background: #eef2ff; }
.aksp-urgent__link { color: var(--aksp-primary); text-decoration: none; }
.aksp-urgent__link:hover { text-decoration: underline; }

/* Donut */
.aksp-donut { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center; }
.aksp-donut__legend { list-style: none; margin: 0; padding: 0; font-size: 13px; min-width: 130px; }
.aksp-donut__legend li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.aksp-donut__swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.aksp-donut__val { margin-inline-start: auto; font-weight: 700; color: var(--aksp-text); }

/* Portfolio highlight (navy, Stitch growth card) */
.aksp-highlight { background: linear-gradient(160deg, var(--aksp-primary-navy), #0b1b6b); color: #fff; border-radius: var(--aksp-card-radius); padding: 18px; display: flex; flex-direction: column; justify-content: center; box-shadow: var(--aksp-card-shadow); }
.aksp-highlight__label { font-size: 13px; opacity: .85; }
.aksp-highlight__value { font-size: 24px; font-weight: 800; margin-top: 6px; }
.aksp-highlight__sub { font-size: 12px; opacity: .8; margin-top: 4px; }

/* Cards / tables */
.aksp-card { background: var(--aksp-surface); border: 1px solid var(--aksp-border); border-radius: var(--aksp-card-radius); box-shadow: var(--aksp-card-shadow); }
.aksp-card__head { padding: 14px 16px; border-bottom: 1px solid var(--aksp-border); font-weight: 700; font-size: 14px; }
.aksp-card__body { padding: 16px; }
.aksp-table-wrap { overflow-x: auto; }               /* horizontal scroll; never clip Arabic */
.aksp-table { width: 100%; border-collapse: collapse; }
.aksp-table th, .aksp-table td { text-align: start; padding: 0 14px; height: var(--aksp-row-h); border-bottom: 1px solid var(--aksp-border); white-space: nowrap; }
.aksp-table thead th { background: #f1f5f9; color: var(--aksp-text-muted); font-size: 12px; font-weight: 600; }
.aksp-table tbody tr:hover { background: #f8fafc; }

/* Status badges (never colour-only: icon/text always present) */
.aksp-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.aksp-badge__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.aksp-badge--success { color: #047857; background: #ecfdf5; border-color: #a7f3d0; } /* AA text (5.2:1) */
.aksp-badge--warning { color: var(--aksp-warning); background: #fffbeb; border-color: #fde68a; }
.aksp-badge--error   { color: var(--aksp-error);   background: #fff1f2; border-color: #fecdd3; }
.aksp-badge--info    { color: var(--aksp-info);    background: #eef2ff; border-color: #c7d2fe; }
.aksp-badge--neutral { color: #475569; background: #f1f5f9; border-color: #e2e8f0; }

/* Alerts (icon + text) */
.aksp-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; border: 1px solid; font-size: 14px; margin-bottom: 12px; }
.aksp-alert--success { color: #065f46; background: #ecfdf5; border-color: #a7f3d0; }
.aksp-alert--warning { color: #92400e; background: #fffbeb; border-color: #fde68a; }
.aksp-alert--error   { color: #9f1239; background: #fff1f2; border-color: #fecdd3; }
.aksp-alert--info    { color: #3730a3; background: #eef2ff; border-color: #c7d2fe; }

/* Empty state */
.aksp-empty { text-align: center; padding: 40px 16px; color: var(--aksp-text-muted); }
.aksp-empty__icon { font-size: 28px; opacity: .5; }
.aksp-empty__title { font-weight: 700; color: var(--aksp-text); margin-top: 8px; }

/* Buttons (brand) */
.btn-aksp { background: var(--aksp-primary); color: #fff; border: 1px solid var(--aksp-primary); }
.btn-aksp:hover { background: var(--aksp-primary-600); color: #fff; }

/* Accessible focus */
a:focus-visible, button:focus-visible, .aksp-nav-link:focus-visible, .aksp-iconbtn:focus-visible, .form-control:focus-visible, .aksp-stat:focus-visible {
  outline: 3px solid rgba(79,70,229,.45); outline-offset: 2px; border-radius: 6px;
}

/* Mobile off-canvas backdrop */
.aksp-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1039; display: none; }
.aksp-backdrop.is-open { display: block; }
.aksp-topbar__toggle-mobile { display: none; }

/* Responsive: tablet */
@media (max-width: 1200px) { .aksp-stat-grid { grid-template-columns: repeat(2, 1fr); } }

/* Responsive: mobile — off-canvas sidebar */
@media (max-width: 992px) {
  .aksp-sidebar { transform: translateX(100%); width: var(--aksp-sidebar-w); }
  .aksp-shell.is-mobile-open .aksp-sidebar { transform: translateX(0); box-shadow: -8px 0 24px rgba(0,0,0,.2); }
  .aksp-main { margin-right: 0 !important; }
  .aksp-topbar__toggle-desktop { display: none; }
  .aksp-topbar__toggle-mobile { display: grid; }
  .aksp-content { padding: 16px; }
  .aksp-stat-grid { grid-template-columns: 1fr; }
}
