:root {
  --primary: #2563eb;
  --primary-light: #93c5fd;
  --accent: #b8860b;
  --sidebar-bg: #1e40af;
  --sidebar-width: 260px;
  --header-height: 56px;
  --body-bg: #f4f6f9;
  --touch-min: 44px;
  --font-urdu: 'Jameel Noori Nastaleeq', 'Urdu Naskh Asiatype', serif;
}

@font-face {
  font-family: 'Jameel Noori Nastaleeq';
  src: url('../fonts/JameelNooriNastaleeq.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Universal Urdu font – use Jameel Noori wherever Urdu text appears */

/* RTL content (typically Urdu) */
[dir="rtl"],
[dir="rtl"] * {
  font-family: var(--font-urdu);
}

.urdu-label { font-family: var(--font-urdu); font-size: 1.1em; direction: rtl; unicode-bidi: embed; }
.urdu-input { font-family: var(--font-urdu); direction: rtl; text-align: right; }
.measurement-form-rtl { font-family: var(--font-urdu); }
.measurement-form-rtl .form-label { text-align: right; }
.measurement-form-rtl .form-control:not(.urdu-input) { text-align: right; direction: rtl; font-family: var(--font-urdu); }
.measurement-display-table { font-family: var(--font-urdu); }
.measurement-display-table td { font-family: inherit; }

/* Urdu text in non-RTL context (e.g. inline spans) */
.font-urdu { font-family: var(--font-urdu); }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: 'Segoe UI', Tahoma, sans-serif; background: var(--body-bg); }
.navbar { background: var(--sidebar-bg) !important; }
.navbar-brand { color: #fff !important; font-weight: 600; }
.nav-link { color: rgba(255,255,255,.85) !important; }
.nav-link:hover { color: #fff !important; }

/* App layout */
.app-body { padding-top: var(--header-height); min-height: 100vh; }
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1030;
  height: var(--header-height);
  min-height: var(--header-height);
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  padding-top: env(safe-area-inset-top);
  background: var(--sidebar-bg);
  display: flex; align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.sidebar-toggle {
  color: rgba(255,255,255,.9) !important;
  text-decoration: none !important;
  padding: .5rem; margin: -.5rem .5rem -.5rem -.5rem;
}
.sidebar-toggle:hover { color: #fff !important; }
.app-brand {
  font-weight: 600; color: #fff !important; text-decoration: none;
  white-space: nowrap; display: flex; align-items: center;
}
.app-brand-img { max-height: 36px; width: auto; display: block; }
.app-title { color: rgba(255,255,255,.8); font-size: .95rem; }

.app-sidebar {
  position: fixed; top: var(--header-height); left: 0; z-index: 1025;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--sidebar-bg);
  overflow-x: hidden; overflow-y: auto;
  transition: transform .25s ease, width .25s ease;
}
.app-sidebar.collapsed {
  transform: translateX(-100%);
}
@media (min-width: 992px) {
  .app-sidebar.collapsed { transform: none; width: 0; }
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1020;
  background: rgba(0,0,0,.4);
  opacity: 0; transition: opacity .25s;
}
.sidebar-overlay.show {
  display: block; opacity: 1;
}
@media (min-width: 992px) {
  .sidebar-overlay { display: none !important; }
}
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1rem; color: rgba(255,255,255,.85) !important;
  border-left: 3px solid transparent;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); color: #fff !important; }
.sidebar-nav .nav-link.active { background: rgba(255,255,255,.12); color: #fff !important; border-left-color: var(--accent); }
.sidebar-nav .nav-link i { font-size: 1.1rem; flex-shrink: 0; }
.sidebar-label { color: rgba(255,255,255,.6) !important; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.sidebar-nav .sub-link { padding-left: 2.5rem; font-size: .9rem; }
.sidebar-group-toggle {
  width: 100%; text-align: left; border: none; background: none; cursor: pointer;
  color: rgba(255,255,255,.85) !important; font-size: inherit;
}
.sidebar-group-toggle:hover { color: #fff !important; }
.sidebar-group-toggle .group-chevron { transition: transform .2s; font-size: .75rem; }
.sidebar-group-toggle:not(.collapsed) .group-chevron { transform: rotate(180deg); }
#settingsSubmenu { padding-left: 0; list-style: none; }
#settingsSubmenu .nav-item { margin: 0; }

.app-main {
  margin-left: var(--sidebar-width);
  padding: 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  min-height: calc(100vh - var(--header-height));
  transition: margin-left .25s ease;
}
.app-sidebar.collapsed ~ .app-main { margin-left: 0; }
@media (min-width: 768px) {
  .app-main { padding: 1.5rem; }
}

/* Legacy sidebar (auth views, etc) */
.sidebar { background: var(--sidebar-bg); min-height: calc(100vh - 56px); }
.sidebar .nav-link { padding: 0.5rem 1rem; }
.sidebar .nav-link.active { background: rgba(255,255,255,.1); color: #fff !important; }
.list-group-item.active { background: var(--primary); border-color: var(--primary); }
.card { border: none; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card-header { background: #fff; border-bottom: 1px solid #eee; font-weight: 600; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.badge-commission { background: var(--accent); color: #fff; }
.stat-card { border-left: 4px solid var(--primary); }
.table th { font-weight: 600; font-size: 0.85rem; }
.alert { border-radius: 0.375rem; }

/* Mobile-first responsive & touch-friendly */
@media (max-width: 767px) {
  .app-header { padding: 0 0.5rem; }
  .app-title { display: none; }
  .app-brand, .app-brand-img { max-height: 32px; }
}
@media (max-width: 575px) {
  .app-brand { font-size: 0.9rem; }
}

/* Touch-friendly form controls (min 44px tap target, 16px font to prevent iOS zoom) */
.form-control, .form-select { min-height: var(--touch-min); font-size: 1rem; }
.form-control-sm { min-height: 38px; font-size: 0.95rem; }
.btn { min-height: var(--touch-min); padding: 0.5rem 1rem; }
.btn-sm { min-height: 38px; padding: 0.35rem 0.75rem; }
.sidebar-nav .nav-link, .sidebar-group-toggle { min-height: var(--touch-min); padding: 0.75rem 1rem; }
.sidebar-toggle { min-width: var(--touch-min); min-height: var(--touch-min); }

/* Table scroll on small screens */
.table-responsive-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 1rem; }
.table-responsive-wrap .table { min-width: 600px; margin-bottom: 0; }

/* Page headers: stack on mobile */
@media (max-width: 575px) {
  .page-header { flex-direction: column; align-items: stretch !important; gap: 0.75rem; }
  .page-header .btn { align-self: flex-start; }
}

/* Form layouts: full width inputs on mobile */
@media (max-width: 767px) {
  .input-group { max-width: none !important; }
}
