/* ═══════════════════════════════════════════════════════
   Helpex ERP — Component Styles (Responsive + Theme-Aware)
   Requires helpex-variables.css to be loaded first.
   ═══════════════════════════════════════════════════════ */

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--hp-font);
  font-size: var(--hp-font-size-base);
  line-height: var(--hp-line-height);
  background-color: var(--hp-bg);
  color: var(--hp-text);
  transition: background-color var(--hp-transition), color var(--hp-transition);
  overflow-x: hidden;
}

a { color: var(--hp-secondary); transition: color var(--hp-transition-fast); }
a:hover { color: var(--hp-secondary-dark); }

::selection { background: var(--hp-secondary); color: #fff; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--hp-text-light); border-radius: var(--hp-radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--hp-text-muted); }

/* ── Sidebar Backdrop ── */
.sidebar-backdrop {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); z-index: var(--hp-z-backdrop);
  display: none; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.sidebar-backdrop.show { display: block; }

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: var(--hp-sidebar-width);
  background: var(--hp-gradient-sidebar); color: #fff;
  overflow-y: auto; overflow-x: hidden;
  transition: transform var(--hp-transition), width var(--hp-transition);
  z-index: var(--hp-z-sidebar);
  display: flex; flex-direction: column;
  pointer-events: none;
}
.sidebar * {
  pointer-events: auto;
}
.sidebar-brand {
  padding: var(--hp-space-6) var(--hp-space-4);
  font-size: var(--hp-font-size-xl);
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-align: center;
  letter-spacing: -0.5px;
  background: var(--hp-sidebar-brand-bg);
  flex-shrink: 0;
}
.sidebar-brand i { margin-right: 0.5rem; color: var(--hp-secondary); }
.sidebar-menu { padding: var(--hp-space-3) 0; flex: 1; }
.menu-item {
  padding: 0.6rem 1.25rem;
  color: var(--hp-sidebar-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  font-size: var(--hp-font-size-sm);
  transition: all var(--hp-transition-fast);
  border-left: 3px solid transparent;
  cursor: pointer;
}
.menu-item:hover {
  background: var(--hp-sidebar-bg-hover);
  color: var(--hp-sidebar-text-active);
  text-decoration: none;
}
.menu-item.active {
  background: var(--hp-sidebar-bg-active);
  color: var(--hp-sidebar-text-active);
  border-left-color: var(--hp-secondary);
  font-weight: 600;
}
.menu-item i { margin-right: 0.75rem; width: 18px; font-size: 1rem; flex-shrink: 0; }
.menu-item .bi-chevron-down { margin-left: auto; margin-right: 0; font-size: 0.75rem; transition: transform var(--hp-transition-fast); }
.menu-item[aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); }
.menu-section { margin-bottom: 0.25rem; }
.submenu { padding-left: 2.75rem; }
.submenu .menu-item { font-size: var(--hp-font-size-xs); padding: 0.45rem 1rem; }
.menu-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 0.5rem 1rem; }

/* ── Main Content ── */
.main-content {
  margin-left: var(--hp-sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--hp-transition);
}

/* ── Topbar ── */
.topbar {
  background: var(--hp-topbar-bg);
  border-bottom: 1px solid var(--hp-topbar-border);
  padding: var(--hp-space-4) var(--hp-space-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color var(--hp-transition), border-color var(--hp-transition);
  flex-shrink: 0;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--hp-space-3);
  min-width: 0;
}
.topbar-left h4 {
  margin: 0;
  font-size: var(--hp-font-size-lg);
  font-weight: 700;
  color: var(--hp-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--hp-transition);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--hp-space-3);
  flex-shrink: 0;
}
.topbar-right .dropdown-menu {
  background: var(--hp-surface);
  border: 1px solid var(--hp-border);
  box-shadow: var(--hp-shadow-lg);
}
.topbar-right .dropdown-item {
  color: var(--hp-text);
  font-size: var(--hp-font-size-sm);
}
.topbar-right .dropdown-item:hover {
  background: var(--hp-surface-hover);
  color: var(--hp-text);
}
.mobile-menu-toggle { display: none; }

/* ── Content Area ── */
.content-area {
  padding: var(--hp-space-6);
  flex: 1;
}

/* ── Cards ── */
.card, .form-section, .data-table {
  background: var(--hp-card-bg);
  border: 1px solid var(--hp-card-border);
  box-shadow: var(--hp-card-shadow);
  transition: background-color var(--hp-transition), border-color var(--hp-transition), box-shadow var(--hp-transition);
}
.stat-card {
  border-radius: var(--hp-radius-md);
  padding: var(--hp-space-6);
  color: #fff;
  box-shadow: var(--hp-shadow-md);
  transition: transform var(--hp-transition-fast);
}
.stat-card:hover { transform: translateY(-4px); }
.stat-card-primary { background: var(--hp-gradient-primary); }
.stat-card-success { background: var(--hp-gradient-success); }
.stat-card-warning { background: var(--hp-gradient-warning); }
.stat-card-info { background: var(--hp-gradient-info); }
.stat-card-danger { background: var(--hp-gradient-danger); }
.stat-card h3 { font-size: 2rem; margin: 0; font-weight: 700; }
.stat-card p { margin: 0.35rem 0 0 0; opacity: 0.9; font-size: var(--hp-font-size-sm); }

/* ── KPI Cards ── */
.kpi-card {
  border: none;
  border-radius: var(--hp-radius-md);
  box-shadow: var(--hp-card-shadow);
  transition: all var(--hp-transition-fast);
  position: relative;
  overflow: hidden;
  background: var(--hp-card-bg);
}
.kpi-card:hover { box-shadow: var(--hp-shadow-md); transform: translateY(-2px); }
.kpi-card .kpi-icon {
  width: 44px; height: 44px;
  border-radius: var(--hp-radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
}
.kpi-card .kpi-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; color: var(--hp-text); }
.kpi-card .kpi-label { font-size: 0.75rem; color: var(--hp-text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.kpi-card .kpi-trend { font-size: 0.7rem; font-weight: 600; }
.kpi-card .kpi-trend.up { color: var(--hp-success); }
.kpi-card .kpi-trend.down { color: var(--hp-danger); }
.kpi-card .kpi-subtitle { font-size: 0.72rem; color: var(--hp-text-muted); }

/* ── Tables ── */
.table-responsive { border-radius: var(--hp-radius-md); overflow: hidden; }
.data-table { overflow: hidden; }
.table-header {
  padding: var(--hp-space-4) var(--hp-space-5);
  border-bottom: 1px solid var(--hp-table-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--hp-space-3);
}
.table-header h5 { margin: 0; font-weight: 600; color: var(--hp-text); }

.table {
  margin: 0;
  color: var(--hp-text);
}
.table thead th {
  background: var(--hp-table-stripe);
  border-bottom: 2px solid var(--hp-table-border);
  color: var(--hp-text-secondary);
  font-size: var(--hp-font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--hp-space-3) var(--hp-space-4);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--hp-space-3) var(--hp-space-4);
  vertical-align: middle;
  border-bottom: 1px solid var(--hp-table-border);
  font-size: var(--hp-font-size-sm);
}
.table tbody tr:hover { background: var(--hp-table-hover); }
.table tbody tr:nth-child(even) { background: var(--hp-table-stripe); }
.table tbody tr:nth-child(even):hover { background: var(--hp-table-hover); }
.table-footer { padding: var(--hp-space-3) var(--hp-space-4); border-top: 1px solid var(--hp-table-border); }

/* ── Buttons ── */
.btn {
  font-size: var(--hp-font-size-sm);
  border-radius: var(--hp-radius-md);
  padding: 0.45rem 1rem;
  font-weight: 500;
  transition: all var(--hp-transition-fast);
}
.btn-sm { padding: 0.25rem 0.75rem; font-size: var(--hp-font-size-xs); }
.btn-lg { padding: 0.65rem 1.5rem; font-size: var(--hp-font-size-base); }
.btn-primary { background: var(--hp-secondary); border-color: var(--hp-secondary); color: #fff; }
.btn-primary:hover { background: var(--hp-secondary-dark); border-color: var(--hp-secondary-dark); }
.btn-outline-primary { color: var(--hp-secondary); border-color: var(--hp-secondary); }
.btn-outline-primary:hover { background: var(--hp-secondary); border-color: var(--hp-secondary); color: #fff; }

/* ── Forms ── */
.form-control, .form-select, textarea {
  background: var(--hp-input-bg);
  border: 1px solid var(--hp-input-border);
  color: var(--hp-text);
  font-size: var(--hp-font-size-sm);
  border-radius: var(--hp-radius-md);
  padding: 0.45rem 0.75rem;
  transition: background-color var(--hp-transition-fast), border-color var(--hp-transition-fast), box-shadow var(--hp-transition-fast);
}
.form-control:focus, .form-select:focus, textarea:focus {
  background: var(--hp-input-focus-bg);
  border-color: var(--hp-input-focus-border);
  box-shadow: 0 0 0 3px var(--hp-input-focus-ring);
  color: var(--hp-text);
}
.form-control:disabled, .form-select:disabled {
  background: var(--hp-input-disabled-bg);
  cursor: not-allowed;
}
.form-label { font-size: var(--hp-font-size-sm); font-weight: 500; color: var(--hp-text-secondary); margin-bottom: 0.35rem; }
.form-text { font-size: var(--hp-font-size-xs); color: var(--hp-text-muted); }
.form-section {
  border-radius: var(--hp-radius-lg);
  padding: var(--hp-space-5);
  margin-bottom: var(--hp-space-5);
}
.form-section .section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: var(--hp-font-size-base);
  font-weight: 700;
  color: var(--hp-text);
  border-bottom: 2px solid var(--hp-border);
  padding-bottom: var(--hp-space-4);
  margin-bottom: var(--hp-space-5);
}
.section-icon {
  width: 36px; height: 36px; border-radius: var(--hp-radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.icon-blue { background: #dbeafe; color: #1d4ed8; }
.icon-green { background: #dcfce7; color: #15803d; }
.icon-purple { background: #e9d5ff; color: #7c3aed; }
.icon-orange { background: #fed7aa; color: #c2410c; }
.icon-red { background: #fee2e2; color: #b91c1c; }
.icon-teal { background: #ccfbf1; color: #0f766e; }
[data-theme="dark"] .icon-blue { background: rgba(59,130,246,0.2); color: #93c5fd; }
[data-theme="dark"] .icon-green { background: rgba(34,197,94,0.2); color: #86efac; }
[data-theme="dark"] .icon-purple { background: rgba(168,85,247,0.2); color: #c4b5fd; }
[data-theme="dark"] .icon-orange { background: rgba(249,115,22,0.2); color: #fdba74; }
[data-theme="dark"] .icon-red { background: rgba(239,68,68,0.2); color: #fca5a5; }
[data-theme="dark"] .icon-teal { background: rgba(20,184,166,0.2); color: #5eead4; }

/* ── Sticky Actions (Bottom Action Bar) ── */
.sticky-actions {
  position: sticky; bottom: 0; z-index: calc(var(--hp-z-sidebar) + 1);
  background: var(--hp-surface);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-top: 1px solid var(--hp-border);
  padding: 0.9rem 1.5rem;
  display: flex; justify-content: space-between; align-items: center;
  transition: background-color var(--hp-transition), border-color var(--hp-transition);
}

/* ── Required Legend ── */
.required-legend { font-size: var(--hp-font-size-sm); color: var(--hp-text-muted); }

/* ── Detail Page Label/Value ── */
.detail-label {
  font-size: var(--hp-font-size-xs);
  color: var(--hp-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 2px;
}
.detail-value {
  font-size: var(--hp-font-size-base);
  color: var(--hp-text);
  font-weight: 500;
}

/* ── Quick Mode ── */
.quick-mode .wizard-stepper { display: none; }
.quick-mode .wizard-step { display: block !important; }
.quick-mode .sticky-actions .btn-secondary { display: none !important; }
.quick-mode .sticky-actions .btn-primary { display: none !important; }
.quick-mode .sticky-actions .btn-success { display: inline-flex !important; }
.quick-mode .sticky-actions .step-indicator-text { display: none; }

/* ── Step Indicator ── */
.step-indicator-text { font-size: var(--hp-font-size-sm); color: var(--hp-text-muted); }

/* ── Wizard Step Header ── */
.wizard-step-header h4 {
  font-size: var(--hp-font-size-lg);
  font-weight: 700;
  color: var(--hp-text);
  margin: 0;
}
.wizard-step-header p {
  font-size: var(--hp-font-size-sm);
  color: var(--hp-text-muted);
  margin: 0;
}

/* ── Badges / Status ── */
.badge-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--hp-radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-draft { background: var(--hp-badge-draft); color: var(--hp-badge-draft-text); }
.badge-pending { background: var(--hp-badge-pending); color: var(--hp-badge-pending-text); }
.badge-approved { background: var(--hp-badge-approved); color: var(--hp-badge-approved-text); }
.badge-rejected { background: var(--hp-badge-rejected); color: var(--hp-badge-rejected-text); }
.badge-in-transit { background: var(--hp-badge-in-transit); color: var(--hp-badge-in-transit-text); }

/* ── Select2 ── */
.select2-container--bootstrap-5 .select2-selection {
  min-height: calc(2rem + 2px);
  background: var(--hp-input-bg);
  border-color: var(--hp-input-border);
  border-radius: var(--hp-radius-md);
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
  line-height: calc(2rem + 2px);
  color: var(--hp-text);
}
.select2-container--bootstrap-5 .select2-dropdown {
  background: var(--hp-surface);
  border-color: var(--hp-border);
}

/* ── Global Search ── */
.global-search-input {
  background: var(--hp-bg);
  border: 1px solid transparent;
}
.global-search-input:focus {
  background: var(--hp-surface);
  border-color: var(--hp-secondary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  width: 300px !important;
  transition: width 0.3s ease;
}
.search-result-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--hp-border);
  cursor: pointer;
  transition: background var(--hp-transition-fast);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--hp-surface-hover); }
.search-result-item .result-icon {
  width: 32px; height: 32px; border-radius: var(--hp-radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 0.9rem;
}
.search-result-item .result-title { font-weight: 600; color: var(--hp-text); font-size: 0.85rem; }
.search-result-item .result-subtitle { font-size: 0.75rem; color: var(--hp-text-muted); }

/* ── Theme Toggle ── */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: var(--hp-radius-full);
  border: 1px solid var(--hp-border);
  background: var(--hp-surface);
  color: var(--hp-text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--hp-transition-fast);
}
.theme-toggle:hover { border-color: var(--hp-secondary); color: var(--hp-secondary); }

/* ── Activity Timeline ── */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: ''; position: absolute; left: 8px; top: 4px; bottom: 4px;
  width: 2px; background: var(--hp-border);
}
.timeline-item { position: relative; padding-bottom: 1.25rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ''; position: absolute; left: -1.65rem; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--hp-surface); border: 2px solid var(--hp-border);
}
.timeline-item.timeline-success::before { border-color: var(--hp-success); }
.timeline-item.timeline-warning::before { border-color: var(--hp-warning); }
.timeline-item.timeline-danger::before  { border-color: var(--hp-danger); }
.timeline-item.timeline-info::before    { border-color: var(--hp-secondary); }
.timeline-time  { font-size: 0.72rem; color: var(--hp-text-muted); margin-bottom: 2px; }
.timeline-content { font-size: 0.82rem; color: var(--hp-text-secondary); }

/* ── Related Documents ── */
.related-doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.related-doc-card {
  border: 1px solid var(--hp-border); border-radius: var(--hp-radius-md);
  padding: 12px 14px; transition: all var(--hp-transition-fast);
  background: var(--hp-card-bg); text-decoration: none; display: block;
}
.related-doc-card:hover { border-color: var(--hp-secondary); box-shadow: 0 2px 8px rgba(37,99,235,0.1); }
.related-doc-card .doc-icon {
  width: 34px; height: 34px; border-radius: var(--hp-radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; flex-shrink: 0;
}
.related-doc-card .doc-title { font-weight: 600; font-size: 0.82rem; color: var(--hp-text); }
.related-doc-card .doc-subtitle { font-size: 0.72rem; color: var(--hp-text-muted); }
.related-doc-card .doc-badge { font-size: 0.65rem; padding: 1px 6px; border-radius: 10px; }

/* ── Bulk Action Toolbar ── */
.bulk-action-toolbar {
  position: fixed; bottom: -60px; left: 50%;
  transform: translateX(-50%);
  background: var(--hp-surface);
  border: 1px solid var(--hp-border);
  color: var(--hp-text);
  padding: 10px 20px;
  border-radius: var(--hp-radius-lg);
  box-shadow: var(--hp-shadow-xl);
  transition: bottom var(--hp-transition);
  z-index: var(--hp-z-toolbar);
  display: flex; align-items: center; gap: 10px;
}
.bulk-action-toolbar.show { bottom: 20px; }
.bulk-action-toolbar .count { font-weight: 700; color: var(--hp-secondary); }
.bulk-action-toolbar .btn-sm { padding: 3px 10px; font-size: 0.78rem; }

/* ── Related Documents ── */
.related-doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }

/* ── Audit ── */
.audit-filters { background: var(--hp-card-bg); border-radius: var(--hp-radius-md); padding: var(--hp-space-4); box-shadow: var(--hp-card-shadow); margin-bottom: var(--hp-space-4); }
.audit-filters .filter-row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: end; }
.audit-filters .filter-row > * { min-width: 140px; }
.audit-diff { font-size: 0.8rem; }
.audit-diff .diff-old { background: rgba(220,38,38,0.12); color: var(--hp-danger); padding: 0 4px; border-radius: 3px; text-decoration: line-through; }
.audit-diff .diff-new { background: rgba(22,163,74,0.12); color: var(--hp-success); padding: 0 4px; border-radius: 3px; }

/* ── Login Page ── */
.login-container {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--hp-gradient-primary);
  padding: var(--hp-space-4);
}
.login-card {
  background: var(--hp-surface);
  border-radius: var(--hp-radius-xl);
  box-shadow: var(--hp-shadow-xl);
  overflow: hidden;
  width: 100%;
  max-width: 900px;
  display: flex;
}
.login-left {
  flex: 1; padding: 3rem;
  background: var(--hp-gradient-sidebar);
  color: #fff;
  display: flex; flex-direction: column; justify-content: center;
}
.login-left h1 { font-size: 2rem; margin-bottom: 0.75rem; font-weight: 700; }
.login-left p { font-size: 1rem; opacity: 0.85; }
.login-right { flex: 1; padding: 3rem; }
.login-right h2 { color: var(--hp-text); margin-bottom: 0.5rem; }
.login-right .form-control { padding: 0.75rem 1rem; border-radius: var(--hp-radius-md); }
.btn-login {
  padding: 0.75rem 2rem; border-radius: var(--hp-radius-md);
  background: var(--hp-gradient-primary); border: none;
  font-weight: 600; width: 100%; color: #fff;
}
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(102,126,234,0.3); }

/* ── Wizard Stepper ── */
.wizard-stepper {
  display: flex; justify-content: center; align-items: center;
  margin-bottom: 2rem; position: relative; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.stepper-line {
  position: absolute; top: 20px; left: 50%; width: 100%; height: 2px;
  background: var(--hp-border); z-index: 1; transform: translateX(50%);
  transition: background var(--hp-transition);
}
.stepper-item {
  display: flex; flex-direction: column; align-items: center;
  position: relative; z-index: 2; width: 130px; flex-shrink: 0;
  text-decoration: none; cursor: pointer;
}
.stepper-circle {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--hp-surface); border: 2px solid var(--hp-border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 1rem;
  color: var(--hp-text-light);
  transition: all 0.3s ease;
  flex-shrink: 0;
}
.stepper-label {
  margin-top: 0.5rem;
  font-size: 0.8rem; font-weight: 600;
  color: var(--hp-text-muted);
  text-align: center; white-space: nowrap;
}
.stepper-item.active .stepper-circle {
  border-color: var(--hp-secondary);
  background: var(--hp-secondary);
  color: #fff;
  box-shadow: 0 0 0 4px var(--hp-input-focus-ring);
  transform: scale(1.1);
}
.stepper-item.active .stepper-label { color: var(--hp-secondary); font-weight: 700; }
.stepper-item.completed .stepper-circle {
  border-color: var(--hp-success);
  background: var(--hp-success);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(25,135,84,0.2);
}
.stepper-item.completed .stepper-label { color: var(--hp-success); }
.stepper-item.completed .stepper-line { background: var(--hp-success); }
.wizard-step { animation: fadeIn 0.35s ease; }

/* ── Stepper Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stepper-pulse {
  animation: pulseGlow 2s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 4px var(--hp-input-focus-ring); }
  50% { box-shadow: 0 0 0 8px var(--hp-input-focus-ring); }
}

/* ── Misc ── */
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--hp-secondary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--hp-font-size-sm);
  flex-shrink: 0;
}
.spinner-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.4); display: none;
  justify-content: center; align-items: center;
  z-index: var(--hp-z-spinner);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.spinner-overlay.show { display: flex; }
.keyboard-shortcut-hint {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--hp-text); color: var(--hp-text-inverse);
  padding: 6px 18px; border-radius: 20px;
  font-size: 0.78rem; z-index: 10001;
  opacity: 0; transition: opacity var(--hp-transition-fast);
  pointer-events: none;
}
.keyboard-shortcut-hint.show { opacity: 1; }
.req-star { color: var(--hp-danger); font-weight: 700; margin-left: 2px; }
.opt-badge {
  font-size: 0.65rem; color: var(--hp-text-muted);
  font-weight: 500; margin-left: 4px;
  background: var(--hp-bg); padding: 2px 6px; border-radius: 4px;
}
.notification-bell .badge { animation: pulse-badge 2s infinite; }
@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ── Quick Modal ── */
.quick-create-modal .modal-header { background: var(--hp-gradient-sidebar); color: #fff; border: none; }
.quick-create-modal .modal-header .btn-close { filter: invert(1); }
.quick-create-modal .modal-body { max-height: 70vh; overflow-y: auto; }
.modal-content { background: var(--hp-surface); border: 1px solid var(--hp-border); }
.modal-header { border-bottom: 1px solid var(--hp-border); }
.modal-footer { border-top: 1px solid var(--hp-border); }
.btn-close { filter: none; }
.btn-close:hover { opacity: 0.75; }

/* ── Toast ── */
.toast { background: var(--hp-surface); color: var(--hp-text); border: 1px solid var(--hp-border); }

/* ── Page Loader ── */
.page-loader {
  position: fixed; top: 0; left: 0; width: 100%; height: 3px;
  background: transparent; z-index: 10002;
  overflow: hidden;
}
.page-loader::after {
  content: ''; display: block; width: 40%; height: 100%;
  background: var(--hp-secondary);
  animation: loader-slide 1s ease-in-out infinite;
}
@keyframes loader-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ── Attachment Upload ── */
.attachment-upload-card {
  border: 2px dashed var(--hp-border);
  border-radius: var(--hp-radius-md); padding: var(--hp-space-4);
  text-align: center; transition: all var(--hp-transition-fast);
  background: var(--hp-bg);
}
.attachment-upload-card:hover {
  border-color: var(--hp-secondary);
  background: var(--hp-surface-hover);
}
.attachment-item { background: var(--hp-surface); font-size: 0.82rem; }

/* ── Breadcrumb ── */
.breadcrumb { margin: 0; }
.breadcrumb-item a { color: var(--hp-text-muted); text-decoration: none; }
.breadcrumb-item a:hover { color: var(--hp-secondary); }
.breadcrumb-item.active { color: var(--hp-text); }
.breadcrumb-item + .breadcrumb-item::before { content: '›'; }

/* ── Dashboard Grid ── */
.dashboard-grid { display: grid; gap: var(--hp-space-4); }
.dashboard-grid-4 { grid-template-columns: repeat(4, 1fr); }
.dashboard-grid-3 { grid-template-columns: repeat(3, 1fr); }
.dashboard-grid-2 { grid-template-columns: repeat(2, 1fr); }

/* ── Print Styles ── */
@media print {
  .sidebar, .topbar, .bulk-action-toolbar, .btn, .no-print,
  .theme-toggle, .notification-bell, .mobile-menu-toggle,
  #globalSearchDropdown, #sidebarBackdrop { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .content-area { padding: 0 !important; }
  body { font-size: 10pt; color: #000; background: #fff; }
  .card, .form-section, .data-table { box-shadow: none; border: 1px solid #ddd; }
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   Mobile-first approach matching Bootstrap 5 grid
   ═══════════════════════════════════════════════════════ */

/* ── sm: ≥576px ── */
@media (min-width: 576px) {
  .dashboard-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .content-area { padding: var(--hp-space-5); }
}

/* ── md: ≥768px (tablet) ── */
@media (min-width: 768px) {
  .mobile-menu-toggle { display: none !important; }
  .sidebar { transform: translateX(0) !important; }
  .main-content { margin-left: var(--hp-sidebar-width) !important; }
  .sidebar-backdrop { display: none !important; }
  .dashboard-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid-3 { grid-template-columns: repeat(3, 1fr); }
  .topbar { padding: var(--hp-space-4) var(--hp-space-6); }
}

/* ── lg: ≥992px (desktop) ── */
@media (min-width: 992px) {
  .dashboard-grid-4 { grid-template-columns: repeat(4, 1fr); }
  .dashboard-grid-2 { grid-template-columns: repeat(2, 1fr); }
  .content-area { padding: var(--hp-space-6); }
}

/* ── xl: ≥1200px (wide) ── */
@media (min-width: 1200px) {
  .content-area { max-width: 1400px; margin: 0 auto; width: 100%; }
}

/* ── xs: <576px (mobile) ── */
@media (max-width: 575.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-menu-toggle { display: block; }
  .topbar { padding: var(--hp-space-3); }
  .topbar-left h4 { font-size: var(--hp-font-size-base); }
  .content-area { padding: var(--hp-space-3); }
  .global-search-input { width: 120px !important; }
  .global-search-input:focus { width: 180px !important; }
  .kpi-card .kpi-value { font-size: 1.2rem; }
  .table-responsive { font-size: 0.75rem; }
  .related-doc-grid { grid-template-columns: 1fr; }
  .stat-card { padding: var(--hp-space-4); }
  .stat-card h3 { font-size: 1.5rem; }
  .login-card { flex-direction: column; max-width: 400px; }
  .login-left { display: none; }
  .login-right { padding: 2rem; }
  .form-section { padding: var(--hp-space-4); }
  .dashboard-grid-4,
  .dashboard-grid-3,
  .dashboard-grid-2 { grid-template-columns: 1fr; }
  .wizard-stepper { justify-content: flex-start; gap: 1rem; padding: 10px; }
  .wizard-stepper::before { display: none; }
  .stepper-label { font-size: 0.65rem; }
  .table-header { flex-direction: column; align-items: stretch; gap: var(--hp-space-2); }
  .bulk-action-toolbar { left: 10px; right: 10px; transform: none; padding: 8px 12px; flex-wrap: wrap; }
  .bulk-action-toolbar.show { bottom: 10px; }
  .breadcrumb { display: none; }
  .topbar .breadcrumb { display: none; }
}

/* ── Responsive Table (data-label pattern for mobile) ── */
@media (max-width: 767.98px) {
  table[data-responsive] thead { display: none; }
  table[data-responsive] tbody tr {
    display: block;
    border: 1px solid var(--hp-table-border);
    border-radius: var(--hp-radius-md);
    margin-bottom: var(--hp-space-3);
    padding: var(--hp-space-3);
    background: var(--hp-table-bg);
  }
  table[data-responsive] tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--hp-space-2) 0;
    border: none;
    text-align: right;
    gap: var(--hp-space-2);
  }
  table[data-responsive] tbody td:not(:last-child) {
    border-bottom: 1px solid var(--hp-border-light);
  }
  table[data-responsive] tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: var(--hp-font-size-xs);
    color: var(--hp-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    text-align: left;
  }
  table[data-responsive] tbody td:empty { display: none; }
}

/* ── Reduce motion if user prefers ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* RTL Support for Arabic */
[dir="rtl"] .sidebar { float: right; }
[dir="rtl"] .main-content { margin-right: 250px; margin-left: 0; }
[dir="rtl"] .navbar-nav { margin-right: auto; margin-left: 0; }
[dir="rtl"] .dropdown-menu { text-align: right; }
[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before { content: "\276E"; }
[dir="rtl"] .table th { text-align: right; }
[dir="rtl"] .float-start { float: right !important; }
[dir="rtl"] .float-end { float: left !important; }
[dir="rtl"] .ms-auto { margin-right: auto !important; margin-left: 0 !important; }
[dir="rtl"] .me-auto { margin-left: auto !important; margin-right: 0 !important; }
[dir="rtl"] .text-start { text-align: right !important; }
[dir="rtl"] .text-end { text-align: left !important; }
[dir="rtl"] .search-bar { direction: rtl; }
[dir="rtl"] input, [dir="rtl"] textarea { direction: rtl; }

/* ── md only <768px (tablet portrait) ── */
@media (max-width: 767.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-menu-toggle { display: block; }
  .topbar-left h4 { font-size: var(--hp-font-size-base); }
  .content-area { padding: var(--hp-space-4); }
  .global-search-input { width: 140px !important; }
  .global-search-input:focus { width: 200px !important; }
}

/* ── Sidebar responsive: collapse on smaller screens ── */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-menu-toggle { display: block; }
}
