/* =========================================================
   HR RBAC SYSTEM - MAIN STYLESHEET
   ========================================================= */
:root {
  --primary: #5b5bf0;
  --primary-dark: #4646d6;
  --sidebar-bg: #1c1d3e;
  --sidebar-hover: #2a2b57;
  --text-dark: #1f2937;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --bg-body: #f4f5fa;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(20,20,50,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  background: var(--bg-body);
  color: var(--text-dark);
  font-size: 14.5px;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; }

/* ---------- App Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: #cfd0f0;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  transition: transform .25s ease;
  z-index: 1000;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px; font-weight: 700; font-size: 17px; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand img { height: 32px; width: 32px; border-radius: 8px; object-fit: cover; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-mark svg { width: 19px; height: 19px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-nav { padding: 14px 10px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px; margin-bottom: 4px;
  font-size: 14px; color: #b8b9e0; font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: var(--sidebar-hover); color: #fff;
}
.sidebar-group { margin-bottom: 4px; }
.sidebar-group-toggle {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border: 0; border-radius: 10px; background: transparent;
  color: #b8b9e0; font: inherit; font-size: 14px; font-weight: 500;
  text-align: left; cursor: pointer; transition: background .15s, color .15s;
}
.sidebar-group-toggle:hover, .sidebar-group-toggle.active { background: var(--sidebar-hover); color: #fff; }
.sidebar-group-toggle .submenu-chevron { width: 16px; height: 16px; margin-left: auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s ease; }
.sidebar-group.expanded .submenu-chevron { transform: rotate(90deg); }
.sidebar-group:not(.expanded) .sidebar-submenu { display: none; }
.sidebar-submenu { margin: 2px 0 7px 22px; padding-left: 14px; border-left: 1px solid rgba(184,185,224,.22); }
.sidebar-submenu a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: #aeb0d2; font-size: 13px; }
.sidebar-submenu a:hover, .sidebar-submenu a.active { color: #fff; background: rgba(255,255,255,.08); }
.submenu-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.sidebar-nav .icon { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-nav .icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-nav .icon svg path:first-child:last-child { fill: currentColor; stroke: none; }

/* ---------- Main content ---------- */
.main-content { margin-left: 260px; flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: #fff; border-bottom: 1px solid var(--border-color);
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 900;
}
.topbar .menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; }
.topbar .user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.topbar .user-chip img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.topbar .user-name { font-weight: 600; font-size: 14px; }

.page-body { padding: 26px; flex: 1; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 21px; font-weight: 700; }
.page-header p.desc { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }

/* ---------- Cards / Widgets ---------- */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-card .icon-box {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff; background: var(--primary); flex-shrink: 0;
}
.stat-card .icon-box svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-box-primary { background: var(--primary) !important; }
.icon-box-success { background: #1e8e4c !important; }
.icon-box-warning { background: #d98710 !important; }
.icon-box-danger { background: #c0392b !important; }
.stat-card h3 { font-size: 22px; font-weight: 700; }
.stat-card p { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: 9px; font-size: 13.5px; font-weight: 600;
  border: none; cursor: pointer; transition: background .15s, transform .1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border: 1px solid var(--border-color); color: var(--text-dark); }
.btn-outline:hover { background: #f7f7fb; }
.btn-danger { background: #fdecea; color: #c0392b; }
.btn-danger:hover { background: #f9d4d0; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 8px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
.form-control {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 9px;
  font-size: 14px; background: #fff; transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- User row actions ---------- */
.user-actions { min-width: 300px; text-align: right; vertical-align: middle; }
.role-actions { min-width: 100px; }
.user-action-group { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 7px; }
.user-action-group form { display: inline-flex !important; margin: 0; }
.user-action-group .btn { min-height: 32px; white-space: nowrap; justify-content: center; }
.user-action-group .btn-icon { width: 34px; height: 34px; padding: 0; }
.user-action-group .btn-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.user-action-group .user-action-status { color: var(--primary); }
.user-action-group .btn-danger.btn-icon:hover { color: #a93226; background: #fbdedb; }
.user-action-group .btn-outline:hover { border-color: #c8c9f7; color: var(--primary); background: #f6f6ff; }
.user-action-group .btn-danger { border: 1px solid #f4c7c2; }
/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; }
table.data-table th {
  text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-muted); padding: 12px 14px; border-bottom: 2px solid var(--border-color);
}
table.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--border-color); font-size: 13.8px; }
table.data-table tr:hover td { background: #fafafe; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge-success { background: #e6f7ec; color: #1e8e4c; }
.badge-danger { background: #fdecea; color: #c0392b; }
.badge-muted { background: #eef0f5; color: #6b7280; }
.badge-primary { background: #ecebfe; color: var(--primary); }

/* ---------- Employee documents ---------- */
.document-row { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-left: 6px; }
.document-name { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text-dark); vertical-align: middle; }
.document-actions { display: inline-flex; align-items: center; gap: 6px; }
.document-actions .btn { padding: 5px 10px; }
.document-preview-overlay { padding: 22px; }
.document-preview-modal { width: min(1100px, 96vw); max-width: none; height: min(820px, 90vh); padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.document-preview-header { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--border-color); }
.document-preview-header h2 { margin: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-preview-close { width: 34px; height: 34px; border: 0; border-radius: 8px; background: #f1f2f6; color: var(--text-dark); font-size: 24px; line-height: 1; cursor: pointer; flex-shrink: 0; }
.document-preview-close:hover { background: #e5e7eb; }
.document-preview-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: auto; background: #eef0f5; }
.document-preview-body img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; padding: 18px; }
.document-preview-body iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.document-preview-body [hidden] { display: none !important; }
/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,20,40,.45);
  display: none; align-items: center; justify-content: center; z-index: 2000; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; border-radius: var(--radius); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; padding: 26px; }
.modal-box h2 { font-size: 18px; margin-bottom: 18px; }
.modal-close { float: right; cursor: pointer; font-size: 20px; color: var(--text-muted); }

/* ---------- Alerts / Toasts ---------- */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 13.5px; margin-bottom: 16px; }
.alert-success { background: #e6f7ec; color: #1e8e4c; }
.alert-error { background: #fdecea; color: #c0392b; }
.alert-info { background: #eef2ff; color: #4338ca; }

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #1f2937; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.2); opacity:0; transform: translateY(-8px); transition: all .25s; }
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Loading spinner ---------- */
.loader-overlay {
  position: fixed; inset: 0; background: #fff; z-index: 5000;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px;
  opacity: 1; visibility: visible; transition: opacity .22s ease, visibility .22s ease;
}
.loader-overlay.loader-hidden { opacity: 0; visibility: hidden; }
.loader-overlay > .loader-spinner { flex: 0 0 auto; margin: 0 auto; }
.loader-overlay > .text-muted { display: block; width: 100%; margin: 0; text-align: center; line-height: 1.4; }
.loader-spinner { width: 44px; height: 44px; position: relative; color: var(--primary); }
.loader-spinner-dual-ring { border: 4px solid #e5e7eb; border-top-color: var(--primary); border-right-color: var(--primary); border-radius: 50%; animation: loader-spin .8s linear infinite; }
.loader-spinner-dots { display: block; }
.loader-spinner-dots::before { content: ''; position: absolute; width: 9px; height: 9px; left: 17.5px; top: 17.5px; border-radius: 50%; background: var(--primary); box-shadow: -15px 0 var(--primary), 15px 0 var(--primary); animation: loader-bounce .8s ease-in-out infinite; }
.loader-spinner-dots::after { display: none; }
.loader-spinner-pulse { border-radius: 50%; background: rgba(91,91,240,.18); border: 5px solid var(--primary); animation: loader-pulse 1s ease-out infinite; }
.loader-spinner-bars { display: block; }
.loader-spinner-bars::before { content: ''; position: absolute; width: 5px; height: 25px; left: 19.5px; top: 9.5px; border-radius: 4px; background: var(--primary); box-shadow: -10px 0 0 var(--primary), 10px 0 0 var(--primary); animation: loader-bars .75s ease-in-out infinite; }
.loader-spinner-bars::after { display: none; }
.loader-spinner-orbit { border: 2px solid #e5e7eb; border-radius: 50%; animation: loader-spin 1.2s linear infinite; }
.loader-spinner-orbit::before { content: ''; position: absolute; width: 11px; height: 11px; border-radius: 50%; background: var(--primary); top: -6px; left: 14px; box-shadow: 0 0 0 4px rgba(91,91,240,.14); }
.loader-spinner-minimal { width: 34px; height: 34px; border: 3px solid #e5e7eb; border-bottom-color: var(--primary); border-radius: 50%; animation: loader-spin .65s linear infinite; }
@keyframes loader-spin { to { transform: rotate(360deg); } }
@keyframes loader-bounce { 0%,80%,100% { transform: scale(.65); opacity: .55; } 40% { transform: scale(1); opacity: 1; } }
@keyframes loader-pulse { 0% { transform: scale(.65); opacity: .5; } 70%,100% { transform: scale(1.08); opacity: 0; } }
@keyframes loader-bars { 0%,100% { transform: scaleY(.55); opacity: .6; } 50% { transform: scaleY(1); opacity: 1; } }

.login-background-preview { width: 100%; max-height: 260px; object-fit: contain; object-position: center; display: block; background: #f0f1f4; border: 1px solid var(--border-color); border-radius: 10px; padding: 8px; margin-bottom: 14px; }
/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; }
.auth-visual {
  flex: 1.2; background-size: 100% 100%; background-position: center; background-repeat: no-repeat;
  background-color: var(--primary);
  display: flex; align-items: flex-end; padding: 50px;
  color: #fff; position: relative;
}
.auth-visual::before { content:''; position:absolute; inset:0; background: linear-gradient(0deg, rgba(20,20,60,.65), rgba(20,20,60,.15)); }
.auth-visual .quote { position: relative; z-index: 1; max-width: 420px; }
.auth-form-side { flex: 1; display: flex; align-items: center; justify-content: center; padding: 30px; }
.auth-form-box { width: 100%; max-width: 380px; }
.auth-form-box h1 { font-size: 24px; margin-bottom: 6px; }
.auth-form-box p.sub { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

/* ---------- Employee form ---------- */
.employee-form-card { width: 100%; max-width: none; padding: 0; overflow: hidden; }
.employee-form { padding: 28px 30px 30px; }
.form-section { padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--border-color); }
.form-section-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.form-section-heading h2 { font-size: 16px; line-height: 1.3; font-weight: 700; color: var(--text-dark); }
.form-section-heading p { margin-top: 4px; color: var(--text-muted); font-size: 12.5px; line-height: 1.45; }
.form-section-icon { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: #eef0ff; color: var(--primary); flex-shrink: 0; }
.form-section-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.employee-form .form-group { margin-bottom: 18px; }
.employee-form .form-group label { color: #374151; }
.employee-form .form-control { min-height: 43px; padding: 10px 13px; border-color: #dfe2ea; }
.employee-form .form-control::placeholder { color: #a2a7b4; }
.employee-form .form-control:focus { box-shadow: 0 0 0 3px rgba(91,91,240,.12); }
.required-mark { color: #c0392b; }
.custom-heading { margin-top: 2px; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding-top: 4px; }
.form-actions .btn { min-height: 42px; }
/* ---------- Loader settings ---------- */
.loader-settings-card { max-width: none; padding: 28px; }
.loader-settings-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 26px; }
.loader-settings-heading h2 { font-size: 20px; margin-bottom: 5px; }
.settings-heading-icon { width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; background: #fff0bf; color: #e6a500; font-size: 27px; line-height: 1; }
.loader-settings-fields { margin-bottom: 30px; }
.loader-preview-label { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.loader-preview-stage { height: 208px; border: 2px solid #d9dce4; border-radius: 14px; background: #f0f1f4; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.loader-preview-content { width: calc(100% - 48px); height: calc(100% - 48px); border-radius: 12px; background: #fff; display: flex; align-items: center; justify-content: center; color: #9aa0b8; font-size: 16px; }
.loader-preview-cover { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.58); }
.loader-preview-stage.preview-running .loader-preview-cover { animation: preview-fade .8s ease; }
.loader-settings-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; }
@keyframes preview-fade { 0% { opacity: .35; } 35% { opacity: 1; } 100% { opacity: .7; } }
/* ---------- Projects ---------- */
.project-filters { display: grid; grid-template-columns: minmax(260px, 1fr) 190px auto auto; gap: 10px; align-items: center; margin-bottom: 18px; }
.project-filters .form-control { min-height: 40px; }
.project-date-cell { white-space: nowrap; }
.project-date-cell span { color: #a0a5b3; padding: 0 4px; }
.table-subtext { margin-top: 3px; font-size: 12px; }
.empty-table-state { text-align: center; padding: 34px 20px !important; color: var(--text-muted); }
.badge-warning { background: #fff4d6; color: #9a6700; }
.project-textarea { min-height: 92px; resize: vertical; }
.project-multi-select { min-height: 168px; padding: 8px; }
.project-multi-select option { padding: 7px 8px; border-radius: 5px; }
.project-summary-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 18px; }
.project-detail-card { min-width: 0; }
.project-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.project-card-heading h3 { margin: 0; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 0; }
.detail-list > div { padding: 12px 0; border-bottom: 1px solid var(--border-color); min-width: 0; }
.detail-list dt { color: var(--text-muted); font-size: 12px; margin-bottom: 4px; }
.detail-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.detail-list .detail-wide { grid-column: 1 / -1; }
.detail-list-single { grid-template-columns: 1fr; }
.supervisor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.supervisor-card { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 13px; border: 1px solid var(--border-color); border-radius: 10px; background: #fbfbff; }
.supervisor-avatar { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; font-weight: 700; flex-shrink: 0; }
.supervisor-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.supervisor-card p, .supervisor-card span { display: block; color: var(--text-muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ---------- Utility ---------- */
.text-muted { color: var(--text-muted); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-10 { margin-top: 10px; }
.mb-10 { margin-bottom: 10px; }
.w-full { width: 100%; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 992px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar .menu-toggle { display: block; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .page-body { padding: 16px; }
  .user-actions { min-width: 250px; }
  .user-action-group { justify-content: flex-start; }
  .document-row { display: flex; margin: 8px 0 0; }
  .document-name { max-width: 100%; width: 100%; }
  .document-preview-overlay { padding: 10px; }
  .document-preview-modal { width: 100%; height: 92vh; }
  .employee-form { padding: 22px 18px 20px; }
  .employee-form-card { max-width: none; }
  .project-filters { grid-template-columns: 1fr; }
  .project-filters .btn { width: 100%; justify-content: center; }
  .project-summary-grid { grid-template-columns: 1fr; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-list .detail-wide { grid-column: auto; }
  .loader-settings-card { padding: 20px 18px; }
  .loader-settings-actions { flex-direction: column-reverse; align-items: stretch; }
  .loader-settings-actions .btn { width: 100%; justify-content: center; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 999; }
  .sidebar-overlay.open { display: block; }
}
