/* STMS application styles (on top of Bootstrap 5.3) */
:root {
  --stms-sidebar-w: 248px;
  --stms-sidebar-bg: #ffffff;
  --stms-sidebar-fg: #111111;
  --stms-sidebar-hover: #f1f4f9;
  --stms-sidebar-active-bg: #fff3dc;
  --stms-sidebar-active: #e85d04;
  --stms-purple: #6f42c1;
  --stms-purple-subtle: #ece3fb;
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}
[data-bs-theme="dark"] {
  --stms-sidebar-bg: #151a23;
  --stms-sidebar-fg: #f1f3f5;
  --stms-sidebar-hover: #222a36;
  --stms-sidebar-active-bg: #3a2a12;
  --stms-purple-subtle: #2c1f47;
}
html[dir="rtl"] { --bs-body-font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Segoe UI", Tahoma, sans-serif; }
html[dir="rtl"] body { line-height: 1.9; }

body { background: var(--bs-tertiary-bg); }
.min-w-0 { min-width: 0; }
.text-purple { color: var(--stms-purple) !important; }
.bg-purple-subtle { background: var(--stms-purple-subtle) !important; }
[data-bs-theme="dark"] .text-purple { color: #b794f4 !important; }
.text-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cell-wide { max-width: 380px; }

/* Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--stms-sidebar-w); background: var(--stms-sidebar-bg); color: var(--stms-sidebar-fg); display: flex; flex-direction: column; border-inline-end: 1px solid var(--bs-border-color); }
/* Bootstrap's .offcanvas-lg forces a transparent background on large screens */
.sidebar.offcanvas-lg { background-color: var(--stms-sidebar-bg) !important; }
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; flex-shrink: 0; overflow-y: auto; }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { --bs-offcanvas-width: 270px; --bs-offcanvas-bg: var(--stms-sidebar-bg); }
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem .75rem; }
.sidebar-brand a { color: var(--stms-sidebar-fg); }
.brand-name { font-weight: 700; font-size: 1.02rem; line-height: 1.2; }
.brand-logo { height: 34px; max-width: 120px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px; }
.brand-mark { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, #fca311, #e85d04); color: #fff; display: grid; place-items: center; font-size: 1.6rem; }
.brand-mark.sm { width: 34px; height: 34px; border-radius: 9px; font-size: 1.1rem; }
.sidebar-nav { padding: .25rem .6rem; flex: 1; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .7rem; color: var(--stms-sidebar-fg); padding: .6rem .75rem; border-radius: .5rem; margin-bottom: 2px; font-size: .97rem; font-weight: 600; }
.sidebar-nav .nav-link i { font-size: 1.08rem; width: 1.2rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--stms-sidebar-hover); color: var(--stms-sidebar-fg); }
.sidebar-nav .nav-link.active { background: var(--stms-sidebar-active-bg); color: var(--stms-sidebar-fg); font-weight: 700; box-shadow: inset 3px 0 0 var(--stms-sidebar-active); }
.sidebar-nav .nav-link.active i { color: var(--stms-sidebar-active); }
html[dir="rtl"] .sidebar-nav .nav-link.active { box-shadow: inset -3px 0 0 var(--stms-sidebar-active); }
.sidebar-foot { padding: .9rem 1rem; border-top: 1px solid var(--bs-border-color); color: var(--stms-sidebar-fg); font-weight: 600; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .5rem; padding: .5rem 1rem; background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color); min-height: 56px; }
.topbar-title { font-weight: 600; color: var(--bs-secondary-color); }
.btn-icon { border: 0; background: transparent; color: var(--bs-body-color); padding: .35rem .55rem; border-radius: .5rem; }
.btn-icon:hover, .btn-icon:focus-visible { background: var(--bs-secondary-bg); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #14213d; color: #fff; display: inline-grid; place-items: center; font-weight: 600; font-size: .9rem; flex-shrink: 0; }
.avatar.sm { width: 28px; height: 28px; font-size: .8rem; }
.app-content { padding: 1.25rem; max-width: 1500px; width: 100%; }
@media (min-width: 768px) { .app-content { padding: 1.5rem 2rem; } }

/* Cards & stats */
.card { border-color: var(--bs-border-color-translucent); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #f5f8fc; font-weight: 600; }
[data-bs-theme="dark"] .card-header { background: var(--bs-tertiary-bg); }
.stat-card { border: 0; transition: transform .12s ease, box-shadow .12s ease; color: var(--bs-body-color); }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16,24,40,.08); }
.stat-card.selected { outline: 2px solid currentColor; }
.stat-card .stat-icon { font-size: 1.25rem; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; margin-bottom: .5rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .82rem; color: var(--bs-secondary-color); }
.stat-card { background: var(--stat-bg, var(--bs-body-bg)); border: 1px solid var(--stat-border, transparent) !important; }
.stat-primary { --stat-bg: #eef4ff; --stat-border: #d6e4ff; }
.stat-danger { --stat-bg: #fff0f0; --stat-border: #ffd6d6; }
.stat-info { --stat-bg: #ebf9fc; --stat-border: #c9eef6; }
.stat-success { --stat-bg: #ecf8f1; --stat-border: #cdebd9; }
.stat-warning { --stat-bg: #fff8e6; --stat-border: #ffe8a8; }
.stat-secondary { --stat-bg: #f3f4f7; --stat-border: #e2e5ea; }
.stat-purple { --stat-bg: #f5f0ff; --stat-border: #e3d7fb; }
[data-bs-theme="dark"] .stat-card { --stat-bg: var(--bs-tertiary-bg); --stat-border: var(--bs-border-color); }
.stat-label { color: var(--bs-body-color) !important; font-weight: 600; }
.stat-primary .stat-icon { background: var(--bs-primary-bg-subtle); color: var(--bs-primary); }
.stat-danger .stat-icon { background: var(--bs-danger-bg-subtle); color: var(--bs-danger); }
.stat-danger .stat-value { color: var(--bs-danger); }
.stat-info .stat-icon { background: var(--bs-info-bg-subtle); color: var(--bs-info-text-emphasis); }
.stat-success .stat-icon { background: var(--bs-success-bg-subtle); color: var(--bs-success); }
.stat-warning .stat-icon { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.stat-secondary .stat-icon { background: var(--bs-secondary-bg); color: var(--bs-secondary-color); }
.stat-purple .stat-icon { background: var(--stms-purple-subtle); color: var(--stms-purple); }

/* Task cards */
.task-card { border-inline-start: 4px solid var(--bs-border-color); }
.task-card { background: #fbfcfe; }
.task-card.critical { border-inline-start-color: var(--bs-danger); }
.task-card.due-today { border-inline-start-color: #f0ad00; background: #fffaeb; }
.task-card.done { background: #f3faf6; border-inline-start-color: var(--bs-success); }
[data-bs-theme="dark"] .task-card { background: var(--bs-body-bg); }
[data-bs-theme="dark"] .task-card.due-today { background: var(--bs-warning-bg-subtle); }
[data-bs-theme="dark"] .task-card.done { background: var(--bs-success-bg-subtle); }
.task-card.overdue { border-inline-start-color: var(--bs-danger); background: linear-gradient(90deg, var(--bs-danger-bg-subtle), var(--bs-body-bg) 35%); }
html[dir="rtl"] .task-card.overdue { background: linear-gradient(-90deg, var(--bs-danger-bg-subtle), var(--bs-body-bg) 35%); }
.task-card h3 a:hover { text-decoration: underline !important; }
.task-card-actions { align-self: center; }
@media (max-width: 575.98px) { .task-card-actions { width: 100%; } .task-card-actions .btn { width: 100%; } }
.badge-priority, .badge-status { font-weight: 600; }
.filter-pills { display: flex; flex-wrap: nowrap; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: thin; }
.filter-pills .btn { white-space: nowrap; border-radius: 999px; }
.row-overdue > td { background: #fff3f3 !important; }
.row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--bs-danger); }
.row-today > td { background: #fffaeb !important; }
.row-today td:first-child { box-shadow: inset 3px 0 0 #f0ad00; }
[data-bs-theme="dark"] .row-overdue > td { background: var(--bs-danger-bg-subtle) !important; }
[data-bs-theme="dark"] .row-today > td { background: var(--bs-warning-bg-subtle) !important; }

/* "Follow up today" panel on the admin dashboard */
.followup-card { border: 2px solid #f0ad00 !important; }
.followup-card > .card-header { background: #fff3cd; font-size: 1.05rem; }
.followup-list { max-height: 520px; overflow-y: auto; }
.followup-item { border-inline-start: 5px solid #f0ad00 !important; background: #fffbf0; }
.followup-item.is-overdue { border-inline-start-color: var(--bs-danger) !important; background: #fff4f4; }
[data-bs-theme="dark"] .followup-card > .card-header { background: var(--bs-warning-bg-subtle); }
[data-bs-theme="dark"] .followup-item { background: var(--bs-body-bg); }
[data-bs-theme="dark"] .followup-item.is-overdue { background: var(--bs-danger-bg-subtle); }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--bs-secondary-color); }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .6; }
.assignee-list { max-height: 260px; overflow-y: auto; }
.active-soft { background: var(--bs-primary-bg-subtle) !important; }
.list-group-item.unread { background: var(--bs-primary-bg-subtle); }
.task-description { white-space: normal; overflow-wrap: anywhere; }
.details-grid dt { color: var(--bs-secondary-color); font-weight: 500; }
.progress-dl dt { color: var(--bs-secondary-color); font-weight: 500; font-size: .8rem; margin-top: .4rem; }
.progress-dl dd { margin-bottom: 0; }

/* Conversation */
.chat { max-height: 480px; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; background: var(--bs-tertiary-bg); }
.msg { max-width: 85%; border-radius: .75rem; padding: .55rem .8rem; font-size: .92rem; overflow-wrap: anywhere; }
.msg-mine { align-self: flex-end; background: var(--bs-primary-bg-subtle); }
.msg-other { align-self: flex-start; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); }
.msg-system { align-self: center; max-width: 95%; background: transparent; color: var(--bs-secondary-color); font-size: .8rem; text-align: center; }
.msg-meta { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; font-size: .78rem; margin-bottom: .2rem; }
.msg-time { color: var(--bs-secondary-color); font-size: .75rem; margin-inline-start: .3rem; }
.msg-files { margin-top: .35rem; display: flex; flex-wrap: wrap; gap: .3rem; }

/* Timeline */
.timeline li { position: relative; padding-inline-start: 1.4rem; padding-bottom: .8rem; border-inline-start: 2px solid var(--bs-border-color); margin-inline-start: .4rem; }
.timeline li:last-child { border-color: transparent; }
.tl-dot { position: absolute; inset-inline-start: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--bs-primary); border: 2px solid var(--bs-body-bg); }

/* Notifications menu */
.notif-menu { width: min(360px, 92vw); }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-list a { display: flex; gap: .6rem; padding: .6rem .9rem; text-decoration: none; color: var(--bs-body-color); border-bottom: 1px solid var(--bs-border-color-translucent); font-size: .86rem; }
.notif-list a:hover { background: var(--bs-secondary-bg); }
.notif-list a.unread { background: var(--bs-primary-bg-subtle); }

/* Auth */
.auth-body { min-height: 100vh; background: linear-gradient(160deg, #14213d 0%, #1f3a6e 55%, #e5e5e5 55.1%); }
[data-bs-theme="dark"] .auth-body { background: linear-gradient(160deg, #0b1222 0%, #14213d 55%, #111 55.1%); }
.auth-wrap { max-width: 420px; margin: 0 auto; padding: 3rem 1rem; }
.auth-wrap > .text-center { color: #fff; }
.auth-wrap > .text-center .text-body-secondary { color: rgba(255,255,255,.75) !important; }
.auth-logo { max-height: 64px; max-width: 200px; background: #fff; border-radius: 10px; padding: 4px; }

/* Calendar */
#calendar { min-height: 600px; }
.fc .fc-toolbar-title { font-size: 1.15rem; }
.fc-event { cursor: pointer; font-size: .78rem; }
.fc .ev-scheduled { opacity: .75; border-style: dashed !important; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: .3rem; vertical-align: middle; }
@media (max-width: 575.98px) { .fc .fc-toolbar { flex-direction: column; gap: .5rem; } }

/* Forms */
.settings-card { max-width: 980px; }
.form-label { font-weight: 500; }
.btn-check + .btn { min-width: 52px; }

/* Print */
.print-body { background: #fff; }
@media print {
  .no-print, .sidebar, .topbar, .btn, .pagination { display: none !important; }
  body, .app-content { background: #fff !important; padding: 0 !important; }
  .card { border: 0 !important; box-shadow: none !important; }
  .table { font-size: 10pt; }
  .table-responsive { overflow: visible !important; }
  a { color: inherit !important; text-decoration: none !important; }
  .badge { border: 1px solid #999; color: #000 !important; background: transparent !important; }
}
