/* ═══════════════════════════════════════════
   SafetyHub – main.css
   Shared styles for all pages
   ═══════════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

/* ── Design Tokens ── */
:root {
  /* --green: #0880c7; */
  --green:       #00C48C;
  /* --green-d: #09659b; */
  --green-d:     #009E71;
  --green-lt: rgba(0, 196, 140, .10);
  --navy: #0D1B2A;
  --slate: #1E3448;
  --mid: #2D4A63;
  --muted: #6B8299;
  --border: #E3EAF0;
  --bg: #F4F7FA;
  --white: #ffffff;
  --danger: #EF4444;
  --warn: #F97316;
  --blue: #3B82F6;
  --purple: #8B5CF6;
  --yellow: #EAB308;

  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --sh-sm: 0 2px 8px rgba(13, 27, 42, .07);
  --sh-md: 0 6px 24px rgba(13, 27, 42, .12);
  --sh-lg: 0 12px 40px rgba(13, 27, 42, .16);

  --topbar-h: 60px;
  --subnav-h: 48px;
  --sidebar-w: 260px;
  --panel-w: 300px;

  --transition: .18s ease;
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--navy);
  font-size: 14px;
  overflow-x: hidden;
  line-height: 1.5;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Space Grotesk', sans-serif;
  line-height: 1.25;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  font-family: 'DM Sans', sans-serif;
}

input,
textarea,
select {
  font-family: 'DM Sans', sans-serif;
}

img {
  max-width: 100%;
  display: block;
}

/* ═══════════════════════════════════
   TOPBAR
   ═══════════════════════════════════ */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  box-shadow: var(--sh-sm);
  gap: 12px;
}

.tb-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.tb-brand-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.tb-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 2px;
}

.tb-brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.2px;
}

.tb-brand-name-ar {
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  direction: rtl;
  letter-spacing: 0.5px;
}

.tb-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

.tb-page-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.tb-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════
   SIDEBAR NAV
   ═══════════════════════════════════ */
#sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  z-index: 900;
  overflow-y: auto;
  transition: transform var(--transition);
}

#sidebar::-webkit-scrollbar {
  width: 4px;
}

#sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1);
  border-radius: 4px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .35);
  padding: 14px 14px 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 14px;
  border-radius: 10px;
  color: rgba(255, 255, 255, .6);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  margin: 1px 8px;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.nav-link i {
  font-size: 17px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-link:hover {
  background: rgba(255, 255, 255, .07);
  color: var(--white);
}

.nav-link.active {
  background: var(--green);
  color: var(--white);
}

.nav-link .nav-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, .15);
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
}

.nav-link.active .nav-badge {
  background: rgba(0, 0, 0, .2);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, .07);
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--transition);
}

.user-row:hover {
  background: rgba(255, 255, 255, .07);
}

/* ═══════════════════════════════════
   MAIN CONTENT AREA
   ═══════════════════════════════════ */
#main {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

.page-content {
  padding: 28px 28px;
}

/* ═══════════════════════════════════
   AVATARS
   ═══════════════════════════════════ */
.avatar {
  border-radius: 50%;
  background: var(--green);
  color: var(--white);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.avatar-md {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

.avatar-lg {
  width: 44px;
  height: 44px;
  font-size: 16px;
}

.avatar-xl {
  width: 56px;
  height: 56px;
  font-size: 20px;
}

.avatar.blue {
  background: var(--blue);
}

.avatar.warn {
  background: var(--warn);
}

.avatar.purple {
  background: var(--purple);
}

.avatar.slate {
  background: var(--slate);
}

/* ═══════════════════════════════════
   BUTTONS
   ═══════════════════════════════════ */
.btn-primary {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 0;
  background: var(--green);
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition);
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--green-d);
  color: var(--white);
}

.btn-primary:disabled {
  background: #CBD5E0;
  cursor: not-allowed;
}

.btn-outline {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition);
  white-space: nowrap;
}

.btn-outline:hover {
  background: var(--bg);
  color: var(--navy);
}

.btn-danger {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  border: 0;
  background: rgba(239, 68, 68, .1);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, .18);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--bg);
  color: var(--navy);
}

/* ═══════════════════════════════════
   CARDS
   ═══════════════════════════════════ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}

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

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}

.card-body {
  padding: 20px;
}

/* KPI Card */
.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--sh-sm);
  padding: 20px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.kpi-icon.green {
  background: var(--green-lt);
  color: var(--green);
}

.kpi-icon.blue {
  background: rgba(59, 130, 246, .10);
  color: var(--blue);
}

.kpi-icon.orange {
  background: rgba(249, 115, 22, .10);
  color: var(--warn);
}

.kpi-icon.red {
  background: rgba(239, 68, 68, .10);
  color: var(--danger);
}

.kpi-icon.purple {
  background: rgba(139, 92, 246, .10);
  color: var(--purple);
}

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 3px;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.kpi-trend {
  font-size: 12px;
  font-weight: 700;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.kpi-trend.up {
  color: var(--green);
}

.kpi-trend.down {
  color: var(--danger);
}

.kpi-trend.warn {
  color: var(--warn);
}

/* ═══════════════════════════════════
   BADGES & PILLS
   ═══════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.green {
  background: var(--green-lt);
  color: var(--green);
}

.badge.orange {
  background: rgba(249, 115, 22, .12);
  color: var(--warn);
}

.badge.red {
  background: rgba(239, 68, 68, .10);
  color: var(--danger);
}

.badge.blue {
  background: rgba(59, 130, 246, .10);
  color: var(--blue);
}

.badge.purple {
  background: rgba(139, 92, 246, .10);
  color: var(--purple);
}

.badge.muted {
  background: rgba(107, 130, 153, .10);
  color: var(--muted);
}

/* ═══════════════════════════════════
   TABLES
   ═══════════════════════════════════ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--bg);
  padding: 10px 16px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--muted);
  font-weight: 700;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table tr:hover td {
  background: var(--bg);
}

.data-table .cell-primary {
  font-weight: 600;
  color: var(--navy);
}

.data-table .cell-muted {
  color: var(--muted);
  font-size: 12px;
}

/* ═══════════════════════════════════
   FORMS
   ═══════════════════════════════════ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .7px;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--navy);
  outline: none;
  background: var(--white);
  transition: border-color var(--transition);
  font-family: 'DM Sans', sans-serif;
}

.form-control:focus {
  border-color: var(--green);
}

.form-select {
  width: 100%;
  /* border: 1.5px solid var(--border); border-radius: var(--radius-sm); */
  padding: 9px 12px;
  font-size: 13px;
  color: var(--navy);
  outline: none;
  background: var(--white);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B8299' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--transition);
}

.form-select:focus {
  border-color: var(--green);
}

/* Toggle switch */
.toggle-sw {
  width: 38px;
  height: 21px;
  border-radius: 11px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background .22s;
  flex-shrink: 0;
}

.toggle-sw.on {
  background: var(--green);
}

.toggle-sw::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .22s;
}

.toggle-sw.on::after {
  transform: translateX(17px);
}

/* ═══════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 3px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* ═══════════════════════════════════
   COMPLIANCE BARS
   ═══════════════════════════════════ */
.compliance-item {
  margin-bottom: 14px;
}

.compliance-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 5px;
  font-weight: 500;
}

.compliance-bar {
  height: 7px;
  background: var(--border);
  border-radius: 20px;
  overflow: hidden;
}

.compliance-fill {
  height: 100%;
  border-radius: 20px;
  transition: width 1s ease;
}

.compliance-fill.green {
  background: var(--green);
}

.compliance-fill.blue {
  background: var(--blue);
}

.compliance-fill.orange {
  background: var(--warn);
}

.compliance-fill.red {
  background: var(--danger);
}

/* ═══════════════════════════════════
   QUICK ACTIONS
   ═══════════════════════════════════ */
.quick-action {
  background: var(--bg);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.quick-action:hover {
  border-color: var(--green);
  background: var(--green-lt);
}

.quick-action i {
  font-size: 24px;
  color: var(--green);
  margin-bottom: 8px;
  display: block;
}

.quick-action-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
}

.quick-action-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* ═══════════════════════════════════
   SCORE RING
   ═══════════════════════════════════ */
.score-ring {
  width: 44px;
  height: 44px;
  position: relative;
  flex-shrink: 0;
}

.score-ring svg {
  transform: rotate(-90deg);
}

.score-ring circle {
  fill: none;
  stroke-width: 4;
}

.score-ring .track {
  stroke: var(--border);
}

.score-ring .fill {
  stroke: var(--green);
  stroke-linecap: round;
  transition: stroke-dashoffset .5s;
}

.score-ring-val {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 800;
  color: var(--navy);
}

/* ═══════════════════════════════════
   TOAST
   ═══════════════════════════════════ */
.sc-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: var(--white);
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--sh-md);
  z-index: 9999;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
  white-space: nowrap;
}

.sc-toast.show {
  opacity: 1;
}

/* ═══════════════════════════════════
   MODAL
   ═══════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 27, 42, .5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--sh-lg);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  transform: translateY(20px);
  transition: transform .25s;
}

.modal-overlay.show .modal-box {
  transform: translateY(0);
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h5 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 20px 22px;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ═══════════════════════════════════
   SIDEBAR TOGGLE & OVERLAY (mobile)
   ═══════════════════════════════════ */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 850;
}

#sidebar-overlay.show {
  display: block;
}

#sidebar-toggle {
  display: none;
}

/* ═══════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════ */
@media (max-width: 991.98px) {
  #sidebar {
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--sh-lg);
  }

  #main {
    margin-left: 0;
  }

  #sidebar-toggle {
    display: flex;
  }

  .hide-md {
    display: none !important;
  }
}

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

  .page-title {
    font-size: 18px;
  }

  .hide-sm {
    display: none !important;
  }
}

/* ═══════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════ */
.text-green {
  color: var(--green) !important;
}

.text-muted {
  color: var(--muted) !important;
}

.text-danger {
  color: var(--danger) !important;
}

.text-warn {
  color: var(--warn) !important;
}

.text-blue {
  color: var(--blue) !important;
}

.text-navy {
  color: var(--navy) !important;
}

.fw-500 {
  font-weight: 500;
}

.fw-600 {
  font-weight: 600;
}

.fw-700 {
  font-weight: 700;
}

.fw-800 {
  font-weight: 800;
}

.gap-4 {
  gap: 4px;
}

.gap-6 {
  gap: 6px;
}

.gap-8 {
  gap: 8px;
}

.gap-10 {
  gap: 10px;
}

.gap-12 {
  gap: 12px;
}

.d-flex {
  display: flex;
}

.d-none {
  display: none;
}

.flex-1 {
  flex: 1;
}

.flex-wrap {
  flex-wrap: wrap;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

.w-100 {
  width: 100%;
}

.mt-4 {
  margin-top: 4px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-20 {
  margin-top: 20px;
}

.mb-4 {
  margin-bottom: 4px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-12 {
  margin-bottom: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-20 {
  margin-bottom: 20px;
}

.mb-24 {
  margin-bottom: 24px;
}

.overflow-hidden {
  overflow: hidden;
}

.cursor-pointer {
  cursor: pointer;
}

.select2-selection--single {
  height: 38px !important;
  line-height: 38px !important;
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius-sm);
}

.select2-selection__rendered {
  line-height: 38px !important;
  /* border: 1.5px solid var(--border) !important; */
  border-radius: var(--radius-sm);
}