/* SESSI Portal — Base: reset, typography, layout */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html, body { height: 100%; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-en);
  background: var(--bg);
  color: var(--text);
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

[lang="ur"] body, html[lang="ur"] { font-family: var(--font-ur); }
[lang="sd"] body, html[lang="sd"] { font-family: var(--font-sd); }

a { color: inherit; text-decoration: none; }
button { background: none; border: none; color: inherit; cursor: pointer; font: inherit; }
input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
ul, ol { list-style: none; }

/* App layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 1fr;
  grid-template-areas: "sidebar main";
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--header-h);
}
.sidebar-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-3));
  display: grid; place-items: center;
  color: white;
  flex-shrink: 0;
}
.sidebar-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
}
.sidebar-subtitle {
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
}
.sidebar-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-search input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12px;
  outline: none;
  transition: border var(--t-fast);
}
.sidebar-search input:focus { border-color: var(--primary); }
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
.nav-section { margin-bottom: 8px; }
.nav-section-title {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  border: 1px solid transparent;
  user-select: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-2);
  font-weight: 600;
}
.nav-item .nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-inline-start: auto;
  font-size: 10px;
  background: var(--primary);
  color: white;
  padding: 1px 6px;
  border-radius: 99px;
  font-weight: 600;
}
.nav-item .nav-badge.danger { background: var(--danger); }
.nav-item .nav-badge.warning { background: var(--warning); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  color: white;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.avatar.xl { width: 80px; height: 80px; font-size: 28px; }
.user-info { min-width: 0; flex: 1; }
.user-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--text-2); }

/* Header */
.header {
  grid-area: header;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  min-height: var(--header-h);
}
.header-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  flex: 1;
  min-width: 0;
}
.header-breadcrumbs .crumb { white-space: nowrap; }
.header-breadcrumbs .crumb:not(:last-child)::after {
  content: '›';
  margin-inline-start: 6px;
  color: var(--text-3);
}
.header-breadcrumbs .crumb:last-child { color: var(--text); font-weight: 600; }
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--text-2);
  transition: all var(--t-fast);
  position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .notification-dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--surface);
}
[data-theme="light"] .icon-btn .notification-dot { border-color: var(--surface); }
.icon-btn .kbd {
  position: absolute;
  bottom: 4px; right: 4px;
  font-size: 8px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text-3);
  padding: 1px 3px;
  border-radius: 3px;
  font-family: var(--font-mono);
}
.lang-switcher {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 2px;
  font-size: 11px;
  font-weight: 600;
}
.lang-switcher button {
  padding: 6px 10px;
  border-radius: 4px;
  color: var(--text-2);
  transition: all var(--t-fast);
}
.lang-switcher button.active { background: var(--primary); color: white; }

/* Main */
.main {
  grid-area: main;
  overflow-y: auto;
  background: var(--bg);
}
.main::-webkit-scrollbar { width: 8px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
.page {
  padding: 24px 28px;
  max-width: var(--content-max);
  margin: 0 auto;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 24px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-2);
}
.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Grids */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1024px) {
  .grid-4, .grid-6 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4, .grid-6 { grid-template-columns: 1fr; }
}

/* Spacing utilities */
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.text-xs { font-size: 11px; } .text-sm { font-size: 12px; } .text-md { font-size: 14px; } .text-lg { font-size: 16px; } .text-xl { font-size: 18px; } .text-2xl { font-size: 22px; } .text-3xl { font-size: 28px; }
.font-bold { font-weight: 700; } .font-semibold { font-weight: 600; } .font-medium { font-weight: 500; }
.text-muted { color: var(--text-2); } .text-dim { color: var(--text-3); }
.text-success { color: var(--success); } .text-warning { color: var(--warning); } .text-danger { color: var(--danger); } .text-info { color: var(--info); } .text-primary { color: var(--primary-2); }
.text-right { text-align: right; } .text-center { text-align: center; }
.w-full { width: 100%; } .h-full { height: 100%; }
.flex-1 { flex: 1; } .flex-shrink-0 { flex-shrink: 0; }
.cursor-pointer { cursor: pointer; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Loading skeleton */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200px 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--radius-sm);
}

/* Mobile sidebar toggle */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas: "header" "main";
  }
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; bottom: 0; width: var(--sidebar-w); z-index: 60; transform: translateX(-100%); transition: transform var(--t); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn { display: grid !important; }
  .page { padding: 16px; }
}
.mobile-menu-btn { display: none; }

/* Print */
@media print {
  .sidebar, .topbar { display: none; }
  .app { grid-template-columns: 1fr; grid-template-areas: "main"; }
  .main { overflow: visible; }
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 16px;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-sub { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  min-width: 240px;
}
.topbar-search input { background: transparent; border: 0; outline: 0; color: var(--text); font-size: 13px; width: 100%; }
.topbar-search svg { color: var(--text-2); }

.icon-btn {
  position: relative;
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: transparent; border: 0;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--t-fast);
}
.icon-btn:hover { background: var(--bg-2); color: var(--text); }
.badge-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; border: 2px solid var(--surface); }

.avatar {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }

/* Sidebar brand */
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  min-height: 64px;
}
.sidebar-brand-text { display: flex; flex-direction: column; }
.sidebar-brand-title { font-weight: 800; font-size: 14px; letter-spacing: -0.01em; }
.sidebar-brand-sub { font-size: 11px; color: var(--text-2); }

.sidebar-group { padding: 12px 8px 4px; }
.sidebar-group-label {
  font-size: 10px; font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 12px 6px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--t-fast);
  margin-bottom: 1px;
}
.sidebar-item:hover { background: var(--bg-2); color: var(--text); }
.sidebar-item.active {
  background: linear-gradient(90deg, var(--primary-soft), transparent);
  color: var(--primary);
  font-weight: 600;
}
.sidebar-item.active .sidebar-item-icon { color: var(--primary); }
.sidebar-item-icon { display: grid; place-items: center; width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-item-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-item-badge {
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px;
  margin-top: auto;
}

/* Overlay */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 55;
}
.overlay.show { display: block; }

/* Toast */
.toast-stack {
  position: fixed; top: 20px; right: 20px;
  z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 280px;
  max-width: 360px;
  box-shadow: var(--shadow);
  display: flex; align-items: flex-start; gap: 10px;
  pointer-events: auto;
  animation: slideIn 0.2s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.danger { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast-icon { flex-shrink: 0; }
.toast-content { flex: 1; }
.toast-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.toast-body { font-size: 12px; color: var(--text-2); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Calendar */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.cal-header {
  padding: 10px 8px;
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-2);
  text-align: center;
}
.cal-cell {
  background: var(--surface);
  min-height: 88px;
  padding: 6px;
  position: relative;
  font-size: 12px;
}
.cal-cell.empty { background: var(--bg-2); }
.cal-cell.today { background: var(--primary-soft); }
.cal-cell.has-events { cursor: pointer; }
.cal-cell.has-events:hover { background: var(--surface-2); }
.cal-date { font-weight: 600; margin-bottom: 4px; }
.cal-event {
  font-size: 10px;
  padding: 2px 4px;
  border-radius: 3px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--info-soft);
  color: var(--info);
}
.cal-event.visit { background: var(--info-soft); color: var(--info); }
.cal-event.deadline { background: var(--warning-soft); color: var(--warning); }
.cal-event.hearing { background: var(--danger-soft); color: var(--danger); }
.cal-event.event { background: var(--accent-soft); color: var(--accent); }
.cal-more { font-size: 9px; color: var(--text-3); padding: 2px 4px; }

/* Tabs */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Stat box */
.stat-box {
  display: flex; align-items: center; gap: 10px;
  padding: 12px;
  background: var(--bg-2);
  border-radius: 8px;
}
.stat-icon { flex-shrink: 0; }
.stat-content { flex: 1; min-width: 0; }
.stat-value { font-size: 18px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 11px; color: var(--text-2); margin-top: 2px; }
