// Scoped to .kra-list-view so the (unrelated) form-view panel keeps its
// normal whole-panel scroll behavior.
.kra-list-view.FormOverView {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kra-container {
  height: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

// ── Stats Row ────────────────────────────────────────
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 16px 16px 0;
  flex-shrink: 0;

  @media (max-width: 900px) {
    grid-template-columns: repeat(2, 1fr);
  }

  @media (max-width: 500px) {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-surface);
  border-radius: 10px;
  padding: 16px 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  border: 1px solid var(--border-subtle);
}

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  flex-shrink: 0;

  mat-icon {
    font-size: 22px;
    width: 22px;
    height: 22px;
  }

  &--total {
    background: #eef2ff;
    mat-icon { color: #4f6fd4; }
  }

  &--active {
    background: #f0fdf4;
    mat-icon { color: #22c55e; }
  }

  &--pb {
    background: #eef4ff;
    mat-icon { color: #1976d2; }
  }

  &--kpi {
    background: #f5f3ff;
    mat-icon { color: #7c3aed; }
  }
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-number {
  font-size: 26px;
  font-weight: 700;
  color: var(--action-primary-default, #7068b1);
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

// ── Filter Bar ───────────────────────────────────────
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
  margin-top: 16px;
  flex-shrink: 0;

  .filter-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }
}

.filter-select-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;

  .filter-select {
    appearance: none;
    padding: 6px 32px 6px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    min-width: 130px;
    transition: border-color 0.2s ease;

    &:focus {
      border-color: var(--action-primary-default, #7068b1);
    }
  }

  .select-arrow {
    position: absolute;
    right: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    pointer-events: none;
  }
}

.filter-search-wrapper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-surface);
  padding: 0 10px;
  gap: 6px;
  transition: border-color 0.2s ease;

  &:focus-within {
    border-color: var(--action-primary-default, #7068b1);
  }

  .searchIcon {
    font-size: 18px;
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    flex-shrink: 0;
  }

  .filter-search {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    padding: 6px 0;
    width: 180px;

    &::placeholder {
      color: var(--text-secondary);
    }
  }
}

// ── Add Button ───────────────────────────────────────
.btn-add-kra {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--action-primary-default, #7068b1);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s ease;

  &:hover { opacity: 0.9; }
}

.btn-icon {
  font-size: 20px;
  width: 20px;
  height: 20px;
}

// ── Table ────────────────────────────────────────────
.table-container {
  background: var(--bg-surface);
  border-radius: 8px;
  margin: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.kra-table {
  width: 100%;
  border-collapse: collapse;

  thead tr {
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border-subtle);

    th {
      position: sticky;
      top: 0;
      z-index: 1;
      background: var(--bg-subtle);
      padding: 12px 16px;
      text-align: left;
      font-size: 12px;
      font-weight: 600;
      color: var(--text-secondary);
      letter-spacing: 0.5px;
      white-space: nowrap;
    }
  }

  tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background 0.15s ease;

    &:last-child { border-bottom: none; }
    &:hover { background: var(--bg-muted); }
    &.row-alternate { background: var(--bg-subtle); }
    &.row-alternate:hover { background: var(--bg-muted); }

    td {
      padding: 12px 16px;
      font-size: 13px;
      color: var(--text-primary);
      vertical-align: middle;

      strong {
        font-weight: 600;
        color: var(--text-primary);
      }
    }
  }
}

// ── Cell styles ──────────────────────────────────────
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-blue {
  background: #E3F2FD;
  color: #1976D2;
}

.badge-green {
  background: #E8F5E9;
  color: #388E3C;
}

.status-active {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #2e7d32;
  color: #2e7d32;
  background: #f1fdf3;
}

.status-inactive {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #e53935;
  color: #e53935;
  background: #fff5f5;
}

// ── Empty State ──────────────────────────────────────
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;

  h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px;
  }

  p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 24px;
  }
}

/* ---- Sort Indicators ---- */
.sortable-col {
  cursor: pointer;
  user-select: none;

  &:hover {
    color: var(--text-primary);
  }
}

.sort-indicator {
  display: inline-flex;
  flex-direction: column;
  margin-left: 5px;
  gap: 1px;
  vertical-align: middle;
  line-height: 1;
}

.sort-arrow-up,
.sort-arrow-down {
  font-size: 8px;
  color: var(--border-subtle);
  line-height: 1;
  display: block;

  &.sort-active {
    color: var(--text-primary);
  }
}

// Form styles
.responsive-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 20px;

  @media (max-width: 768px) {
    grid-template-columns: 1fr;
  }
}

.left-section,
.right-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

// Scrollbar styling
.scrollbar {
  &::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  &::-webkit-scrollbar-track {
    background: var(--scrollbar-track, #f1f1f1);
    border-radius: 4px;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb, #888);
    border-radius: 4px;

    &:hover {
      background: var(--scrollbar-thumb-hover, #555);
    }
  }
}
