/* ============================================================================
 * ninatrans-hris-theme.css — WMS design-system reskin for the HRIS app
 *
 * Load this LAST in base.html (after styles.css and tailwind.build.css):
 *   <link rel="stylesheet"
 *         href="{{ url_for('static', filename='css/ninatrans-hris-theme.css') }}">
 *
 * It re-tunes the design tokens and re-skins BOTH Bootstrap components AND the
 * app's own component classes (.modern-*, .card-custom, .status-badge, …) so
 * every one of the ~145 existing templates adopts the WMS look with no per-page
 * edits. To revert: remove the single <link>.
 *
 * Palette: white base · brand red #AB0534 · light-grey secondary surfaces ·
 * flat elevation · 8px radius · dense, legible tables.
 * ========================================================================== */

:root {
  /* Brand (HSL components — used as hsl(var(--primary)) / …/ .08 for alpha) */
  --primary: 343 94% 34%;            /* #AB0534 */
  --primary-foreground: 0 0% 100%;
  --primary-light: 343 90% 88%;
  --primary-dark: 342 94% 27%;       /* #85042A */
  --ring: 343 94% 34%;

  --background: 0 0% 100%;
  --foreground: 240 6% 10%;          /* #18181B */
  --card: 0 0% 100%;
  --card-border: 240 6% 90%;
  --border: 240 6% 90%;
  --input: 240 6% 90%;
  --secondary: 240 5% 96%;           /* #F4F4F5 */
  --muted: 240 5% 96%;
  --muted-foreground: 240 4% 46%;
  --accent: 240 5% 96%;

  --success: 142 71% 45%;
  --success-light: 142 76% 90%;
  --warning: 45 93% 47%;
  --warning-light: 45 93% 90%;
  --danger: 0 84% 60%;
  --danger-light: 0 84% 95%;
  --info: 217 91% 60%;
  --info-light: 217 91% 90%;

  --radius: 0.5rem;
  --shadow-card: 0 1px 3px hsl(240 5% 0% / 0.06);
  --shadow-elevated: 0 4px 14px hsl(240 5% 0% / 0.08), 0 2px 4px hsl(240 5% 0% / 0.04);
  --shadow-primary: 0 4px 12px hsl(343 94% 34% / 0.18);

  /* Aliases the app's styles.css / base.html reference directly */
  --accent-color: #AB0534;
  --accent-color-dark: #85042A;
  --success-color: #16a34a;
  --warning-color: #d97706;
  --danger-color: #dc2626;
  --info-color: #2563eb;
  --bg-primary: #ffffff;
  --bg-secondary: #f4f4f5;
  --text-primary: #18181b;
  --text-secondary: #71717a;
  --text-muted: #a1a1aa;
  --border-color: #e4e4e7;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --brand: #AB0534;
  --brand-dark: #85042A;
  --bg-hover: hsl(343 94% 34% / 0.08);
  --bg-color: #ffffff;
}

/* ---- Base ---------------------------------------------------------------- */
body {
  background-color: #ffffff !important;
  color: hsl(var(--foreground));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
}
h1, h2 { color: hsl(var(--foreground)); }
a { color: hsl(var(--primary)); }
a:hover { color: hsl(var(--primary-dark)); }

.main-content { padding: 1.75rem; }
.modern-page { background: #ffffff; padding: 1.75rem; }

/* ---- Top navigation shell ----------------------------------------------- */
.top-nav {
  background: #ffffff !important;
  border-bottom: 1px solid hsl(var(--card-border));
  box-shadow: var(--shadow-card);
}
.nav-brand img { height: 30px; width: auto; }

.nav-link-top {
  border-radius: var(--radius);
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}
.nav-link-top:hover:not(.active),
.nav-link-top:focus:not(.active) {
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
}
.nav-link-top.active {
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.1);
  border-color: hsl(var(--primary) / 0.2);
  font-weight: 600;
}
.nav-link-top.active .nav-icon-i { opacity: 1; }

.nav-dropdown {
  border: 1px solid hsl(var(--card-border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-elevated);
}
.nav-dropdown-item { color: hsl(var(--muted-foreground)); border-radius: calc(var(--radius) - 2px); }
.nav-dropdown-item i, .nav-dropdown-item .dropdown-icon { color: hsl(var(--primary)); }
.nav-dropdown-item:hover {
  background: hsl(var(--primary) / 0.08);
  color: hsl(var(--primary));
  transform: none;                    /* drop the slide-right micro-anim */
}
.nav-dropdown-section, .mobile-section-title { color: hsl(var(--primary)); }

/* User pill + logout */
.user-pill { border: 1px solid hsl(var(--card-border)); border-radius: var(--radius); }
.user-pill:hover { background: hsl(var(--muted)); border-color: hsl(var(--card-border)); }
.user-avatar-sm {
  background: hsl(var(--primary) / 0.1) !important;
  box-shadow: none !important;
  border-radius: 999px;
}
.user-avatar-sm i, .user-avatar-sm .user-avatar-icon { color: hsl(var(--primary)) !important; }
.user-name-sm { color: hsl(var(--foreground)); }
.user-role-sm { color: hsl(var(--muted-foreground)); }
.logout-btn { border: 1px solid hsl(var(--card-border)); border-radius: var(--radius); color: hsl(var(--muted-foreground)); }
.logout-btn:hover { background: hsl(var(--primary) / 0.08); border-color: hsl(var(--primary) / 0.3); color: hsl(var(--primary)); }

/* ---- Buttons: every variant reads as the solid red primary -------------- */
.btn-primary, .btn-info,
.btn-modern-primary,
.btn-outline-primary {
  background: hsl(var(--primary)) !important;
  border: 1px solid hsl(var(--primary)) !important;
  color: #fff !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-primary);
  font-weight: 500;
}
.btn-primary:hover, .btn-info:hover,
.btn-modern-primary:hover, .btn-outline-primary:hover,
.btn-primary:focus, .btn-modern-primary:focus {
  background: hsl(var(--primary-dark)) !important;
  border-color: hsl(var(--primary-dark)) !important;
  color: #fff !important;
  transform: none !important;         /* remove the lift */
  box-shadow: var(--shadow-primary);
}
/* Secondary / neutral buttons: white with hairline border */
.btn-secondary, .btn-light, .btn-outline-secondary,
.btn-modern-secondary, .filter-clear-btn {
  background: #fff !important;
  border: 1px solid hsl(var(--card-border)) !important;
  color: hsl(var(--foreground)) !important;
  border-radius: var(--radius) !important;
  box-shadow: none !important;
  font-weight: 500;
}
.btn-secondary:hover, .btn-light:hover, .btn-outline-secondary:hover,
.btn-modern-secondary:hover, .filter-clear-btn:hover {
  background: hsl(var(--muted)) !important;
  color: hsl(var(--foreground)) !important;
  transform: none !important;
}
.btn-danger {
  background: hsl(var(--danger)) !important;
  border-color: hsl(var(--danger)) !important;
  border-radius: var(--radius) !important;
}
.btn { border-radius: var(--radius); }

/* ---- Cards -------------------------------------------------------------- */
.card, .card-custom, .modern-card, .summary-card {
  border: 1px solid hsl(var(--card-border)) !important;
  border-radius: var(--radius) !important;
  background: #fff;
  box-shadow: var(--shadow-card) !important;
}
.card-header, .modern-card-header {
  background: transparent !important;
  border-bottom: 1px solid hsl(var(--card-border)) !important;
  font-weight: 600;
  font-size: 0.95rem;
  color: hsl(var(--foreground));
  padding: 0.85rem 1.1rem;
}
.card-body { padding: 1.25rem; background: #fff; }
.card-title, .modern-card-title { color: hsl(var(--foreground)); }
.modern-card-title i { color: hsl(var(--primary)); }

/* ---- Page header / titles ---------------------------------------------- */
.page-header { margin-bottom: 1.25rem; }
.page-title, .modern-page .page-title, .bold-title {
  color: hsl(var(--foreground));
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.page-subtitle { color: hsl(var(--muted-foreground)); font-size: 0.9rem; }
.section-heading, .section-heading i { color: hsl(var(--foreground)); }
.section-heading i { color: hsl(var(--primary)); }

/* ---- Summary / stat cards ---------------------------------------------- */
.controls-section { border: 1px solid hsl(var(--card-border)); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.summary-card { padding: 1.1rem 1.2rem; }
.summary-card-header { color: hsl(var(--muted-foreground)); font-size: 0.72rem; letter-spacing: 0.04em; }
.summary-card-header i { color: hsl(var(--primary)); }
.summary-card-value { color: hsl(var(--foreground)); font-size: 1.75rem; }
.summary-card.success .summary-card-header i { color: hsl(var(--success)); }
.summary-card.warning .summary-card-header i { color: hsl(var(--warning)); }
.summary-card.info .summary-card-header i { color: hsl(var(--info)); }

/* ---- Forms -------------------------------------------------------------- */
.form-control, .modern-input, .modern-select, select, textarea {
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  color: hsl(var(--foreground));
}
.form-control:focus, .modern-input:focus, .modern-select:focus,
select:focus, textarea:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.13);
  outline: none;
}
.filter-label { color: hsl(var(--muted-foreground)); font-size: 0.72rem; letter-spacing: 0.04em; }

/* Enhanced dropdowns (Tom Select + Select2) */
.ts-wrapper,
.select2-container {
  width: 100% !important;
}
.ts-wrapper .ts-control {
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  min-height: 36px;
  box-shadow: none;
  background: #fff;
}
.ts-wrapper.focus .ts-control {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.13);
}
.ts-wrapper .ts-dropdown {
  border: 1px solid hsl(var(--card-border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-elevated);
}
/* While typing in single-select mode, hide selected label text */
.ts-wrapper.single.input-active .ts-control > .item {
  display: none;
}

.select2-container .select2-selection--single,
.select2-container .select2-selection--multiple {
  border: 1px solid hsl(var(--input)) !important;
  border-radius: var(--radius) !important;
  min-height: 36px !important;
  box-shadow: none !important;
}
.select2-container--focus .select2-selection--single,
.select2-container--focus .select2-selection--multiple,
.select2-container--open .select2-selection--single,
.select2-container--open .select2-selection--multiple {
  border-color: hsl(var(--primary)) !important;
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.13) !important;
}
.select2-dropdown {
  border: 1px solid hsl(var(--card-border)) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-elevated) !important;
}

/* Shared table style for settings/config modules (assets table baseline) */
.asset-table th,
.cfg-unified-table th {
  font-size: 11px !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground)) !important;
  font-weight: 700 !important;
}
.asset-table td,
.cfg-unified-table td {
  font-size: 13.5px !important;
  color: hsl(var(--foreground)) !important;
  vertical-align: middle;
}
.asset-table .timestamp,
.cfg-unified-table .timestamp {
  font-size: 12.5px;
  color: hsl(var(--muted-foreground));
}
.asset-filter-row th,
.cfg-unified-filter-row th {
  background: hsl(var(--muted) / 0.45) !important;
}
.asset-filter-row .form-control,
.asset-filter-row .form-select,
.cfg-unified-filter-row .form-control,
.cfg-unified-filter-row .form-select {
  font-size: 12px;
  height: 34px;
}
.row-actions,
.cfg-row-actions {
  white-space: nowrap;
}
.row-actions .btn,
.cfg-row-actions .btn {
  padding: 0.3rem 0.45rem;
}
.row-actions .btn + .btn,
.cfg-row-actions .btn + .btn {
  margin-left: 0.3rem;
}

/* ---- Onboarding filter bar + actions dropdown --------------------------- */
.onb-wrap .flow-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.onb-wrap .flow-controls .form-select,
.onb-wrap .flow-controls .form-control {
  min-width: 180px;
  font-size: .85rem;
}
.onb-wrap .flow-controls .ts-wrapper {
  width: 220px !important;
  flex: 0 0 220px;
}
.onb-wrap .flow-controls .search-wrap {
  position: relative;
  margin-left: auto;
}
.onb-wrap .flow-controls .search-wrap i {
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  color: hsl(var(--muted-foreground));
  font-size: .78rem;
  pointer-events: none;
}
.onb-wrap .flow-controls .search-wrap .form-control {
  width: 220px;
  min-width: 220px;
  padding-left: 2rem;
}
.onb-wrap .actions-dropdown {
  position: relative;
  display: inline-block;
}
.onb-wrap .dropdown-menu-modern {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow-card);
  border: 1px solid hsl(var(--card-border));
  min-width: 145px;
  z-index: 1000;
  display: none;
}
.onb-wrap .dropdown-menu-modern.show { display: block; }
.onb-wrap .dropdown-item-modern {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem .8rem;
  color: hsl(var(--foreground));
  font-size: 12.5px;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.onb-wrap .dropdown-item-modern:hover {
  background: hsl(var(--muted));
  text-decoration: none;
}
.onb-wrap .dropdown-item-modern.text-danger {
  color: #b91c1c;
}
.onb-wrap .dropdown-item-modern.text-danger:hover {
  background: #fef2f2;
}
@media (max-width: 900px) {
  .onb-wrap .flow-controls .search-wrap {
    margin-left: 0;
    width: 100%;
  }
  .onb-wrap .flow-controls .search-wrap .form-control {
    width: 100%;
    min-width: 0;
  }
}

/* ---- Tables (dense, CRM-aligned) --------------------------------------- */
.table, .modern-table { color: hsl(var(--foreground)); margin: 0; }
.table thead th, .modern-table th {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  font-weight: 600;
  border-bottom: 1px solid hsl(var(--card-border));
  white-space: nowrap;
  padding: 0.7rem 0.85rem;
}
.table > :not(caption) > * > *, .modern-table td {
  padding: 0.7rem 0.85rem;
  border-bottom-color: hsl(var(--card-border));
  vertical-align: middle;
}
.table-hover tbody tr:hover,
.modern-table tbody tr:hover {
  background: hsl(var(--primary) / 0.04) !important;
  color: hsl(var(--foreground));
}
.table-striped tbody tr:nth-of-type(odd) { background-color: hsl(var(--muted) / 0.5); }
.employee-cell strong, .policy-cell strong { color: hsl(var(--foreground)); }
.muted-text { color: hsl(var(--muted-foreground)); }

/* Table wrappers as framed cards */
.table-responsive {
  border: 1px solid hsl(var(--card-border));
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-card);
  overflow: auto;
}

/* ---- Badges / status pills --------------------------------------------- */
.badge { font-weight: 600; letter-spacing: 0.01em; border-radius: 999px; padding: 0.3em 0.7em; }
.badge-success, .status-badge.success { background: hsl(var(--success-light)); color: hsl(142 71% 26%); }
.badge-warning, .status-badge.warning { background: hsl(var(--warning-light)); color: hsl(32 95% 30%); }
.badge-danger,  .status-badge.danger  { background: hsl(var(--danger-light)); color: hsl(0 70% 38%); }
.badge-info,    .status-badge.info    { background: hsl(var(--info-light)); color: hsl(217 91% 35%); }
.badge-primary { background: hsl(var(--primary) / 0.12); color: hsl(var(--primary)); }
.status-badge { border-radius: 999px; font-weight: 600; padding: 0.25rem 0.7rem; }
.status-badge.secondary { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }

/* Optional shared status-pill set (matches WMS) */
.wms-status-pill { display: inline-flex; align-items: center; padding: 0.25rem 0.65rem; border-radius: 999px; font-size: 12px; font-weight: 600; }
.wms-status-pill--active, .wms-status-pill--valid, .wms-status-pill--complete { background: hsl(var(--success-light)); color: hsl(142 71% 26%); }
.wms-status-pill--pending, .wms-status-pill--expiring { background: hsl(var(--warning-light)); color: hsl(32 95% 30%); }
.wms-status-pill--expired, .wms-status-pill--overdue { background: hsl(var(--danger-light)); color: hsl(0 70% 38%); }
.wms-status-pill--inactive, .wms-status-pill--draft { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.wms-status-pill--info { background: hsl(var(--info-light)); color: hsl(217 91% 35%); }

/* Status pills glow softly in their own colour, like the WMS progress lines. */
.wms-status-pill, .status-pill, .status-badge, .doc-status-pill, .badge-modern {
  box-shadow: 0 0 8px color-mix(in srgb, currentColor 35%, transparent);
}

/* ---- Progress bars ------------------------------------------------------ */
.progress { background: hsl(var(--muted)); border-radius: 999px; height: 8px; }
.progress-bar { background: hsl(var(--primary)); border-radius: 999px; }
.progress-bar-100 { background: hsl(var(--success)) !important; }
.progress-percentage { color: hsl(var(--foreground)); }

/* ---- Icon action buttons ----------------------------------------------- */
.icon-action { border-radius: var(--radius); }
.row-actions .btn-primary, .row-actions .icon-action { min-width: 2rem; }

/* ---- Alerts (flatten the gradients to solid tints) --------------------- */
.alert { border: 1px solid transparent; border-radius: var(--radius); box-shadow: none; font-weight: 500; }
.alert-success { background: hsl(var(--success-light)); color: hsl(142 71% 24%); border-left: 3px solid hsl(var(--success)); }
.alert-error, .alert-danger { background: hsl(var(--danger-light)); color: hsl(0 70% 38%); border-left: 3px solid hsl(var(--danger)); }
.alert-warning { background: hsl(var(--warning-light)); color: hsl(32 95% 28%); border-left: 3px solid hsl(var(--warning)); }
.alert-info { background: hsl(var(--info-light)); color: hsl(217 91% 32%); border-left: 3px solid hsl(var(--info)); }

/* ---- Tabs --------------------------------------------------------------- */
.nav-tabs .nav-link.active { color: hsl(var(--primary)); border-color: hsl(var(--card-border)) hsl(var(--card-border)) #fff; font-weight: 600; }
.nav-tabs .nav-link:hover { color: hsl(var(--primary)); }

/* ---- Drag/drop upload area --------------------------------------------- */
.drag-drop-area { border: 2px dashed hsl(var(--card-border)); border-radius: var(--radius); }
.drag-drop-area.dragover { border-color: hsl(var(--primary)); background: hsl(var(--primary) / 0.04); }

/* ---- Date status accents (keep semantic, align hues) ------------------- */
.date-expired, .date-status-indicator.expired { color: hsl(0 70% 45%) !important; }
.date-expiring-soon, .date-status-indicator.expiring-soon { color: hsl(32 95% 38%) !important; }
.expiring-soon { background-color: hsl(var(--warning-light)) !important; }
.expired { background-color: hsl(var(--danger-light)) !important; }
