/* ================================================================
   HRPMS Pro – Component Library
   Refined Enterprise Components
   ================================================================ */

/* ════════════════════════════════════════════
   CARDS
   ════════════════════════════════════════════ */
.card {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--gray-300);
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--white);
}

.card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -0.2px;
}

.card-body {
  padding: 12px 16px;
}

/* KPI Card Style (Dashboard Style) */
.kpi-card {
  padding: 8px 12px !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 52px;
  border-left: 3px solid var(--primary);
}

.kpi-card .kpi-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-card .kpi-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}

.kpi-card .kpi-sub {
  font-size: 0.6rem;
  color: var(--gray-400);
  margin-top: 2px;
}

/* Accent-top card variant */
.card-accent-top {
  border-top: 3px solid var(--primary);
}

.card-accent-top-success {
  border-top: 3px solid var(--success);
}

.card-accent-top-warning {
  border-top: 3px solid var(--warning);
}

.card-accent-top-danger {
  border-top: 3px solid var(--danger);
}

/* ════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  gap: 7px;
  white-space: nowrap;
  font-family: var(--font-body);
  letter-spacing: 0.1px;
  text-decoration: none;
  outline: none;
  position: relative;
  overflow: hidden;
}

/* Ripple effect on click */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.15);
  opacity: 0;
  transition: opacity 0.2s;
}

.btn:active::after {
  opacity: 1;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--gray-800);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--gray-900);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: white;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.btn-success:hover {
  background: #047857;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(5, 150, 105, 0.35);
}

.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
}

.btn-danger:hover {
  background: #B91C1C;
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.btn-warning:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gray-300);
  color: var(--gray-700);
  box-shadow: none;
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--gray-600);
  box-shadow: none;
  padding: 8px 12px;
}

.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

/* Sizes */
.btn-xs {
  padding: 4px 10px;
  font-size: 0.72rem;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.79rem;
}

.btn-lg {
  padding: 11px 24px;
  font-size: 0.95rem;
}

.btn-xl {
  padding: 13px 32px;
  font-size: 1rem;
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
}

/* ════════════════════════════════════════════
   FORM ELEMENTS
   ════════════════════════════════════════════ */
.form-group {
  margin-bottom: 14px;
}

.form-label,
label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-700);
  letter-spacing: 0.05px;
}

.form-control {
  width: 100%;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--gray-200);
  font-size: 0.85rem;
  font-family: var(--font-body);
  transition: var(--transition);
  background: var(--gray-50);
  color: var(--gray-800);
  outline: none;
  line-height: 1.4;
}

.form-control::placeholder {
  color: var(--gray-400);
}

.form-control:hover {
  border-color: var(--gray-300);
}

.form-control:focus {
  outline: none;
  background: var(--white);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Textarea */
textarea.form-control {
  border-radius: var(--radius-md);
  resize: vertical;
  min-height: 90px;
}

/* Select */
select.form-control {
  cursor: pointer;
}

/* Form hint */
.form-hint {
  font-size: 0.73rem;
  color: var(--gray-500);
  margin-top: 4px;
}

.form-hint.error {
  color: var(--danger);
}

/* Input group */
.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control {
  border-radius: var(--radius-full) 0 0 var(--radius-full);
  border-right: none;
  flex: 1;
}

.input-group .btn {
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

/* Input icon */
.input-with-icon {
  position: relative;
}

.input-with-icon .form-control {
  padding-left: 36px;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 0.82rem;
  pointer-events: none;
}

/* ════════════════════════════════════════════
   TABLES
   ════════════════════════════════════════════ */
.table-responsive {
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  background: var(--white);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  background: var(--gray-50);
  padding: 11px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--gray-600);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  font-size: 0.84rem;
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background 0.12s;
}

tbody tr:hover td {
  background: var(--gray-50);
}

/* Table compact variant */
.table-compact {
  font-size: 0.8rem !important;
}

.table-compact th,
.table-compact td {
  padding: 6px 14px !important;
  font-size: 0.8rem !important;
}

.table-compact thead th {
  font-size: 0.8rem !important;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ════════════════════════════════════════════
   BADGES
   ════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-success {
  background: rgba(5, 150, 105, 0.10);
  color: #065F46;
}

.badge-warning {
  background: rgba(217, 119, 6, 0.12);
  color: #92400E;
}

.badge-danger {
  background: rgba(220, 38, 38, 0.10);
  color: #991B1B;
}

.badge-info {
  background: rgba(2, 132, 199, 0.10);
  color: #075985;
}

.badge-primary {
  background: rgba(99, 102, 241, 0.10);
  color: #3730A3;
}

.badge-gray {
  background: var(--gray-100);
  color: var(--gray-600);
}

.badge-teal {
  background: rgba(13, 148, 136, 0.10);
  color: #0F766E;
}

.badge-amber {
  background: rgba(245, 158, 11, 0.10);
  color: #92400E;
}

/* Dot badges */
.badge-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════
   GRID SYSTEM
   ════════════════════════════════════════════ */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.grid-auto-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.grid-auto-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

@media (max-width: 1024px) {

  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ════════════════════════════════════════════
   AVATARS
   ════════════════════════════════════════════ */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.avatar-sm {
  width: 28px;
  height: 28px;
}

.avatar-md {
  width: 40px;
  height: 40px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
}

.avatar-xl {
  width: 80px;
  height: 80px;
}

.avatar-xxl {
  width: 100px;
  height: 100px;
}

/* Initials avatar */
.avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.72rem;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════
   PAGE TITLE BOX
   ════════════════════════════════════════════ */
.page-title-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

.page-title-box h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.3px;
  margin-bottom: 3px;
}

.page-title-box .subtitle {
  font-size: 0.8rem;
  color: var(--gray-500);
}

/* ════════════════════════════════════════════
   TOGGLE SWITCH
   ════════════════════════════════════════════ */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--gray-300);
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  transition: .3s;
  box-shadow: var(--shadow-xs);
}

input:checked+.slider {
  background: var(--primary);
}

input:focus+.slider {
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input:checked+.slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 22px;
}

.slider.round:before {
  border-radius: 50%;
}

/* ════════════════════════════════════════════
   TABS
   ════════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 22px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 14px;
  font-size: 0.84rem;
  font-family: var(--font-body);
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  font-weight: 500;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn:hover {
  color: var(--gray-700);
  background: var(--gray-50);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
  background: transparent;
}

/* Pill tabs variant */
.tabs-pills {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-pill {
  background: var(--gray-100);
  border: none;
  padding: 6px 14px;
  font-size: 0.81rem;
  font-family: var(--font-body);
  color: var(--gray-600);
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: var(--transition);
  font-weight: 500;
}

.tab-pill:hover {
  background: var(--gray-200);
}

.tab-pill.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
  box-shadow: var(--shadow-primary);
}

/* ════════════════════════════════════════════
   STAT ROW (horizontal stat display)
   ════════════════════════════════════════════ */
.stat-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  gap: 12px;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  flex: 1;
  font-size: 0.83rem;
  color: var(--gray-600);
}

.stat-value {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gray-800);
}

/* ════════════════════════════════════════════
   DIVIDER
   ════════════════════════════════════════════ */
.divider {
  height: 1px;
  background: var(--gray-200);
  margin: 16px 0;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--gray-400);
  font-size: 0.77rem;
  margin: 16px 0;
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

/* ════════════════════════════════════════════
   PROGRESS
   ════════════════════════════════════════════ */
.progress {
  height: 6px;
  background: var(--gray-100);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--primary);
  transition: width 0.5s ease;
}

.progress-bar.success {
  background: var(--success);
}

.progress-bar.warning {
  background: var(--warning);
}

.progress-bar.danger {
  background: var(--danger);
}

/* Inner fill element — used by leave.js, onboarding.js, offboarding.js, performance.js */
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--primary);
  transition: width 0.5s ease;
}

/* Ensure .progress-bar acts as a container when it wraps a .progress-fill child */
.progress-bar:has(.progress-fill) {
  background: var(--gray-200);
  height: 8px;
  border-radius: var(--radius-full);
  overflow: hidden;
}

/* ════════════════════════════════════════════
   ALERTS
   ════════════════════════════════════════════ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  border: 1px solid;
  margin-bottom: 14px;
}

.alert-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 700;
  margin-bottom: 2px;
}

.alert-success {
  background: var(--success-soft);
  border-color: rgba(5, 150, 105, 0.2);
  color: #065F46;
}

.alert-warning {
  background: var(--warning-soft);
  border-color: rgba(217, 119, 6, 0.2);
  color: #92400E;
}

.alert-danger {
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.2);
  color: #991B1B;
}

.alert-info {
  background: var(--info-soft);
  border-color: rgba(2, 132, 199, 0.2);
  color: #075985;
}

.alert-primary {
  background: var(--primary-soft);
  border-color: var(--primary-glow);
  color: var(--primary-dark);
}

/* ════════════════════════════════════════════
   LOADING SPINNER
   ════════════════════════════════════════════ */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-spinner-dark {
  border-color: var(--gray-200);
  border-top-color: var(--primary);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg,
      var(--gray-100) 25%,
      var(--gray-200) 50%,
      var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ════════════════════════════════════════════
   EMPTY STATE
   ════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--gray-500);
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  background: var(--gray-100);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--gray-400);
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.empty-state-desc {
  font-size: 0.82rem;
  color: var(--gray-500);
  max-width: 280px;
}

/* ════════════════════════════════════════════
   KPI / STAT CARD
   ════════════════════════════════════════════ */
.kpi-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--gray-500);
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
  letter-spacing: -1px;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.kpi-delta.up {
  background: var(--success-soft);
  color: var(--success);
}

.kpi-delta.down {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ════════════════════════════════════════════
   DROPDOWN
   ════════════════════════════════════════════ */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 100;
  overflow: hidden;
  animation: fadeUp 0.15s ease-out;
  display: none;
}

.dropdown.show .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 0.83rem;
  color: var(--gray-700);
  cursor: pointer;
  transition: background 0.12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.dropdown-item:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}

.dropdown-item.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.dropdown-divider {
  height: 1px;
  background: var(--gray-100);
  margin: 4px 0;
}

/* ── Company Selection Screen Cards ─────────────────────────── */
.company-select-card {
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: 20px;
  padding: 28px 24px 24px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
}
.company-select-card.hovered,
.company-select-card:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 28px rgba(79,70,229,0.16);
  transform: translateY(-3px);
}
.company-select-btn {
  background: var(--primary);
  color: white;
  border-radius: 10px;
  padding: 11px 20px;
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
  margin-top: auto;
  transition: background 0.15s;
}
.company-select-card:hover .company-select-btn {
  background: var(--primary-dark, #4338ca);
}
